Skip to content
Commit 5f4e5ce6 authored by Song Liu's avatar Song Liu Committed by Peter Zijlstra
Browse files

perf: Fix list corruption in perf_cgroup_switch()

There's list corruption on cgrp_cpuctx_list. This happens on the
following path:

  perf_cgroup_switch: list_for_each_entry(cgrp_cpuctx_list)
      cpu_ctx_sched_in
         ctx_sched_in
            ctx_pinned_sched_in
              merge_sched_in
                  perf_cgroup_event_disable: remove the event from the list

Use list_for_each_entry_safe() to allow removing an entry during
iteration.

Fixes: 058fe1c0

 ("perf/core: Make cgroup switch visit only cpuctxs with cgroup events")
Signed-off-by: default avatarSong Liu <song@kernel.org>
Reviewed-by: default avatarRik van Riel <riel@surriel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220204004057.2961252-1-song@kernel.org
parent 1d909345
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment