[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191220093613.GD2844@hirez.programming.kicks-ass.net>
Date: Fri, 20 Dec 2019 10:36:13 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>,
Stephane Eranian <eranian@...gle.com>,
LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH 2/9] perf/core: Add PERF_SAMPLE_CGROUP feature
On Fri, Dec 20, 2019 at 01:32:46PM +0900, Namhyung Kim wrote:
> The PERF_SAMPLE_CGROUP bit is to save (perf_event) cgroup information
> in the sample. It will add a 64-bit id to identify current cgroup and
> it's the file handle in the cgroup file system. Userspace should use
> this information with PERF_RECORD_CGROUP event to match which cgroup
> it belongs.
>
> I put it before PERF_SAMPLE_AUX for simplicity since it just needs a
> 64-bit word. But if we want bigger samples, I can work on that
> direction too.
>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: Li Zefan <lizefan@...wei.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
> @@ -6895,6 +6901,18 @@ void perf_prepare_sample(struct perf_event_header *header,
> if (sample_type & PERF_SAMPLE_PHYS_ADDR)
> data->phys_addr = perf_virt_to_phys(data->addr);
>
> + if (sample_type & PERF_SAMPLE_CGROUP) {
> + u64 cgrp_id = 0;
> +#ifdef CONFIG_CGROUP_PERF
> + struct cgroup *cgrp;
> +
> + /* protected by RCU */
> + cgrp = task_css_check(current, perf_event_cgrp_id, 1)->cgroup;
> + cgrp_id = cgroup_id(cgrp);
> +#endif
> + data->cgroup = cgrp_id;
> + }
Would it make more sense to refuse SAMPLE_CGROUP if !CGROUP_PERF?
Powered by blists - more mailing lists