From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Stephane Eranian <eranian@google.com>,
Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH 3/9] perf tools: Basic support for CGROUP event
Date: Fri, 30 Aug 2019 09:55:24 -0300 [thread overview]
Message-ID: <20190830125524.GA4082@kernel.org> (raw)
In-Reply-To: <20190828073130.83800-4-namhyung@kernel.org>
Em Wed, Aug 28, 2019 at 04:31:24PM +0900, Namhyung Kim escreveu:
> Implement basic functionality to support cgroup tracking. Each cgroup
> can be identified by inode number which can be read from userspace
> too. The actual cgroup processing will come in the later patch.
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/include/uapi/linux/perf_event.h | 17 +++++++++++++++--
Try to have the synchronization of tools/include/ with the kernel to be
done in a separate patch, please, there is a number of projects such as
libbpf and in time libperf that will have a mirror repo outside the
kernel tree and that will get just the needed csets.
- Arnaldo
> tools/perf/builtin-diff.c | 1 +
> tools/perf/builtin-report.c | 1 +
> tools/perf/lib/include/perf/event.h | 7 +++++++
> tools/perf/util/event.c | 18 ++++++++++++++++++
> tools/perf/util/event.h | 7 +++++++
> tools/perf/util/evsel.c | 7 +++++++
> tools/perf/util/machine.c | 12 ++++++++++++
> tools/perf/util/machine.h | 3 +++
> tools/perf/util/session.c | 4 ++++
> tools/perf/util/tool.h | 1 +
> 11 files changed, 76 insertions(+), 2 deletions(-)
>
> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index bb7b271397a6..91a552bf9611 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h
> @@ -141,8 +141,9 @@ enum perf_event_sample_format {
> PERF_SAMPLE_TRANSACTION = 1U << 17,
> PERF_SAMPLE_REGS_INTR = 1U << 18,
> PERF_SAMPLE_PHYS_ADDR = 1U << 19,
> + PERF_SAMPLE_CGROUP = 1U << 20,
>
> - PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
> + PERF_SAMPLE_MAX = 1U << 21, /* non-ABI */
>
> __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */
> };
> @@ -375,7 +376,8 @@ struct perf_event_attr {
> ksymbol : 1, /* include ksymbol events */
> bpf_event : 1, /* include bpf events */
> aux_output : 1, /* generate AUX records instead of events */
> - __reserved_1 : 32;
> + cgroup : 1, /* include cgroup events */
> + __reserved_1 : 31;
>
> union {
> __u32 wakeup_events; /* wakeup every n events */
> @@ -1000,6 +1002,17 @@ enum perf_event_type {
> */
> PERF_RECORD_BPF_EVENT = 18,
>
> + /*
> + * struct {
> + * struct perf_event_header header;
> + * u64 ino;
> + * u64 path_len;
> + * char path[];
> + * struct sample_id sample_id;
> + * };
> + */
> + PERF_RECORD_CGROUP = 19,
> +
> PERF_RECORD_MAX, /* non-ABI */
> };
>
> diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
> index 51c37e53b3d8..ec639340bb65 100644
> --- a/tools/perf/builtin-diff.c
> +++ b/tools/perf/builtin-diff.c
> @@ -445,6 +445,7 @@ static struct perf_diff pdiff = {
> .fork = perf_event__process_fork,
> .lost = perf_event__process_lost,
> .namespaces = perf_event__process_namespaces,
> + .cgroup = perf_event__process_cgroup,
> .ordered_events = true,
> .ordering_requires_timestamps = true,
> },
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 318b0b95c14c..c65a59fd2a94 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1033,6 +1033,7 @@ int cmd_report(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,
> .lost = perf_event__process_lost,
> diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
> index 36ad3a4a79e6..ec112ad640a1 100644
> --- a/tools/perf/lib/include/perf/event.h
> +++ b/tools/perf/lib/include/perf/event.h
> @@ -104,6 +104,13 @@ struct perf_record_bpf_event {
> __u8 tag[BPF_TAG_SIZE]; // prog tag
> };
>
> +struct perf_record_cgroup {
> + struct perf_event_header header;
> + __u64 ino;
> + __u64 path_len;
> + char path[PATH_MAX];
> +};
> +
> struct perf_record_sample {
> struct perf_event_header header;
> __u64 array[];
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 33616ea62a47..c19b00c1fc26 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -52,6 +52,7 @@ static const char *perf_event__names[] = {
> [PERF_RECORD_NAMESPACES] = "NAMESPACES",
> [PERF_RECORD_KSYMBOL] = "KSYMBOL",
> [PERF_RECORD_BPF_EVENT] = "BPF_EVENT",
> + [PERF_RECORD_CGROUP] = "CGROUP",
> [PERF_RECORD_HEADER_ATTR] = "ATTR",
> [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
> [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
> @@ -1279,6 +1280,12 @@ size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp)
> return ret;
> }
>
> +size_t perf_event__fprintf_cgroup(union perf_event *event, FILE *fp)
> +{
> + return fprintf(fp, " cgroup: %" PRI_lu64 " %s\n",
> + event->cgroup.ino, event->cgroup.path);
> +}
> +
> int perf_event__process_comm(struct perf_tool *tool __maybe_unused,
> union perf_event *event,
> struct perf_sample *sample,
> @@ -1295,6 +1302,14 @@ int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused,
> return machine__process_namespaces_event(machine, event, sample);
> }
>
> +int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused,
> + union perf_event *event,
> + struct perf_sample *sample,
> + struct machine *machine)
> +{
> + return machine__process_cgroup_event(machine, event, sample);
> +}
> +
> int perf_event__process_lost(struct perf_tool *tool __maybe_unused,
> union perf_event *event,
> struct perf_sample *sample,
> @@ -1516,6 +1531,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
> case PERF_RECORD_NAMESPACES:
> ret += perf_event__fprintf_namespaces(event, fp);
> break;
> + case PERF_RECORD_CGROUP:
> + ret += perf_event__fprintf_cgroup(event, fp);
> + break;
> case PERF_RECORD_MMAP2:
> ret += perf_event__fprintf_mmap2(event, fp);
> break;
> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
> index 429a3fe52d6c..0170435fd1e8 100644
> --- a/tools/perf/util/event.h
> +++ b/tools/perf/util/event.h
> @@ -123,6 +123,7 @@ struct perf_sample {
> u32 raw_size;
> u64 data_src;
> u64 phys_addr;
> + u64 cgroup;
> u32 flags;
> u16 insn_len;
> u8 cpumode;
> @@ -554,6 +555,7 @@ union perf_event {
> struct perf_record_mmap2 mmap2;
> struct perf_record_comm comm;
> struct perf_record_namespaces namespaces;
> + struct perf_record_cgroup cgroup;
> struct perf_record_fork fork;
> struct perf_record_lost lost;
> struct perf_record_lost_samples lost_samples;
> @@ -663,6 +665,10 @@ int perf_event__process_namespaces(struct perf_tool *tool,
> union perf_event *event,
> struct perf_sample *sample,
> struct machine *machine);
> +int perf_event__process_cgroup(struct perf_tool *tool,
> + union perf_event *event,
> + struct perf_sample *sample,
> + struct machine *machine);
> int perf_event__process_mmap(struct perf_tool *tool,
> union perf_event *event,
> struct perf_sample *sample,
> @@ -750,6 +756,7 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp);
> +size_t perf_event__fprintf_cgroup(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp);
> size_t perf_event__fprintf(union perf_event *event, FILE *fp);
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index fa676355559e..86a38679cad1 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1593,6 +1593,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
> PRINT_ATTRf(ksymbol, p_unsigned);
> PRINT_ATTRf(bpf_event, p_unsigned);
> PRINT_ATTRf(aux_output, p_unsigned);
> + PRINT_ATTRf(cgroup, p_unsigned);
>
> PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned);
> PRINT_ATTRf(bp_type, p_unsigned);
> @@ -2369,6 +2370,12 @@ int perf_evsel__parse_sample(struct evsel *evsel, union perf_event *event,
> array++;
> }
>
> + data->cgroup = 0;
> + if (type & PERF_SAMPLE_CGROUP) {
> + data->cgroup = *array;
> + array++;
> + }
> +
> return 0;
> }
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 93483f1764d3..61c35eef616b 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -642,6 +642,16 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused,
> return err;
> }
>
> +int machine__process_cgroup_event(struct machine *machine __maybe_unused,
> + union perf_event *event,
> + struct perf_sample *sample __maybe_unused)
> +{
> + if (dump_trace)
> + perf_event__fprintf_cgroup(event, stdout);
> +
> + return 0;
> +}
> +
> int machine__process_lost_event(struct machine *machine __maybe_unused,
> union perf_event *event, struct perf_sample *sample __maybe_unused)
> {
> @@ -1902,6 +1912,8 @@ int machine__process_event(struct machine *machine, union perf_event *event,
> ret = machine__process_mmap_event(machine, event, sample); break;
> case PERF_RECORD_NAMESPACES:
> ret = machine__process_namespaces_event(machine, event, sample); break;
> + case PERF_RECORD_CGROUP:
> + ret = machine__process_cgroup_event(machine, event, sample); break;
> case PERF_RECORD_MMAP2:
> ret = machine__process_mmap2_event(machine, event, sample); break;
> case PERF_RECORD_FORK:
> diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
> index 7d69119d0b5d..608813ced0cd 100644
> --- a/tools/perf/util/machine.h
> +++ b/tools/perf/util/machine.h
> @@ -127,6 +127,9 @@ int machine__process_switch_event(struct machine *machine,
> int machine__process_namespaces_event(struct machine *machine,
> union perf_event *event,
> struct perf_sample *sample);
> +int machine__process_cgroup_event(struct machine *machine,
> + union perf_event *event,
> + struct perf_sample *sample);
> int machine__process_mmap_event(struct machine *machine, union perf_event *event,
> struct perf_sample *sample);
> int machine__process_mmap2_event(struct machine *machine, union perf_event *event,
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 5786e9c807c5..2cdce7ee228c 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -457,6 +457,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
> tool->comm = process_event_stub;
> if (tool->namespaces == NULL)
> tool->namespaces = process_event_stub;
> + if (tool->cgroup == NULL)
> + tool->cgroup = process_event_stub;
> if (tool->fork == NULL)
> tool->fork = process_event_stub;
> if (tool->exit == NULL)
> @@ -1417,6 +1419,8 @@ static int machines__deliver_event(struct machines *machines,
> return tool->comm(tool, event, sample, machine);
> case PERF_RECORD_NAMESPACES:
> return tool->namespaces(tool, event, sample, machine);
> + case PERF_RECORD_CGROUP:
> + return tool->cgroup(tool, event, sample, machine);
> case PERF_RECORD_FORK:
> return tool->fork(tool, event, sample, machine);
> case PERF_RECORD_EXIT:
> diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
> index 2abbf668b8de..472ef5eb4068 100644
> --- a/tools/perf/util/tool.h
> +++ b/tools/perf/util/tool.h
> @@ -46,6 +46,7 @@ struct perf_tool {
> mmap2,
> comm,
> namespaces,
> + cgroup,
> fork,
> exit,
> lost,
> --
> 2.23.0.187.g17f5b7556c-goog
--
- Arnaldo
next prev parent reply other threads:[~2019-08-30 12:55 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 7:31 [PATCHSET 0/9] perf: Improve cgroup profiling (v1) Namhyung Kim
2019-08-28 7:31 ` [PATCH 1/9] perf/core: Add PERF_RECORD_CGROUP event Namhyung Kim
2019-08-28 9:44 ` Peter Zijlstra
2019-08-28 9:44 ` Peter Zijlstra
2019-08-28 13:13 ` Arnaldo Carvalho de Melo
2019-08-30 3:46 ` Namhyung Kim
2019-08-30 7:34 ` Peter Zijlstra
2019-08-30 22:49 ` Namhyung Kim
2019-08-30 23:52 ` Stephane Eranian
2019-08-28 14:48 ` Tejun Heo
2019-08-30 3:56 ` Namhyung Kim
2019-08-28 7:31 ` [PATCH 2/9] perf/core: Add PERF_SAMPLE_CGROUP feature Namhyung Kim
2019-08-28 14:49 ` Tejun Heo
2019-08-31 3:03 ` Namhyung Kim
2019-08-31 4:58 ` Tejun Heo
2019-09-03 2:13 ` Namhyung Kim
2019-09-05 16:56 ` Tejun Heo
2019-09-08 13:28 ` Namhyung Kim
2019-09-14 14:02 ` Song Liu
2019-09-16 15:23 ` Tejun Heo
2019-09-19 6:42 ` Song Liu
2019-09-20 8:47 ` Namhyung Kim
2019-09-20 16:13 ` Song Liu
2019-09-20 21:04 ` Tejun Heo
2019-10-02 6:28 ` Namhyung Kim
2019-10-07 14:16 ` Tejun Heo
2019-08-28 7:31 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2019-08-30 12:55 ` Arnaldo Carvalho de Melo [this message]
2019-08-30 22:51 ` Namhyung Kim
2019-08-28 7:31 ` [PATCH 4/9] perf tools: Maintain cgroup hierarchy Namhyung Kim
2019-08-28 7:31 ` [PATCH 5/9] perf report: Add 'cgroup' sort key Namhyung Kim
2019-08-28 7:31 ` [PATCH 6/9] perf record: Support synthesizing cgroup events Namhyung Kim
2019-08-28 7:31 ` [PATCH 7/9] perf record: Add --all-cgroups option Namhyung Kim
2019-08-28 7:31 ` [PATCH 8/9] perf top: " Namhyung Kim
2019-08-28 7:31 ` [PATCH 9/9] perf script: Add --show-cgroup-events option Namhyung Kim
2019-12-20 4:32 [PATCHSET 0/9] perf: Improve cgroup profiling (v2) Namhyung Kim
2019-12-20 4:32 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2019-12-23 6:07 [PATCHSET 0/9] perf: Improve cgroup profiling (v3) Namhyung Kim
2019-12-23 6:07 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2020-01-07 13:34 [PATCHSET 0/9] perf: Improve cgroup profiling (v4) Namhyung Kim
2020-01-07 13:34 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2020-03-25 12:45 [PATCHSET 0/9] perf: Improve cgroup profiling (v6) Namhyung Kim
2020-03-25 12:45 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2020-03-27 14:06 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190830125524.GA4082@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).