Skip to content

Commit 7b4c5a3

Browse files
Luo GengkunPeter Zijlstra
authored andcommitted
perf/core: Fix the WARN_ON_ONCE is out of lock protected region
commit 3172fb9 ("perf/core: Fix WARN in perf_cgroup_switch()") try to fix a concurrency problem between perf_cgroup_switch and perf_cgroup_event_disable. But it does not to move the WARN_ON_ONCE into lock-protected region, so the warning is still be triggered. Fixes: 3172fb9 ("perf/core: Fix WARN in perf_cgroup_switch()") Signed-off-by: Luo Gengkun <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d0b3b7b commit 7b4c5a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,6 @@ static void perf_cgroup_switch(struct task_struct *task)
951951
if (READ_ONCE(cpuctx->cgrp) == NULL)
952952
return;
953953

954-
WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0);
955-
956954
cgrp = perf_cgroup_from_task(task, NULL);
957955
if (READ_ONCE(cpuctx->cgrp) == cgrp)
958956
return;
@@ -964,6 +962,8 @@ static void perf_cgroup_switch(struct task_struct *task)
964962
if (READ_ONCE(cpuctx->cgrp) == NULL)
965963
return;
966964

965+
WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0);
966+
967967
perf_ctx_disable(&cpuctx->ctx, true);
968968

969969
ctx_sched_out(&cpuctx->ctx, NULL, EVENT_ALL|EVENT_CGROUP);

0 commit comments

Comments
 (0)