Commit 6875186a authored by Chengming Zhou's avatar Chengming Zhou Committed by Peter Zijlstra
Browse files

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: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220329154523.86438-3-zhouchengming@bytedance.com
parent a0827713
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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,15 +788,13 @@ 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);
	info = this_cpu_ptr(event->cgrp->info);
	/*
	 * Do not update time when cgroup is not active
	 */
	if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) {
		info = this_cpu_ptr(event->cgrp->info);
	if (info->active)
		__update_cgrp_time(info, perf_clock(), true);
}
}

static inline void
perf_cgroup_set_timestamp(struct perf_cpu_context *cpuctx)