[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLg4SsZHY66n3Vi2@gpd4>
Date: Wed, 3 Sep 2025 14:44:58 +0200
From: Andrea Righi <arighi@...dia.com>
To: Tejun Heo <tj@...nel.org>
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
Hi Tejun,
On Tue, Sep 02, 2025 at 01:39:34PM -1000, Tejun Heo wrote:
> SCX hooks into CPU cgroup controller operations and read-locks
> scx_cgroup_rwsem to exclude them while enabling and disable schedulers.
> While this works, it's unnecessarily complicated given that
> cgroup_[un]lock() are available and thus the cgroup operations can be locked
> out that way.
>
> Drop scx_cgroup_rwsem locking from the tg on/offline and cgroup [can_]attach
> operations. Instead, grab cgroup_lock() from scx_cgroup_lock(). Drop
> scx_cgroup_finish_attach() which is no longer necessary. Drop the now
> unnecessary rcu locking and css ref bumping in scx_cgroup_init() and
> scx_cgroup_exit().
>
> As scx_cgroup_set_weight/bandwidth() paths aren't protected by
> cgroup_lock(), rename scx_cgroup_rwsem to scx_cgroup_ops_rwsem and retain
> the locking there.
>
> This is overall simpler and will also allow enable/disable paths to
> synchronize against cgroup changes independent of the CPU controller.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Cc: Peter Zijlstra <peterz@...radead.org>
> ---
...
>
> 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?
>
> static void scx_cgroup_unlock(void)
> {
> - percpu_up_write(&scx_cgroup_rwsem);
> + cgroup_unlock();
> + percpu_up_write(&scx_cgroup_ops_rwsem);
> }
Thanks,
-Andrea
Powered by blists - more mailing lists