diff options
author | Jiri Olsa <jolsa@redhat.com> | 2017-02-27 04:48:18 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-03-03 17:07:19 -0500 |
commit | e3ba76deef23064fc272424b86b506cd80b04fc5 (patch) | |
tree | 69c46c0708f4ac1a8ca5a32c496a67188b797484 | |
parent | d0e02579c282ccf34c79818045ec2d2934b56c19 (diff) |
perf tools: Force uncore events to system wide monitoring
Make system wide (-a) the default option if no target was specified and
one of following conditions is met:
- there's no workload specified (current behaviour)
- there is workload specified but all requested
events are system wide ones
Mixed events core/uncore with workload:
$ perf stat -e 'uncore_cbox_0/clockticks/,cycles' sleep 1
Performance counter stats for 'sleep 1':
<not supported> uncore_cbox_0/clockticks/
980,489 cycles
1.000897406 seconds time elapsed
Uncore event with workload:
$ perf stat -e 'uncore_cbox_0/clockticks/' sleep 1
Performance counter stats for 'system wide':
281,473,897,192,670 uncore_cbox_0/clockticks/
1.000833784 seconds time elapsed
Committer note:
When testing I realized the default case for !root, i.e. no events
passed via -e, was broke by v2 of this patch, reported and after a
patch provided by Jiri it is back working:
[acme@jouet linux]$ perf stat usleep 1
Performance counter stats for 'usleep 1':
0.401335 task-clock:u (msec) # 0.297 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
48 page-faults:u # 0.120 M/sec
458,146 cycles:u # 1.142 GHz
245,113 instructions:u # 0.54 insn per cycle
47,991 branches:u # 119.578 M/sec
4,022 branch-misses:u # 8.38% of all branches
0.001350029 seconds time elapsed
[acme@jouet linux]$
Suggested-and-Tested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20170227094818.GA12764@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 33 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 5 |
2 files changed, 33 insertions, 5 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index f4f555a67e9b..f53f449d864d 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -2350,6 +2350,35 @@ static int __cmd_report(int argc, const char **argv) | |||
2350 | return 0; | 2350 | return 0; |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | static void setup_system_wide(int forks) | ||
2354 | { | ||
2355 | /* | ||
2356 | * Make system wide (-a) the default target if | ||
2357 | * no target was specified and one of following | ||
2358 | * conditions is met: | ||
2359 | * | ||
2360 | * - there's no workload specified | ||
2361 | * - there is workload specified but all requested | ||
2362 | * events are system wide events | ||
2363 | */ | ||
2364 | if (!target__none(&target)) | ||
2365 | return; | ||
2366 | |||
2367 | if (!forks) | ||
2368 | target.system_wide = true; | ||
2369 | else { | ||
2370 | struct perf_evsel *counter; | ||
2371 | |||
2372 | evlist__for_each_entry(evsel_list, counter) { | ||
2373 | if (!counter->system_wide) | ||
2374 | return; | ||
2375 | } | ||
2376 | |||
2377 | if (evsel_list->nr_entries) | ||
2378 | target.system_wide = true; | ||
2379 | } | ||
2380 | } | ||
2381 | |||
2353 | int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) | 2382 | int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) |
2354 | { | 2383 | { |
2355 | const char * const stat_usage[] = { | 2384 | const char * const stat_usage[] = { |
@@ -2456,9 +2485,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2456 | } else if (big_num_opt == 0) /* User passed --no-big-num */ | 2485 | } else if (big_num_opt == 0) /* User passed --no-big-num */ |
2457 | big_num = false; | 2486 | big_num = false; |
2458 | 2487 | ||
2459 | /* Make system wide (-a) the default target. */ | 2488 | setup_system_wide(argc); |
2460 | if (!argc && target__none(&target)) | ||
2461 | target.system_wide = true; | ||
2462 | 2489 | ||
2463 | if (run_count < 0) { | 2490 | if (run_count < 0) { |
2464 | pr_err("Run count must be a positive number\n"); | 2491 | pr_err("Run count must be a positive number\n"); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 67a8aebc67ab..54355d3caf09 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -316,8 +316,9 @@ __add_event(struct list_head *list, int *idx, | |||
316 | return NULL; | 316 | return NULL; |
317 | 317 | ||
318 | (*idx)++; | 318 | (*idx)++; |
319 | evsel->cpus = cpu_map__get(cpus); | 319 | evsel->cpus = cpu_map__get(cpus); |
320 | evsel->own_cpus = cpu_map__get(cpus); | 320 | evsel->own_cpus = cpu_map__get(cpus); |
321 | evsel->system_wide = !!cpus; | ||
321 | 322 | ||
322 | if (name) | 323 | if (name) |
323 | evsel->name = strdup(name); | 324 | evsel->name = strdup(name); |