Commit daca23b2 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo

perf diff: Support --cpu filter option

To improve 'perf diff', implement a --cpu filter option.

Multiple CPUs can be provided as a comma-separated list with no space:
0,1.  Ranges of CPUs are specified with -: 0-2. Default is to report
samples on all CPUs.

For example,

  perf diff --cpu 0,1

It only diff the samples for CPU0 and CPU1.
Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1551791143-10334-3-git-send-email-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4802138d
...@@ -163,6 +163,11 @@ OPTIONS ...@@ -163,6 +163,11 @@ OPTIONS
the end of perf.data.old and analyzes the perf.data from the the end of perf.data.old and analyzes the perf.data from the
timestamp 3971.150589 to the end of perf.data. timestamp 3971.150589 to the end of perf.data.
--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
be provided as a comma-separated list with no space: 0,1. Ranges of
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.
COMPARISON COMPARISON
---------- ----------
The comparison is governed by the baseline file. The baseline perf.data The comparison is governed by the baseline file. The baseline perf.data
......
...@@ -83,6 +83,9 @@ static unsigned int sort_compute = 1; ...@@ -83,6 +83,9 @@ static unsigned int sort_compute = 1;
static s64 compute_wdiff_w1; static s64 compute_wdiff_w1;
static s64 compute_wdiff_w2; static s64 compute_wdiff_w2;
static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
enum { enum {
COMPUTE_DELTA, COMPUTE_DELTA,
COMPUTE_RATIO, COMPUTE_RATIO,
...@@ -354,6 +357,11 @@ static int diff__process_sample_event(struct perf_tool *tool, ...@@ -354,6 +357,11 @@ static int diff__process_sample_event(struct perf_tool *tool,
return -1; return -1;
} }
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) {
ret = 0;
goto out_put;
}
if (!hists__add_entry(hists, &al, NULL, NULL, NULL, sample, true)) { if (!hists__add_entry(hists, &al, NULL, NULL, NULL, sample, true)) {
pr_warning("problem incrementing symbol period, skipping event\n"); pr_warning("problem incrementing symbol period, skipping event\n");
goto out_put; goto out_put;
...@@ -892,6 +900,13 @@ static int __cmd_diff(void) ...@@ -892,6 +900,13 @@ static int __cmd_diff(void)
goto out_delete; goto out_delete;
} }
if (cpu_list) {
ret = perf_session__cpu_bitmap(d->session, cpu_list,
cpu_bitmap);
if (ret < 0)
goto out_delete;
}
ret = perf_session__process_events(d->session); ret = perf_session__process_events(d->session);
if (ret) { if (ret) {
pr_err("Failed to process %s\n", d->data.path); pr_err("Failed to process %s\n", d->data.path);
...@@ -969,6 +984,7 @@ static const struct option options[] = { ...@@ -969,6 +984,7 @@ static const struct option options[] = {
"How to display percentage of filtered entries", parse_filter_percentage), "How to display percentage of filtered entries", parse_filter_percentage),
OPT_STRING(0, "time", &pdiff.time_str, "str", OPT_STRING(0, "time", &pdiff.time_str, "str",
"Time span (time percent or absolute timestamp)"), "Time span (time percent or absolute timestamp)"),
OPT_STRING(0, "cpu", &cpu_list, "cpu", "list of cpus to profile"),
OPT_END() OPT_END()
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment