diff options
author | Tejun Heo <tj@kernel.org> | 2013-04-08 22:00:38 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-04-10 14:07:16 -0400 |
commit | ef824fa129b7579f56b92d466ecda2e378879806 (patch) | |
tree | 4a0e244bae94fffd4cc37d5ddaa73edad3fa2882 | |
parent | 78574cf981cd3d9ae9f6adbd466a772310ec24ff (diff) |
perf: make perf_event cgroup hierarchical
perf_event is one of a couple remaining cgroup controllers with broken
hierarchy support. Converting it to support hierarchy is almost
trivial. The only thing necessary is to consider a task belonging to
a descendant cgroup as a match. IOW, if the cgroup of the currently
executing task (@cpuctx->cgrp) equals or is a descendant of the
event's cgroup (@event->cgrp), then the event should be enabled.
Implement hierarchy support and remove .broken_hierarchy tag along
with the incorrect comment on what needs to be done for hierarchy
support.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Stephane Eranian <eranian@google.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
-rw-r--r-- | kernel/events/core.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index b0cd86501c30..310ec19d968a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -251,7 +251,22 @@ perf_cgroup_match(struct perf_event *event) | |||
251 | struct perf_event_context *ctx = event->ctx; | 251 | struct perf_event_context *ctx = event->ctx; |
252 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | 252 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); |
253 | 253 | ||
254 | return !event->cgrp || event->cgrp == cpuctx->cgrp; | 254 | /* @event doesn't care about cgroup */ |
255 | if (!event->cgrp) | ||
256 | return true; | ||
257 | |||
258 | /* wants specific cgroup scope but @cpuctx isn't associated with any */ | ||
259 | if (!cpuctx->cgrp) | ||
260 | return false; | ||
261 | |||
262 | /* | ||
263 | * Cgroup scoping is recursive. An event enabled for a cgroup is | ||
264 | * also enabled for all its descendant cgroups. If @cpuctx's | ||
265 | * cgroup is a descendant of @event's (the test covers identity | ||
266 | * case), it's a match. | ||
267 | */ | ||
268 | return cgroup_is_descendant(cpuctx->cgrp->css.cgroup, | ||
269 | event->cgrp->css.cgroup); | ||
255 | } | 270 | } |
256 | 271 | ||
257 | static inline bool perf_tryget_cgroup(struct perf_event *event) | 272 | static inline bool perf_tryget_cgroup(struct perf_event *event) |
@@ -7509,12 +7524,5 @@ struct cgroup_subsys perf_subsys = { | |||
7509 | .css_free = perf_cgroup_css_free, | 7524 | .css_free = perf_cgroup_css_free, |
7510 | .exit = perf_cgroup_exit, | 7525 | .exit = perf_cgroup_exit, |
7511 | .attach = perf_cgroup_attach, | 7526 | .attach = perf_cgroup_attach, |
7512 | |||
7513 | /* | ||
7514 | * perf_event cgroup doesn't handle nesting correctly. | ||
7515 | * ctx->nr_cgroups adjustments should be propagated through the | ||
7516 | * cgroup hierarchy. Fix it and remove the following. | ||
7517 | */ | ||
7518 | .broken_hierarchy = true, | ||
7519 | }; | 7527 | }; |
7520 | #endif /* CONFIG_CGROUP_PERF */ | 7528 | #endif /* CONFIG_CGROUP_PERF */ |