Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4968ac8f authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo
Browse files

perf report: Implement browsing of individual samples



Now 'perf report' can show whole time periods with 'perf script', but
the user still has to find individual samples of interest manually.

It would be expensive and complicated to search for the right samples in
the whole perf file. Typically users only need to look at a small number
of samples for useful analysis.

Also the full scripts tend to show samples of all CPUs and all threads
mixed up, which can be very confusing on larger systems.

Add a new --samples option to save a small random number of samples per
hist entry.

Use a reservoir sample technique to select a representatve number of
samples.

Then allow browsing the samples using 'perf script' as part of the hist
entry context menu. This automatically adds the right filters, so only
the thread or cpu of the sample is displayed. Then we use less' search
functionality to directly jump the to the time stamp of the selected
sample.

It uses different menus for assembler and source display.  Assembler
needs xed installed and source needs debuginfo.

Currently it only supports as many samples as fit on the screen due to
some limitations in the slang ui code.

Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190311174605.GA29294@tassilo.jf.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6f3da20e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -584,6 +584,12 @@ llvm.*::
	llvm.opts::
		Options passed to llc.

samples.*::

	samples.context::
		Define how many ns worth of time to show
		around samples in perf report sample context browser.

SEE ALSO
--------
linkperf:perf[1]
+4 −0
Original line number Diff line number Diff line
@@ -461,6 +461,10 @@ include::itrace.txt[]
--socket-filter::
	Only report the samples on the processor socket that match with this filter

--samples=N::
	Save N individual samples for each histogram entry to show context in perf
	report tui browser.

--raw-trace::
	When displaying traceevent output, do not use print fmt or plugins.

+2 −0
Original line number Diff line number Diff line
@@ -1159,6 +1159,8 @@ int cmd_report(int argc, const char **argv)
	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
		    "Enable kernel symbol demangling"),
	OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
	OPT_INTEGER(0, "samples", &symbol_conf.res_sample,
		    "Number of samples to save per histogram entry for individual browsing"),
	OPT_CALLBACK(0, "percent-limit", &report, "percent",
		     "Don't show entries under that percent", parse_percent_limit),
	OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ perf-y += hists.o
perf-y += map.o
perf-y += scripts.o
perf-y += header.o
perf-y += res_sample.o

CFLAGS_annotate.o += -DENABLE_SLFUTURE_CONST
CFLAGS_hists.o    += -DENABLE_SLFUTURE_CONST
+47 −0
Original line number Diff line number Diff line
@@ -1226,6 +1226,8 @@ void hist_browser__init_hpp(void)
				hist_browser__hpp_color_overhead_guest_us;
	perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color =
				hist_browser__hpp_color_overhead_acc;

	res_sample_init();
}

static int hist_browser__show_entry(struct hist_browser *browser,
@@ -2345,6 +2347,7 @@ struct popup_action {
	struct map_symbol 	ms;
	int			socket;
	struct perf_evsel	*evsel;
	enum rstype		rstype;

	int (*fn)(struct hist_browser *browser, struct popup_action *act);
};
@@ -2572,6 +2575,17 @@ do_run_script(struct hist_browser *browser __maybe_unused,
	return 0;
}

static int
do_res_sample_script(struct hist_browser *browser __maybe_unused,
		     struct popup_action *act)
{
	struct hist_entry *he;

	he = hist_browser__selected_entry(browser);
	res_sample_browse(he->res_samples, he->num_res, act->evsel, act->rstype);
	return 0;
}

static int
add_script_opt_2(struct hist_browser *browser __maybe_unused,
	       struct popup_action *act, char **optstr,
@@ -2629,6 +2643,27 @@ add_script_opt(struct hist_browser *browser,
	return n;
}

static int
add_res_sample_opt(struct hist_browser *browser __maybe_unused,
		   struct popup_action *act, char **optstr,
		   struct res_sample *res_sample,
		   struct perf_evsel *evsel,
		   enum rstype type)
{
	if (!res_sample)
		return 0;

	if (asprintf(optstr, "Show context for individual samples %s",
		type == A_ASM ? "with assembler" :
		type == A_SOURCE ? "with source" : "") < 0)
		return 0;

	act->fn = do_res_sample_script;
	act->evsel = evsel;
	act->rstype = type;
	return 1;
}

static int
do_switch_data(struct hist_browser *browser __maybe_unused,
	       struct popup_action *act __maybe_unused)
@@ -3115,6 +3150,18 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
		}
		nr_options += add_script_opt(browser, &actions[nr_options],
					     &options[nr_options], NULL, NULL, evsel);
		nr_options += add_res_sample_opt(browser, &actions[nr_options],
						 &options[nr_options],
				 hist_browser__selected_entry(browser)->res_samples,
				 evsel, A_NORMAL);
		nr_options += add_res_sample_opt(browser, &actions[nr_options],
						 &options[nr_options],
				 hist_browser__selected_entry(browser)->res_samples,
				 evsel, A_ASM);
		nr_options += add_res_sample_opt(browser, &actions[nr_options],
						 &options[nr_options],
				 hist_browser__selected_entry(browser)->res_samples,
				 evsel, A_SOURCE);
		nr_options += add_switch_opt(browser, &actions[nr_options],
					     &options[nr_options]);
skip_scripting:
Loading