mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-6.18] sched_ext: Use cgroup_lock/unlock() to synchronize against cgroup operations
Date: Wed, 3 Sep 2025 23:35:06 +0200	[thread overview]
Message-ID: <aLi0irnOyHFXY7Yy@gpd4> (raw)
In-Reply-To: <aLirwysOBpAGubIy@slm.duckdns.org>

On Wed, Sep 03, 2025 at 10:57:39AM -1000, Tejun Heo wrote:
> 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().

Ah! That's the part I was missing, thanks for clarifying it. In that case:

Acked-by: Andrea Righi <arighi@nvidia.com>

-Andrea

  reply	other threads:[~2025-09-03 21:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 23:39 Tejun Heo
2025-09-03  8:14 ` Peter Zijlstra
2025-09-03 12:44 ` Andrea Righi
2025-09-03 16:39   ` Tejun Heo
2025-09-03 20:48     ` Andrea Righi
2025-09-03 20:57       ` Tejun Heo
2025-09-03 21:35         ` Andrea Righi [this message]
2025-09-03 21:49 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aLi0irnOyHFXY7Yy@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®