Re: [PATCH 07/16] sched_ext: Add a DL server for sched_ext tasks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux