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: <9037ef51-441c-4868-932a-8b618382a4d5@arm.com>
Date: Wed, 3 Sep 2025 16:53:01 +0100
From: Christian Loehle <christian.loehle@....com>
To: Thomas Gleixner <tglx@...utronix.de>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
 yury.norov@...il.com
Cc: Rik van Riel <riel@...riel.com>
Subject: Re: [PATCH] smp: Fix smp_call_function_any() if no CPU online

On 8/28/25 23:40, Christian Loehle wrote:
> smp_call_function_any() used to handle a mask without any online
> CPUs just fine, but when switching to use sched_numa_find_nth_cpu()
> a previous check for online CPUs was removed.
> smp_call_function_single() handles invalid CPUs just fine, so
> just add the check back before calling sched_numa_find_nth_cpu().
> 
> An observed issue was when initializing PMUs on HMP if all CPUs
> were offline (e.g. by booting with maxcpus):
> 
> [    1.192642] Call trace:
> [    1.192868]  sched_numa_find_nth_cpu+0xc0/0x170 (P)
> [    1.193323]  smp_call_function_any+0xc8/0xd0
> [    1.193724]  armv8_pmu_init+0x58/0x27c
> [    1.194079]  armv8_cortex_a72_pmu_init+0x20/0x2c
> [    1.194507]  arm_pmu_device_probe+0x1e4/0x5e8
> [    1.194911]  armv8_pmu_device_probe+0x1c/0x28
> [    1.195316]  platform_probe+0x5c/0xac
> [    1.195658]  really_probe+0xbc/0x298
> [    1.195995]  __driver_probe_device+0x78/0x12c
> [    1.196399]  driver_probe_device+0xdc/0x160
> [    1.196787]  __driver_attach+0x94/0x19c
> [    1.197146]  bus_for_each_dev+0x74/0xd4
> [    1.197503]  driver_attach+0x24/0x30
> [    1.197838]  bus_add_driver+0xe4/0x208
> [    1.198187]  driver_register+0x60/0x128
> [    1.198546]  __platform_driver_register+0x24/0x30
> [    1.198974]  armv8_pmu_driver_init+0x28/0x4c
> [    1.199372]  do_one_initcall+0x44/0x25c
> [    1.199729]  kernel_init_freeable+0x1dc/0x3bc
> [    1.200134]  kernel_init+0x20/0x1d8
> [    1.200466]  ret_from_fork+0x10/0x20
> [    1.200809] Code: 4b020264 eb04007f 54000129 51000402 (f860d825)
> [    1.201355] ---[ end trace 0000000000000000 ]---
> 
> Fixes: 5f295519b42f ("smp: Improve locality in smp_call_function_any()")
> Cc: stable@...r.kernel.org
> Signed-off-by: Christian Loehle <christian.loehle@....com>
> ---
>  kernel/smp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/smp.c b/kernel/smp.c
> index 56f83aa58ec8..cbce9699ced6 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -759,7 +759,9 @@ int smp_call_function_any(const struct cpumask *mask,
>  
>  	/* Try for same CPU (cheapest) */
>  	cpu = get_cpu();
> -	if (!cpumask_test_cpu(cpu, mask))
> +	if (!cpumask_intersects(mask, cpu_online_mask))
> +		cpu = nr_cpu_ids;
> +	else if (!cpumask_test_cpu(cpu, mask))
>  		cpu = sched_numa_find_nth_cpu(mask, 0, cpu_to_node(cpu));
>  
>  	ret = smp_call_function_single(cpu, func, info, wait);

Please disregard in favor of
https://lore.kernel.org/lkml/1ae868cf-470b-44d8-bda3-20a64dedd8b8@arm.com/
as sched_numa_find_nth_cpu() should've handled this case.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ