]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/events/core.c
Merge branch 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
[karo-tx-linux.git] / kernel / events / core.c
index 9fcb0944f0718597fab6f6723e70e701be55b075..dce6e13cf9d752a32a3d4c3eb39556de1a2fad31 100644 (file)
@@ -251,7 +251,22 @@ perf_cgroup_match(struct perf_event *event)
        struct perf_event_context *ctx = event->ctx;
        struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
 
-       return !event->cgrp || event->cgrp == cpuctx->cgrp;
+       /* @event doesn't care about cgroup */
+       if (!event->cgrp)
+               return true;
+
+       /* wants specific cgroup scope but @cpuctx isn't associated with any */
+       if (!cpuctx->cgrp)
+               return false;
+
+       /*
+        * Cgroup scoping is recursive.  An event enabled for a cgroup is
+        * also enabled for all its descendant cgroups.  If @cpuctx's
+        * cgroup is a descendant of @event's (the test covers identity
+        * case), it's a match.
+        */
+       return cgroup_is_descendant(cpuctx->cgrp->css.cgroup,
+                                   event->cgrp->css.cgroup);
 }
 
 static inline bool perf_tryget_cgroup(struct perf_event *event)
@@ -7517,12 +7532,5 @@ struct cgroup_subsys perf_subsys = {
        .css_free       = perf_cgroup_css_free,
        .exit           = perf_cgroup_exit,
        .attach         = perf_cgroup_attach,
-
-       /*
-        * perf_event cgroup doesn't handle nesting correctly.
-        * ctx->nr_cgroups adjustments should be propagated through the
-        * cgroup hierarchy.  Fix it and remove the following.
-        */
-       .broken_hierarchy = true,
 };
 #endif /* CONFIG_CGROUP_PERF */