Messages in this thread | | | From | Namhyung Kim <> | Date | Tue, 22 Mar 2022 15:06:39 -0700 | Subject | Re: [External] Re: [PATCH v2 1/6] perf/core: Fix incosistency between cgroup sched_out and sched_in |
| |
Hello,
On Tue, Mar 22, 2022 at 8:28 AM Chengming Zhou <zhouchengming@bytedance.com> wrote: > > On 2022/3/22 11:16 下午, Chengming Zhou wrote: > > Hi peter, > > > > On 2022/3/22 10:54 下午, Peter Zijlstra wrote: > >> On Tue, Mar 22, 2022 at 09:38:21PM +0800, Chengming Zhou wrote: > >>> On 2022/3/22 8:59 下午, Peter Zijlstra wrote: > >>>> On Tue, Mar 22, 2022 at 08:08:29PM +0800, Chengming Zhou wrote: > >>>>> There is a race problem that can trigger WARN_ON_ONCE(cpuctx->cgrp) > >>>>> in perf_cgroup_switch(). > >>>>> > >>>>> CPU1 CPU2 > >>>>> (in context_switch) (attach running task) > >>>>> perf_cgroup_sched_out(prev, next) > >>>>> cgrp1 == cgrp2 is True > >>>>> next->cgroups = cgrp3 > >>>>> perf_cgroup_attach() > >>>>> perf_cgroup_sched_in(prev, next) > >>>>> cgrp1 == cgrp3 is False > > I see, you must have been misled by my wrong drawing above ;-) > I'm sorry, perf_cgroup_attach() on the right should be put at the bottom. > > CPU1 CPU2 > (in context_switch) (attach running task) > perf_cgroup_sched_out(prev, next) > cgrp1 == cgrp2 is True > next->cgroups = cgrp3 > perf_cgroup_sched_in(prev, next) > cgrp1 == cgrp3 is False > __perf_cgroup_move() >
Yep, this is a real race and I saw the warnings reported sometimes. The perf_cgroup_attach() is called after the task's cgroup is changed.
Thanks, Namhyung
| |