Commit be96b316 authored by Tejun Heo's avatar Tejun Heo Committed by Ingo Molnar

perf/cgroup: Fix perf cgroup hierarchy support

The following commit:

  864c2357 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups")

made list_update_cgroup_event() skip setting cpuctx->cgrp if no cgroup event
targets %current's cgroup.

This breaks perf_event's hierarchical support because events which target one
of the ancestors get ignored.

Fix it by using cgroup_is_descendant() test instead of equality.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: David Carrillo-Cisneros <davidcc@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kernel-team@fb.com
Cc: stable@vger.kernel.org # v4.9+
Fixes: 864c2357 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups")
Link: http://lkml.kernel.org/r/20171028164237.GA972780@devbig577.frc2.facebook.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 4139433c
...@@ -901,9 +901,11 @@ list_update_cgroup_event(struct perf_event *event, ...@@ -901,9 +901,11 @@ list_update_cgroup_event(struct perf_event *event,
cpuctx_entry = &cpuctx->cgrp_cpuctx_entry; cpuctx_entry = &cpuctx->cgrp_cpuctx_entry;
/* cpuctx->cgrp is NULL unless a cgroup event is active in this CPU .*/ /* cpuctx->cgrp is NULL unless a cgroup event is active in this CPU .*/
if (add) { if (add) {
struct perf_cgroup *cgrp = perf_cgroup_from_task(current, ctx);
list_add(cpuctx_entry, this_cpu_ptr(&cgrp_cpuctx_list)); list_add(cpuctx_entry, this_cpu_ptr(&cgrp_cpuctx_list));
if (perf_cgroup_from_task(current, ctx) == event->cgrp) if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup))
cpuctx->cgrp = event->cgrp; cpuctx->cgrp = cgrp;
} else { } else {
list_del(cpuctx_entry); list_del(cpuctx_entry);
cpuctx->cgrp = NULL; cpuctx->cgrp = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment