lkml.org 
[lkml]   [2019]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@kernel.org>
> Cc: Li Zefan <lizefan@huawei.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.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?

\
 
 \ /
  Last update: 2019-12-20 10:37    [W:0.093 / U:2.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site