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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aUmK-moSOtQdD2VJ@gpd4>
Date: Mon, 22 Dec 2025 19:16:26 +0100
From: Andrea Righi <arighi@...dia.com>
To: Zqiang <qiang.zhang@...ux.dev>
Cc: tj@...nel.org, void@...ifault.com, changwoo@...lia.com,
	sched-ext@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched_ext: Use the resched_cpu() to replace
 resched_curr() in the bypass_lb_node()

On Mon, Dec 22, 2025 at 07:53:17PM +0800, Zqiang wrote:
> For the PREEMPT_RT kernels, the scx_bypass_lb_timerfn() running in the
> preemptible per-CPU ktimer kthread context, this means that the following
> scenarios will occur(for x86 platform):
> 
>        cpu1                          cpu2
> 				 ktimer kthread:
>                                  ->scx_bypass_lb_timerfn
>                                    ->bypass_lb_node
>                                      ->for_each_cpu(cpu, resched_mask)
> 
>     migration/1:                       by preempt by migration/2:
>     multi_cpu_stop()                     multi_cpu_stop()
>     ->take_cpu_down()
>       ->__cpu_disable()
> 	->set cpu1 offline
> 
>                                        ->rq1 = cpu_rq(cpu1)
>                                        ->resched_curr(rq1)
>                                          ->smp_send_reschedule(cpu1)
> 					   ->native_smp_send_reschedule(cpu1)
> 					     ->if(unlikely(cpu_is_offline(cpu))) {
>                 					WARN(1, "sched: Unexpected
> 							reschedule of offline CPU#%d!\n", cpu);
>                 					return;
>         					}
> 
> This commit therefore use the resched_cpu() to replace resched_curr()
> in the bypass_lb_node() to avoid send-ipi to offline CPUs.
> 
> Signed-off-by: Zqiang <qiang.zhang@...ux.dev>

Good catch, resched_cpu() checks for online CPUs, so makes sense to me.

Reviewed-by: Andrea Righi <arighi@...dia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 5ebf8a740847..8f6d8d7f895c 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3956,13 +3956,8 @@ static void bypass_lb_node(struct scx_sched *sch, int node)
>  					     nr_donor_target, nr_target);
>  	}
>  
> -	for_each_cpu(cpu, resched_mask) {
> -		struct rq *rq = cpu_rq(cpu);
> -
> -		raw_spin_rq_lock_irq(rq);
> -		resched_curr(rq);
> -		raw_spin_rq_unlock_irq(rq);
> -	}
> +	for_each_cpu(cpu, resched_mask)
> +		resched_cpu(cpu);
>  
>  	for_each_cpu_and(cpu, cpu_online_mask, node_mask) {
>  		u32 nr = READ_ONCE(cpu_rq(cpu)->scx.bypass_dsq.nr);
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ