perf record: Add --all-cgroups option
The --all-cgroups option is to enable cgroup profiling support. It
tells kernel to record CGROUP events in the ring buffer so that perf
report can identify task/cgroup association later.
[root@seventh ~]# perf record --all-cgroups --namespaces /wb/cgtest
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.042 MB perf.data (558 samples) ]
[root@seventh ~]# perf report --stdio -s cgroup_id,cgroup,pid
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 558 of event 'cycles'
# Event count (approx.): 458017341
#
# Overhead cgroup id (dev/inode) Cgroup Pid:Command
# ........ ..................... .......... ...............
#
33.15% 4/0xeffffffb /sub 9615:looper0
32.83% 4/0xf00002f5 /sub/cgrp2 9620:looper2
32.79% 4/0xf00002f4 /sub/cgrp1 9619:looper1
0.35% 4/0xf00002f5 /sub/cgrp2 9618:cgtest
0.34% 4/0xf00002f4 /sub/cgrp1 9617:cgtest
0.32% 4/0xeffffffb / 9615:looper0
0.11% 4/0xeffffffb /sub 9617:cgtest
0.10% 4/0xeffffffb /sub 9618:cgtest
#
# (Tip: Sample related events with: perf record -e '{cycles,instructions}:S')
#
[root@seventh ~]#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200325124536.2800725-8-namhyung@kernel.org
Link: http://lore.kernel.org/lkml/20200402015249.3800462-1-namhyung@kernel.org
[ Extracted the HAVE_FILE_HANDLE from the followup patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
ab64069f1a
commit
8fb4b67939
@@ -1104,6 +1104,11 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
|
||||
if (opts->record_namespaces)
|
||||
attr->namespaces = track;
|
||||
|
||||
if (opts->record_cgroup) {
|
||||
attr->cgroup = track && !perf_missing_features.cgroup;
|
||||
perf_evsel__set_sample_bit(evsel, CGROUP);
|
||||
}
|
||||
|
||||
if (opts->record_switch_events)
|
||||
attr->context_switch = track;
|
||||
|
||||
@@ -1789,7 +1794,11 @@ try_fallback:
|
||||
* Must probe features in the order they were added to the
|
||||
* perf_event_attr interface.
|
||||
*/
|
||||
if (!perf_missing_features.branch_hw_idx &&
|
||||
if (!perf_missing_features.cgroup && evsel->core.attr.cgroup) {
|
||||
perf_missing_features.cgroup = true;
|
||||
pr_debug2_peo("Kernel has no cgroup sampling support, bailing out\n");
|
||||
goto out_close;
|
||||
} else if (!perf_missing_features.branch_hw_idx &&
|
||||
(evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX)) {
|
||||
perf_missing_features.branch_hw_idx = true;
|
||||
pr_debug2("switching off branch HW index support\n");
|
||||
|
||||
@@ -120,6 +120,7 @@ struct perf_missing_features {
|
||||
bool bpf;
|
||||
bool aux_output;
|
||||
bool branch_hw_idx;
|
||||
bool cgroup;
|
||||
};
|
||||
|
||||
extern struct perf_missing_features perf_missing_features;
|
||||
|
||||
@@ -34,6 +34,7 @@ struct record_opts {
|
||||
bool auxtrace_snapshot_on_exit;
|
||||
bool auxtrace_sample_mode;
|
||||
bool record_namespaces;
|
||||
bool record_cgroup;
|
||||
bool record_switch_events;
|
||||
bool all_kernel;
|
||||
bool all_user;
|
||||
|
||||
Reference in New Issue
Block a user