[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7chL6r=4Ay6udSv-heyH3pAdH=Cp+2mXU2-+Z7yHt+aH7w@mail.gmail.com>
Date: Tue, 22 Mar 2022 15:06:39 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Chengming Zhou <zhouchengming@...edance.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Stephane Eranian <eranian@...gle.com>,
linux-perf-users <linux-perf-users@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
duanxiongchun@...edance.com, songmuchun@...edance.com
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@...edance.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
Powered by blists - more mailing lists