lkml.org 
[lkml]   [2020]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH 9/9] perf script: Add --show-cgroup-events option
Em Wed, Mar 25, 2020 at 09:45:36PM +0900, Namhyung Kim escreveu:
> The --show-cgroup-events option is to print CGROUP events in the
> output like others.

Added this to the comment:

Committer testing:

[root@seventh ~]# perf record --all-cgroups --namespaces /wb/cgtest
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.039 MB perf.data (487 samples) ]
[root@seventh ~]# perf script --show-cgroup-events | grep PERF_RECORD_CGROUP -B2 -A2
swapper 0 0.000000: PERF_RECORD_CGROUP cgroup: 1 /
perf 12145 11200.440730: 1 cycles: ffffffffb900d58b __intel_pmu_enable_all.constprop.0+0x3b (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
perf 12145 11200.440733: 1 cycles: ffffffffb900d58b __intel_pmu_enable_all.constprop.0+0x3b (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
--
cgtest 12145 11200.440739: 193472 cycles: ffffffffb90f6fbc commit_creds+0x1fc (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
cgtest 12145 11200.440790: 2691608 cycles: 7fa2cb43019b _dl_sysdep_start+0x7cb (/usr/lib64/ld-2.29.so)
cgtest 12145 11200.440962: PERF_RECORD_CGROUP cgroup: 83 /sub
cgtest 12147 11200.441054: 1 cycles: ffffffffb900d58b __intel_pmu_enable_all.constprop.0+0x3b (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
cgtest 12147 11200.441057: 1 cycles: ffffffffb900d58b __intel_pmu_enable_all.constprop.0+0x3b (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
--
cgtest 12148 11200.441103: 10227 cycles: ffffffffb9a0153d end_repeat_nmi+0x48 (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
cgtest 12148 11200.441106: 273295 cycles: ffffffffb99ecbc7 copy_page+0x7 (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
cgtest 12147 11200.441133: PERF_RECORD_CGROUP cgroup: 88 /sub/cgrp1
cgtest 12147 11200.441143: 2788845 cycles: ffffffffb94676c2 security_genfs_sid+0x102 (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
cgtest 12148 11200.441162: PERF_RECORD_CGROUP cgroup: 93 /sub/cgrp2
cgtest 12148 11200.441182: 2669546 cycles: 401020 _init+0x20 (/wb/cgtest)
cgtest 12149 11200.441247: 1 cycles: ffffffffb900d58b __intel_pmu_enable_all.constprop.0+0x3b (/lib/modules/5.6.0-rc6-00008-gfe2413eefd7f/build/vmlinux)
[root@seventh ~]#

Thanks, series applied and tested, seems to work :-)

Now to trampolines...

- Arnaldo

> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/Documentation/perf-script.txt | 3 ++
> tools/perf/builtin-script.c | 41 ++++++++++++++++++++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
> index db6a36aac47e..515ff9f6af30 100644
> --- a/tools/perf/Documentation/perf-script.txt
> +++ b/tools/perf/Documentation/perf-script.txt
> @@ -319,6 +319,9 @@ OPTIONS
> --show-bpf-events
> Display bpf events i.e. events of type PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT.
>
> +--show-cgroup-events
> + Display cgroup events i.e. events of type PERF_RECORD_CGROUP.
> +
> --demangle::
> Demangle symbol names to human readable form. It's enabled by default,
> disable with --no-demangle.
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 656b347f6dd8..6cc2d1da6ece 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -1685,6 +1685,7 @@ struct perf_script {
> bool show_lost_events;
> bool show_round_events;
> bool show_bpf_events;
> + bool show_cgroup_events;
> bool allocated;
> bool per_event_dump;
> struct evswitch evswitch;
> @@ -2203,6 +2204,41 @@ static int process_namespaces_event(struct perf_tool *tool,
> return ret;
> }
>
> +static int process_cgroup_event(struct perf_tool *tool,
> + union perf_event *event,
> + struct perf_sample *sample,
> + struct machine *machine)
> +{
> + struct thread *thread;
> + struct perf_script *script = container_of(tool, struct perf_script, tool);
> + struct perf_session *session = script->session;
> + struct evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
> + int ret = -1;
> +
> + thread = machine__findnew_thread(machine, sample->pid, sample->tid);
> + if (thread == NULL) {
> + pr_debug("problem processing CGROUP event, skipping it.\n");
> + return -1;
> + }
> +
> + if (perf_event__process_cgroup(tool, event, sample, machine) < 0)
> + goto out;
> +
> + if (!evsel->core.attr.sample_id_all) {
> + sample->cpu = 0;
> + sample->time = 0;
> + }
> + if (!filter_cpu(sample)) {
> + perf_sample__fprintf_start(sample, thread, evsel,
> + PERF_RECORD_CGROUP, stdout);
> + perf_event__fprintf(event, stdout);
> + }
> + ret = 0;
> +out:
> + thread__put(thread);
> + return ret;
> +}
> +
> static int process_fork_event(struct perf_tool *tool,
> union perf_event *event,
> struct perf_sample *sample,
> @@ -2542,6 +2578,8 @@ static int __cmd_script(struct perf_script *script)
> script->tool.context_switch = process_switch_event;
> if (script->show_namespace_events)
> script->tool.namespaces = process_namespaces_event;
> + if (script->show_cgroup_events)
> + script->tool.cgroup = process_cgroup_event;
> if (script->show_lost_events)
> script->tool.lost = process_lost_event;
> if (script->show_round_events) {
> @@ -3467,6 +3505,7 @@ int cmd_script(int argc, const char **argv)
> .mmap2 = perf_event__process_mmap2,
> .comm = perf_event__process_comm,
> .namespaces = perf_event__process_namespaces,
> + .cgroup = perf_event__process_cgroup,
> .exit = perf_event__process_exit,
> .fork = perf_event__process_fork,
> .attr = process_attr,
> @@ -3567,6 +3606,8 @@ int cmd_script(int argc, const char **argv)
> "Show context switch events (if recorded)"),
> OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
> "Show namespace events (if recorded)"),
> + OPT_BOOLEAN('\0', "show-cgroup-events", &script.show_cgroup_events,
> + "Show cgroup events (if recorded)"),
> OPT_BOOLEAN('\0', "show-lost-events", &script.show_lost_events,
> "Show lost events (if recorded)"),
> OPT_BOOLEAN('\0', "show-round-events", &script.show_round_events,
> --
> 2.25.1.696.g5e7596f4ac-goog
>

--

- Arnaldo

\
 
 \ /
  Last update: 2020-03-27 17:39    [W:0.195 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site