diff options
author | Jin Yao <yao.jin@linux.intel.com> | 2019-03-05 08:05:42 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-06 16:05:21 -0500 |
commit | daca23b2007595b6a48255ca08c763f56050d1c5 (patch) | |
tree | ae8ef6d1a59f558901c0cba4928f66306e2dce0b /tools/perf | |
parent | 4802138d78caed36cee2a859f77fb2035f230018 (diff) |
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: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/Documentation/perf-diff.txt | 5 | ||||
-rw-r--r-- | tools/perf/builtin-diff.c | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 036d65bded51..8c2c229faf50 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt | |||
@@ -163,6 +163,11 @@ OPTIONS | |||
163 | the end of perf.data.old and analyzes the perf.data from the | 163 | the end of perf.data.old and analyzes the perf.data from the |
164 | timestamp 3971.150589 to the end of perf.data. | 164 | timestamp 3971.150589 to the end of perf.data. |
165 | 165 | ||
166 | --cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can | ||
167 | be provided as a comma-separated list with no space: 0,1. Ranges of | ||
168 | CPUs are specified with -: 0-2. Default is to report samples on all | ||
169 | CPUs. | ||
170 | |||
166 | COMPARISON | 171 | COMPARISON |
167 | ---------- | 172 | ---------- |
168 | The comparison is governed by the baseline file. The baseline perf.data | 173 | The comparison is governed by the baseline file. The baseline perf.data |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 17cd898074c8..dfe6c7606f5a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -83,6 +83,9 @@ static unsigned int sort_compute = 1; | |||
83 | static s64 compute_wdiff_w1; | 83 | static s64 compute_wdiff_w1; |
84 | static s64 compute_wdiff_w2; | 84 | static s64 compute_wdiff_w2; |
85 | 85 | ||
86 | static const char *cpu_list; | ||
87 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | ||
88 | |||
86 | enum { | 89 | enum { |
87 | COMPUTE_DELTA, | 90 | COMPUTE_DELTA, |
88 | COMPUTE_RATIO, | 91 | COMPUTE_RATIO, |
@@ -354,6 +357,11 @@ static int diff__process_sample_event(struct perf_tool *tool, | |||
354 | return -1; | 357 | return -1; |
355 | } | 358 | } |
356 | 359 | ||
360 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) { | ||
361 | ret = 0; | ||
362 | goto out_put; | ||
363 | } | ||
364 | |||
357 | if (!hists__add_entry(hists, &al, NULL, NULL, NULL, sample, true)) { | 365 | if (!hists__add_entry(hists, &al, NULL, NULL, NULL, sample, true)) { |
358 | pr_warning("problem incrementing symbol period, skipping event\n"); | 366 | pr_warning("problem incrementing symbol period, skipping event\n"); |
359 | goto out_put; | 367 | goto out_put; |
@@ -892,6 +900,13 @@ static int __cmd_diff(void) | |||
892 | goto out_delete; | 900 | goto out_delete; |
893 | } | 901 | } |
894 | 902 | ||
903 | if (cpu_list) { | ||
904 | ret = perf_session__cpu_bitmap(d->session, cpu_list, | ||
905 | cpu_bitmap); | ||
906 | if (ret < 0) | ||
907 | goto out_delete; | ||
908 | } | ||
909 | |||
895 | ret = perf_session__process_events(d->session); | 910 | ret = perf_session__process_events(d->session); |
896 | if (ret) { | 911 | if (ret) { |
897 | pr_err("Failed to process %s\n", d->data.path); | 912 | pr_err("Failed to process %s\n", d->data.path); |
@@ -969,6 +984,7 @@ static const struct option options[] = { | |||
969 | "How to display percentage of filtered entries", parse_filter_percentage), | 984 | "How to display percentage of filtered entries", parse_filter_percentage), |
970 | OPT_STRING(0, "time", &pdiff.time_str, "str", | 985 | OPT_STRING(0, "time", &pdiff.time_str, "str", |
971 | "Time span (time percent or absolute timestamp)"), | 986 | "Time span (time percent or absolute timestamp)"), |
987 | OPT_STRING(0, "cpu", &cpu_list, "cpu", "list of cpus to profile"), | ||
972 | OPT_END() | 988 | OPT_END() |
973 | }; | 989 | }; |
974 | 990 | ||