Skip to content

Commit 6875186

Browse files
Chengming ZhouPeter Zijlstra
authored andcommitted
perf/core: Use perf_cgroup_info->active to check if cgroup is active
Since we use perf_cgroup_set_timestamp() to start cgroup time and set active to 1, then use update_cgrp_time_from_cpuctx() to stop cgroup time and set active to 0. We can use info->active directly to check if cgroup is active. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220329154523.86438-3-zhouchengming@bytedance.com
1 parent a082771 commit 6875186

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

kernel/events/core.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx,
780780
static inline void update_cgrp_time_from_event(struct perf_event *event)
781781
{
782782
struct perf_cgroup_info *info;
783-
struct perf_cgroup *cgrp;
784783

785784
/*
786785
* ensure we access cgroup data only when needed and
@@ -789,14 +788,12 @@ static inline void update_cgrp_time_from_event(struct perf_event *event)
789788
if (!is_cgroup_event(event))
790789
return;
791790

792-
cgrp = perf_cgroup_from_task(current, event->ctx);
791+
info = this_cpu_ptr(event->cgrp->info);
793792
/*
794793
* Do not update time when cgroup is not active
795794
*/
796-
if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) {
797-
info = this_cpu_ptr(event->cgrp->info);
795+
if (info->active)
798796
__update_cgrp_time(info, perf_clock(), true);
799-
}
800797
}
801798

802799
static inline void

0 commit comments

Comments
 (0)