Skip to contentSkip to conversation

FAILED: patch "[PATCH] perf/cgroup: Fix perf cgroup hierarchy support" failed to apply to 4.9-stable tree

PATCH [email protected] 1 participant 1 message Nov 6, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From be96b316deff35e119760982c43af74e606fa143 Mon Sep 17 00:00:00 2001

From: Tejun Heo <[email protected]>
Date: Sat, 28 Oct 2017 09:49:37 -0700
Subject: [PATCH] perf/cgroup: Fix perf cgroup hierarchy support

The following commit:

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.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc David Carrillo-Cisneros <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 864c2357ca89 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups")
kernel/events/core.c +4 -2
index 9d93db81fa36..10cdb9c26b5d 100644
@@ -901,9 +901,11 @@ 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;