From: "Yury Norov (NVIDIA)" <yury.norov@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@kernel.org>,
Rik van Riel <riel@surriel.com>,
"Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Roman Kisel <romank@linux.microsoft.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] smp: simplify smp_call_function_any()
Date: Wed, 8 Oct 2025 12:57:45 -0400 [thread overview]
Message-ID: <20251008165746.144503-1-yury.norov@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2025-10-08 16:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 16:57 Yury Norov (NVIDIA) [this message]
2025-10-08 17:06 ` Mathieu Desnoyers
2025-10-09 14:58 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251008165746.144503-1-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=riel@surriel.com \
--cc=romank@linux.microsoft.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®