]> git.karo-electronics.de Git - linux-beck.git/blobdiff - kernel/events/core.c
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-beck.git] / kernel / events / core.c
index 8097df340eedb25f85fe574f172b56f1ad4b29e6..3820e3cefbaea869541fcdabadb909174f83a42f 100644 (file)
@@ -266,7 +266,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)
@@ -4623,6 +4638,7 @@ void perf_event_comm(struct task_struct *task)
        struct perf_event_context *ctx;
        int ctxn;
 
+       rcu_read_lock();
        for_each_task_context_nr(ctxn) {
                ctx = task->perf_event_ctxp[ctxn];
                if (!ctx)
@@ -4630,6 +4646,7 @@ void perf_event_comm(struct task_struct *task)
 
                perf_event_enable_on_exec(ctx);
        }
+       rcu_read_unlock();
 
        if (!atomic_read(&nr_comm_events))
                return;
@@ -7545,12 +7562,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 */