From: Eric Dumazet <edumazet@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH 1/3] x86/smp: Use static_call for arch_send_call_function_single_ipi()
Date: Mon, 22 Dec 2025 20:14:04 +0000 [thread overview]
Message-ID: <20251222201406.3725665-2-edumazet@google.com> (raw)
In-Reply-To: <20251222201406.3725665-1-edumazet@google.com>
Use static_call to avoid an indirect call, especially expensive
with retpoline.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
arch/x86/include/asm/smp.h | 10 ++++++++--
arch/x86/kernel/smp.c | 10 ++++++++++
arch/x86/xen/smp_hvm.c | 1 +
arch/x86/xen/smp_pv.c | 1 +
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 84951572ab8170578ca5c4a3437c66e9809f34c2..891a5d16bcd52d2da0b71d928d3728afe3d15ade 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -4,6 +4,7 @@
#ifndef __ASSEMBLER__
#include <linux/cpumask.h>
#include <linux/thread_info.h>
+#include <linux/static_call_types.h>
#include <asm/cpumask.h>
@@ -42,6 +43,12 @@ struct smp_ops {
void (*send_call_func_single_ipi)(int cpu);
};
+void x86_smp_ops_static_call_update(void);
+
+void native_send_call_func_single_ipi(int cpu);
+DECLARE_STATIC_CALL(x86_send_call_func_single_ipi,
+ native_send_call_func_single_ipi);
+
/* Globals due to paravirt */
extern void set_cpu_sibling_map(int cpu);
@@ -92,7 +99,7 @@ static inline void arch_smp_send_reschedule(int cpu)
static inline void arch_send_call_function_single_ipi(int cpu)
{
- smp_ops.send_call_func_single_ipi(cpu);
+ static_call(x86_send_call_func_single_ipi)(cpu);
}
static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
@@ -122,7 +129,6 @@ void __noreturn mwait_play_dead(unsigned int eax_hint);
void native_smp_send_reschedule(int cpu);
void native_send_call_func_ipi(const struct cpumask *mask);
-void native_send_call_func_single_ipi(int cpu);
asmlinkage __visible void smp_reboot_interrupt(void);
__visible void smp_reschedule_interrupt(struct pt_regs *regs);
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index b014e6d229f9519add6f3fb315f1a2f375675a50..2c8fdf1f59d953e49a6beeba8f76f5fe62bd5db7 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -300,6 +300,16 @@ struct smp_ops smp_ops = {
};
EXPORT_SYMBOL_GPL(smp_ops);
+DEFINE_STATIC_CALL(x86_send_call_func_single_ipi,
+ native_send_call_func_single_ipi);
+
+void x86_smp_ops_static_call_update(void)
+{
+ static_call_update(x86_send_call_func_single_ipi,
+ smp_ops.send_call_func_single_ipi);
+}
+EXPORT_SYMBOL_GPL(x86_smp_ops_static_call_update);
+
int arch_cpu_rescan_dead_smt_siblings(void)
{
enum cpuhp_smt_control old = cpu_smt_control;
diff --git a/arch/x86/xen/smp_hvm.c b/arch/x86/xen/smp_hvm.c
index 485c1d8804f739fbbb7980c98ed56eab59ad8b37..5ea0f53e4ea3f6cd4ad24fedbe2ef28d2dc444b9 100644
--- a/arch/x86/xen/smp_hvm.c
+++ b/arch/x86/xen/smp_hvm.c
@@ -85,4 +85,5 @@ void __init xen_hvm_smp_init(void)
smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
+ x86_smp_ops_static_call_update();
}
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 9bb8ff8bff30a6d13a186609e40346203d4feb25..91f9d6854f7448bd1ffcb4e194615ce6336827bb 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -442,6 +442,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
void __init xen_smp_init(void)
{
smp_ops = xen_smp_ops;
+ x86_smp_ops_static_call_update();
/* Avoid searching for BIOS MP tables */
x86_init.mpparse.find_mptable = x86_init_noop;
--
2.52.0.351.gbe84eed79e-goog
next prev parent reply other threads:[~2025-12-22 20:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 20:14 [PATCH 0/3] x86: Use static_call for three smp_ops methods Eric Dumazet
2025-12-22 20:14 ` Eric Dumazet [this message]
2026-01-16 21:22 ` [tip: x86/core] x86/smp: Use static_call for arch_send_call_function_single_ipi() tip-bot2 for Eric Dumazet
2025-12-22 20:14 ` [PATCH 2/3] x86/smp: Use static_call for arch_smp_send_reschedule() Eric Dumazet
2026-01-16 21:22 ` [tip: x86/core] " tip-bot2 for Eric Dumazet
2025-12-22 20:14 ` [PATCH 3/3] x86/smp: Use static_call for arch_send_call_function_ipi() Eric Dumazet
2026-01-16 21:21 ` [tip: x86/core] " tip-bot2 for Eric Dumazet
2026-01-08 11:51 ` [PATCH 0/3] x86: Use static_call for three smp_ops methods Peter Zijlstra
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=20251222201406.3725665-2-edumazet@google.com \
--to=edumazet@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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