lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLoH_5TfiTGgQsb0@slm.duckdns.org>
Date: Thu, 4 Sep 2025 11:43:27 -1000
From: Tejun Heo <tj@...nel.org>
To: Peter Zijlstra <peterz@...radead.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

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?

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ