Messages in this thread Patch in this message | | | From | Chengming Zhou <> | Subject | [PATCH v2 4/6] perf/core: Use stable cpuctx->cgrp when update perf cgroup time | Date | Tue, 22 Mar 2022 20:08:32 +0800 |
| |
The current code use the changeable task->cgroups when update the perf cgroup time, which maybe not the active perf_cgroup that sched_in on the CPU.
This patch change to use the stable cpuctx->cgrp and only update time when event is matched with cpuctx->cgrp.
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> --- kernel/events/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c index e27c06628bad..849a81299906 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -780,7 +780,6 @@ static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx, static inline void update_cgrp_time_from_event(struct perf_event *event) { struct perf_cgroup_info *info; - struct perf_cgroup *cgrp; /* * ensure we access cgroup data only when needed and @@ -789,11 +788,10 @@ static inline void update_cgrp_time_from_event(struct perf_event *event) if (!is_cgroup_event(event)) return; - cgrp = perf_cgroup_from_task(current, event->ctx); /* - * Do not update time when cgroup is not active + * Only update time when event is matched with cpuctx cgrp */ - if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) { + if (perf_cgroup_match(event)) { info = this_cpu_ptr(event->cgrp->info); __update_cgrp_time(info, perf_clock(), true); } -- 2.20.1
| |