mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cgroup, perf_event: Fix perf cgroup hierarchy support
@ 2017-10-28 16:49 Tejun Heo
  2017-10-30 10:20 ` Peter Zijlstra
  2017-10-30 11:26 ` [tip:perf/urgent] perf/cgroup: " tip-bot for Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2017-10-28 16:49 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: linux-kernel, David Carrillo-Cisneros, kernel-team

864c2357ca89 ("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: Tejun Heo <tj@kernel.org>
Fixes: 864c2357ca89 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups")
Cc: stable@vger.kernel.org # v4.9+
Cc: David Carrillo-Cisneros <davidcc@google.com>
---
 kernel/events/core.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9d93db8..db2e630 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -901,9 +901,12 @@ list_update_cgroup_event(struct perf_event *event,
 	cpuctx_entry = &cpuctx->cgrp_cpuctx_entry;
 	/* cpuctx->cgrp is NULL unless a cgroup event is active in this CPU .*/
 	if (add) {
+		struct perf_cgroup *cgrp = perf_cgroup_from_task(current, ctx);
+
 		list_add(cpuctx_entry, this_cpu_ptr(&cgrp_cpuctx_list));
-		if (perf_cgroup_from_task(current, ctx) == event->cgrp)
-			cpuctx->cgrp = event->cgrp;
+		if (cgroup_is_descendant(cgrp->css.cgroup,
+					 event->cgrp->css.cgroup))
+			cpuctx->cgrp = cgrp;
 	} else {
 		list_del(cpuctx_entry);
 		cpuctx->cgrp = NULL;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-30 11:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28 16:49 [PATCH] cgroup, perf_event: Fix perf cgroup hierarchy support Tejun Heo
2017-10-30 10:20 ` Peter Zijlstra
2017-10-30 11:26 ` [tip:perf/urgent] perf/cgroup: " tip-bot for Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome