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: <aDpQjDsPGkwf3qRs@slm.duckdns.org>
Date: Fri, 30 May 2025 14:42:52 -1000
From: Tejun Heo <tj@...nel.org>
To: Andrea Righi <arighi@...dia.com>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched_ext: idle: Properly handle invalid prev_cpu during
 idle selection

On Fri, May 30, 2025 at 05:46:29PM +0200, Andrea Righi wrote:
> The default idle selection policy doesn't properly handle the case where
> @prev_cpu is not part of the task's allowed CPUs.
> 
> In this situation, it may return an idle CPU that is not usable by the
> task, breaking the assumption that the returned CPU must always be
> within the allowed cpumask, causing inefficiencies or even stalls in
> certain cases.
> 
> This issue can arise in the following cases:
> 
>  - The task's affinity may have changed by the time the function is
>    invoked, especially now that the idle selection logic can be used
>    from multiple contexts (i.e., BPF test_run call).
> 
>  - The BPF scheduler may provide a @prev_cpu that is not part of the
>    allowed mask, either unintentionally or as a placement hint. In fact
>    @prev_cpu may not necessarily refer to the CPU the task last ran on,
>    but it can also be considered as a target CPU that the scheduler
>    wishes to use for the task.
> 
> Therefore, enforce the right behavior by always checking whether
> @prev_cpu is in the allowed mask, when using scx_bpf_select_cpu_and(),
> and it's also usable by the task (@p->cpus_ptr). If it is not, try to
> find a valid CPU nearby @prev_cpu, following the usual locality-aware
> fallback path (SMT, LLC, node, allowed CPUs).
> 
> This ensures the returned CPU is always allowed, improving robustness to
> affinity changes and invalid scheduler hints, while preserving locality
> as much as possible.
> 
> Fixes: a730e3f7a48bc ("sched_ext: idle: Consolidate default idle CPU selection kfuncs")
> Signed-off-by: Andrea Righi <arighi@...dia.com>

Applied to sched_ext/for-6.16-fixes.

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ