[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250904220219.GS3245006@noisy.programming.kicks-ass.net>
Date: Fri, 5 Sep 2025 00:02:19 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Tejun Heo <tj@...nel.org>
Cc: Andrea Righi <arighi@...dia.com>, Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>,
Joel Fernandes <joelagnelf@...dia.com>,
David Vernet <void@...ifault.com>,
Changwoo Min <changwoo@...lia.com>, Shuah Khan <shuah@...nel.org>,
sched-ext@...ts.linux.dev, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
Luigi De Matteis <ldematteis123@...il.com>
Subject: Re: [PATCH 07/16] sched_ext: Add a DL server for sched_ext tasks
On Thu, Sep 04, 2025 at 11:43:27AM -1000, Tejun Heo wrote:
> Hello, Peter.
>
> On Thu, Sep 04, 2025 at 10:28:58PM +0200, Peter Zijlstra wrote:
> ...
> > RUNNABLE:
> > 1) hold both source and target rq->lock.
> ...
> > Now, assuming you have a locking order like:
> >
> > p->pi_lock
> > rq->lock
> > dsq->lock
> >
> > When you do something like:
> >
> > __schedule()
> > raw_spin_lock(rq->lock);
> > next = pick_next_task() -> pick_task_scx()
> > raw_spin_lock(dsq->lock);
> >
> > Then you are, in effect, in the RUNNABLE 1) case above. You hold both
> > locks. Nothing is going to move your task around while you hold that
> > dsq->lock. That task is on the dsq, anybody else wanting to also do
> > anything with that task, will have to first take dsq->lock.
> >
> > Therefore, at this point, it is perfectly fine to do:
> >
> > set_task_cpu(cpu_of(rq)); // move task here
> >
> > There is no actual concurrency. The only thing there is is
> > set_task_cpu() complaining you're not following the rules -- but you
> > are, it just doesn't know -- and we can fix that.
>
> I can't convince myself this is safe. For example, when task_rq_lock()
> returns, it should guarantee that the rq that the task is currently
> associated with is locked and the task can't go anywhere. However, as
> task_rq_lock() isn't interlocked with dsq lock, this won't hold true. I
> think this will break multiple things subtly - e.g. the assumptions that
> task_call_func() makes in the comment wouldn't hold anymore,
> task_sched_runtime()'s test of task_on_rq_queued() would be racy, and so on.
>
> ie. Operations protected by deq/enq pair would be fine but anything which is
> protected only by task_rq_lock/unlock() would become racy, right?
Yeah, let me go audit all that in the morning. Because it would save a
lot of pain if we can make this work.
Powered by blists - more mailing lists