Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf stat: Do not allow --for-each-cgroup without cpu

The cgroup mode should work with cpu events. Warn if --for-each-cgroup
option is used with a task target like existing -G option.

# perf stat --for-each-cgroup . sleep 1
both cgroup and no-aggregation modes only available in system-wide mode

Usage: perf stat [<options>] [<command>]

-G, --cgroup <name> monitor event in cgroup name only
-A, --no-aggr disable CPU count aggregation
-a, --all-cpus system-wide collection from all CPUs
--for-each-cgroup <name>
expand events for each cgroup

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210830170200.55652-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
1c02f6c9 a32762b8

+3 -1
+3 -1
tools/perf/builtin-stat.c
··· 2386 2386 * --per-thread is aggregated per thread, we dont mix it with cpu mode 2387 2387 */ 2388 2388 if (((stat_config.aggr_mode != AGGR_GLOBAL && 2389 - stat_config.aggr_mode != AGGR_THREAD) || nr_cgroups) && 2389 + stat_config.aggr_mode != AGGR_THREAD) || 2390 + (nr_cgroups || stat_config.cgroup_list)) && 2390 2391 !target__has_cpu(&target)) { 2391 2392 fprintf(stderr, "both cgroup and no-aggregation " 2392 2393 "modes only available in system-wide mode\n"); ··· 2395 2394 parse_options_usage(stat_usage, stat_options, "G", 1); 2396 2395 parse_options_usage(NULL, stat_options, "A", 1); 2397 2396 parse_options_usage(NULL, stat_options, "a", 1); 2397 + parse_options_usage(NULL, stat_options, "for-each-cgroup", 0); 2398 2398 goto out; 2399 2399 } 2400 2400