[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLirwysOBpAGubIy@slm.duckdns.org>
Date: Wed, 3 Sep 2025 10:57:39 -1000
From: Tejun Heo <tj@...nel.org>
To: Andrea Righi <arighi@...dia.com>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
sched-ext@...ts.linux.dev, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH sched_ext/for-6.18] sched_ext: Use cgroup_lock/unlock()
to synchronize against cgroup operations
On Wed, Sep 03, 2025 at 10:48:09PM +0200, Andrea Righi wrote:
> On Wed, Sep 03, 2025 at 06:39:46AM -1000, Tejun Heo wrote:
> > Hello,
> >
> > On Wed, Sep 03, 2025 at 02:44:58PM +0200, Andrea Righi wrote:
> > > > static void scx_cgroup_lock(void)
> > > > {
> > > > - percpu_down_write(&scx_cgroup_rwsem);
> > > > + percpu_down_write(&scx_cgroup_ops_rwsem);
> > > > + cgroup_lock();
> > > > }
> > >
> > > Shouldn't we acquire cgroup_lock() before scx_cgroup_ops_rwsem to avoid
> > > a potential AB-BA deadlock?
> >
> > There's no existing ordering between the two locks, so any order should be
> > safe. The reason why I put it in this particular order is because any
> > cgroup_lock() holder has no reason to grab ops_rwsem now or in the future
> > while the opposite direction is still unlikely but theoretically more
> > possible.
>
> Isn't scx_group_set_weight() called with cgroup_mutex held? In this case
> the order is cgroup_lock() -> scx_cgroup_ops_rwsem, or am I missing
> something?
Oh, no, cgroup_lock() is only held for operations that change the cgroup
hierarchy - cgroup creation, deletion, controller enable/disable, task
migration and so on. Writes to control knobs doesn't acquire cgroup_lock().
Thanks.
--
tejun
Powered by blists - more mailing lists