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-next>] [day] [month] [year] [list]
Message-ID: <20251008165746.144503-1-yury.norov@gmail.com>
Date: Wed,  8 Oct 2025 12:57:45 -0400
From: "Yury Norov (NVIDIA)" <yury.norov@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>,
	"Paul E. McKenney" <paulmck@...nel.org>,
	Rik van Riel <riel@...riel.com>,
	"Yury Norov (NVIDIA)" <yury.norov@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	Joel Fernandes <joelagnelf@...dia.com>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Roman Kisel <romank@...ux.microsoft.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] smp: simplify smp_call_function_any()

The functions calls get_cpu()/put_cpu() meaningless because the actual
CPU that would execute the caller's function is not necessarily the
current one.

The smp_call_function_single() which is called by
smp_call_function_any() does the right get/put protection.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@...il.com>
---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index 02f52291fae4..fa50ed459703 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -754,17 +754,13 @@ EXPORT_SYMBOL_GPL(smp_call_function_single_async);
 int smp_call_function_any(const struct cpumask *mask,
 			  smp_call_func_t func, void *info, int wait)
 {
-	unsigned int cpu;
-	int ret;
+	unsigned int cpu = smp_processor_id();
 
 	/* Try for same CPU (cheapest) */
-	cpu = get_cpu();
 	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);
-	put_cpu();
-	return ret;
+	return smp_call_function_single(cpu, func, info, wait);
 }
 EXPORT_SYMBOL_GPL(smp_call_function_any);
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ