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

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

perf tools: Add support for weight v7 (modified)



perf record has a new option -W that enables weightened sampling.

Add sorting support in top/report for the average weight per sample and the
total weight sum. This allows to both compare relative cost per event
and the total cost over the measurement period.

Add the necessary glue to perf report, record and the library.

v2: Merge with new hist refactoring.
v3: Fix manpage. Remove value check.
Rename global_weight to weight and weight to local_weight.
v4: Readd sort keys to manpage
v5: Move weight to end
v6: Move weight to template
v7: Rename weight key.

Original patch from Andi modified by Stephane Eranian <eranian@google.com>
to include ONLY the weight supporting code and apply to pristine 3.8.0-rc4.

Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1359040242-8269-6-git-send-email-eranian@google.com


[ committer note: changed to cope with fc5871ed and the hists_link perf test entry ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2fe85427
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -182,6 +182,12 @@ is enabled for all the sampling events. The sampled branch type is the same for
The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
Note that this feature may not be available on all processors.

-W::
--weight::
Enable weightened sampling. An additional weight is recorded per sample and can be
displayed with the weight and local_weight sort keys.  This currently works for TSX
abort events and some memory events in precise mode on modern Intel CPUs.

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ OPTIONS
--sort=::
	Sort histogram entries by given key(s) - multiple keys can be specified
	in CSV format.  Following sort keys are available:
	pid, comm, dso, symbol, parent, cpu, srcline.
	pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight.

	Each key has following meaning:

+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ Default is to monitor all CPUS.

-s::
--sort::
	Sort by key(s): pid, comm, dso, symbol, parent, srcline.
	Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight, local_weight.

-n::
--show-nr-samples::
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
		return 0;
	}

	he = __hists__add_entry(&evsel->hists, al, NULL, 1);
	he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1);
	if (he == NULL)
		return -ENOMEM;

+4 −3
Original line number Diff line number Diff line
@@ -231,9 +231,10 @@ int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair,
}

static int hists__add_entry(struct hists *self,
			    struct addr_location *al, u64 period)
			    struct addr_location *al, u64 period,
			    u64 weight)
{
	if (__hists__add_entry(self, al, NULL, period) != NULL)
	if (__hists__add_entry(self, al, NULL, period, weight) != NULL)
		return 0;
	return -ENOMEM;
}
@@ -255,7 +256,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
	if (al.filtered)
		return 0;

	if (hists__add_entry(&evsel->hists, &al, sample->period)) {
	if (hists__add_entry(&evsel->hists, &al, sample->period, sample->weight)) {
		pr_warning("problem incrementing symbol period, skipping event\n");
		return -1;
	}
Loading