tools/perf/builtin-top.c

Source file repositories/reference/linux-study-clean/tools/perf/builtin-top.c

File Facts

System
Linux kernel
Corpus path
tools/perf/builtin-top.c
Extension
.c
Size
51809 bytes
Lines
1907
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

else if (err == -ENOMEM) {
			pr_err("Not enough memory for annotating '%s' symbol!\n",
			       sym->name);
			sleep(1);
		}

		mutex_lock(&he->hists->lock);
	}
}

static void perf_top__show_details(struct perf_top *top)
{
	struct hist_entry *he = top->sym_filter_entry;
	struct evsel *evsel;
	struct annotation *notes;
	struct symbol *symbol;
	int more;

	if (!he)
		return;

	evsel = hists_to_evsel(he->hists);

	symbol = he->ms.sym;
	notes = symbol__annotation(symbol);

	annotation__lock(notes);

	symbol__calc_percent(symbol, evsel);

	if (notes->src == NULL)
		goto out_unlock;

	printf("Showing %s for %s\n", evsel__name(top->sym_evsel), symbol->name);
	printf("  Events  Pcnt (>=%d%%)\n", annotate_opts.min_pcnt);

	more = hist_entry__annotate_printf(he, top->sym_evsel);

	if (top->evlist->enabled) {
		if (top->zero)
			symbol__annotate_zero_histogram(symbol, top->sym_evsel);
		else
			symbol__annotate_decay_histogram(symbol, top->sym_evsel);
	}
	if (more != 0)
		printf("%d lines not displayed, maybe increase display entries [e]\n", more);
out_unlock:
	annotation__unlock(notes);
}

static void perf_top__resort_hists(struct perf_top *t)
{
	struct evlist *evlist = t->evlist;
	struct evsel *pos;

	evlist__for_each_entry(evlist, pos) {
		struct hists *hists = evsel__hists(pos);

		/*
		 * unlink existing entries so that they can be linked
		 * in a correct order in hists__match() below.
		 */
		hists__unlink(hists);

		if (evlist->enabled) {
			if (t->zero) {
				hists__delete_entries(hists);
			} else {
				hists__decay_entries(hists, t->hide_user_symbols,
						     t->hide_kernel_symbols);
			}
		}

		hists__collapse_resort(hists, NULL);

		/* Non-group events are considered as leader */
		if (symbol_conf.event_group && !evsel__is_group_leader(pos)) {
			struct hists *leader_hists = evsel__hists(evsel__leader(pos));

			hists__match(leader_hists, hists);
			hists__link(leader_hists, hists);
		}
	}

	evlist__for_each_entry(evlist, pos) {
		evsel__output_resort(pos, NULL);
	}
}

static void perf_top__print_sym_table(struct perf_top *top)

Annotation

Implementation Notes