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] [day] [month] [year] [list]
Message-ID: <aAk52qs21rCXpZlF@slm.duckdns.org>
Date: Wed, 23 Apr 2025 09:04:58 -1000
From: Tejun Heo <tj@...nel.org>
To: Andrea Righi <arighi@...dia.com>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
	Jake Hillion <jake@...lion.co.uk>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched_ext: Clarify CPU context for running/stopping
 callbacks

On Wed, Apr 23, 2025 at 09:00:59PM +0200, Andrea Righi wrote:
> The ops.running() and ops.stopping() callbacks can be invoked from a CPU
> other than the one the task is assigned to, particularly during affinity
> changes, as both scx_next_task_scx() and dequeue_task_scx() may run on
> CPUs different from the task's target CPU.
> 
> This behavior can lead to confusion or incorrect assumptions if not
> properly clarified, potentially resulting in bugs (see [1]).
> 
> Therefore, update the documentation to clarify this aspect and advise
> users to use scx_bpf_task_cpu() to determine the actual CPU the task
> will run on or was running on.
> 
> [1] https://github.com/sched-ext/scx/pull/1728
> 
> Cc: Jake Hillion <jake@...lion.co.uk>
> Cc: Changwoo Min <changwoo@...lia.com>
> Signed-off-by: Andrea Righi <arighi@...dia.com>
> ---
>  kernel/sched/ext.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index a2380a6bba210..f146e678cc261 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -373,6 +373,10 @@ struct sched_ext_ops {
>  	 * @running: A task is starting to run on its associated CPU
>  	 * @p: task starting to run
>  	 *
> +	 * Note that this callback may be called from a CPU other than the
> +	 * one the task is going to run on. Use scx_bpf_task_cpu(@p) to
> +	 * determine the target CPU the task is going to use.

Can you briefly explain the scenario as a part of the comment? Just a couple
sentences can go a long way against future head scratches.

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ