Skip to contentSkip to conversation

x86/apic: Inline __x2apic_send_IPI_dest()

PATCH Applied Eric Dumazet 2 participants 3 messages Dec 23, 2025 – Jan 26 x86

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/apic: Inline __x2apic_send_IPI_dest()

Avoid one call/ret in networking RPS/RFS fast path, with no space cost.

scripts/bloat-o-meter -t vmlinux.before vmlinux.after add/remove: 0/2 grow/shrink: 2/0 up/down: 96/-97 (-1)

Function                                     old     new   delta
x2apic_send_IPI                              146     198     +52
__x2apic_send_IPI_mask                       326     370     +44
__pfx___x2apic_send_IPI_dest                  16       -     -16
__x2apic_send_IPI_dest                        81       -     -81

Total: Before=20861234, After=20861233, chg -0.00%

---
v2: added CONFIG_X86_X2APIC dependency (kernel test robot), updated bloat-o-meter
v1: https://lore.kernel.org/lkml/CANn89iJ4r5hrqE=Lj16XVNFM7iZ+XB+JsXU8gE5ryeuG6kf1Sg@mail.gmail.com/T/#mc7288459ec504831a9888cb0e5c4dbdae253f263

 arch/x86/kernel/apic/local.h       | 10 +++++++++-
 arch/x86/kernel/apic/x2apic_phys.c |  6 ------
 2 files changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/apic/local.h +9 -1
index bdcf609eb283..0e5dd6772d6a 100644
@@ -14,7 +14,6 @@
 #include <asm/apic.h>
 
 /* X2APIC */
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest);
 u32 x2apic_get_apic_id(u32 id);
 
 void x2apic_send_IPI_all(int vector);
@@ -42,6 +41,15 @@ static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
 	return icr;
 }
 
+#ifdef CONFIG_X86_X2APIC
+static inline void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
+					  unsigned int dest)
+{
+	unsigned long cfg = __prepare_ICR(0, vector, dest);
+	native_x2apic_icr_write(cfg, apicid);
+}
+#endif
+
 void default_init_apic_ldr(void);
 
 void apic_mem_wait_icr_idle(void);
arch/x86/kernel/apic/x2apic_phys.c +0 -6
index 12d4c35547a6..10f79026e8e3 100644
@@ -107,12 +107,6 @@ void x2apic_send_IPI_self(int vector)
 	apic_write(APIC_SELF_IPI, vector);
 }
 
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
-{
-	unsigned long cfg = __prepare_ICR(0, vector, dest);
-	native_x2apic_icr_write(cfg, apicid);
-}
-
 static int x2apic_phys_probe(void)
 {
 	if (!x2apic_mode)
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
#1 lore raw
Quoted 67 lines · Eric Dumazet

Avoid one call/ret in networking RPS/RFS fast path, with no space cost.

scripts/bloat-o-meter -t vmlinux.before vmlinux.after add/remove: 0/2 grow/shrink: 2/0 up/down: 96/-97 (-1)

Function                                     old     new   delta
x2apic_send_IPI                              146     198     +52
__x2apic_send_IPI_mask                       326     370     +44
__pfx___x2apic_send_IPI_dest                  16       -     -16
__x2apic_send_IPI_dest                        81       -     -81

Total: Before=20861234, After=20861233, chg -0.00%

---
v2: added CONFIG_X86_X2APIC dependency (kernel test robot), updated bloat-o-meter
v1: https://lore.kernel.org/lkml/CANn89iJ4r5hrqE=Lj16XVNFM7iZ+XB+JsXU8gE5ryeuG6kf1Sg@mail.gmail.com/T/#mc7288459ec504831a9888cb0e5c4dbdae253f263

 arch/x86/kernel/apic/local.h       | 10 +++++++++-
 arch/x86/kernel/apic/x2apic_phys.c |  6 ------
 2 files changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/apic/local.h +9 -1
index bdcf609eb283..0e5dd6772d6a 100644
@@ -14,7 +14,6 @@
 #include <asm/apic.h>
 
 /* X2APIC */
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest);
 u32 x2apic_get_apic_id(u32 id);
 
 void x2apic_send_IPI_all(int vector);
@@ -42,6 +41,15 @@ static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
        return icr;
 }
 
+#ifdef CONFIG_X86_X2APIC
+static inline void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
+                                         unsigned int dest)
+{
+       unsigned long cfg = __prepare_ICR(0, vector, dest);
+       native_x2apic_icr_write(cfg, apicid);
+}
+#endif
+
 void default_init_apic_ldr(void);
 
 void apic_mem_wait_icr_idle(void);
arch/x86/kernel/apic/x2apic_phys.c +0 -7
index 12d4c35547a6..10f79026e8e3 100644
@@ -107,12 +107,6 @@ void x2apic_send_IPI_self(int vector)
        apic_write(APIC_SELF_IPI, vector);
 }
 
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
-{
-       unsigned long cfg = __prepare_ICR(0, vector, dest);
-       native_x2apic_icr_write(cfg, apicid);
-}
-
 static int x2apic_phys_probe(void)
 {
        if (!x2apic_mode)
--
Quoted 2 lines

2.52.0.351.gbe84eed79e-goog

I do not think I received any feedback for this patch, should I resend it ?

Thanks.

merge bot Applied
#2 lore raw
In reply to Eric Dumazet
The following commit has been merged into the x86/apic branch of tip:

The following commit has been merged into the x86/apic branch of tip:

Commit-ID:     9bad74127f0ae8eeed2510fe381b064e08e6507e
Gitweb:        https://git.kernel.org/tip/9bad74127f0ae8eeed2510fe381b064e08e6507e
Author:        Eric Dumazet <[email protected]>
AuthorDate:    Tue, 23 Dec 2025 05:20:26 
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 26 Jan 2026 16:25:18 +01:00

x86/apic: Inline __x2apic_send_IPI_dest()

Avoid one call/ret in networking RPS/RFS fast path, with no space cost.

scripts/bloat-o-meter -t vmlinux.before vmlinux.after add/remove: 0/2 grow/shrink: 2/0 up/down: 96/-97 (-1)

Function                                     old     new   delta
x2apic_send_IPI                              146     198     +52
__x2apic_send_IPI_mask                       326     370     +44
__pfx___x2apic_send_IPI_dest                  16       -     -16
__x2apic_send_IPI_dest                        81       -     -81

Total: Before=20861234, After=20861233, chg -0.00%

---
 arch/x86/kernel/apic/local.h       | 10 +++++++++-
 arch/x86/kernel/apic/x2apic_phys.c |  6 ------
 2 files changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/apic/local.h +9 -1
index bdcf609..998efd4 100644
@@ -14,7 +14,6 @@
 #include <asm/apic.h>
 
 /* X2APIC */
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest);
 u32 x2apic_get_apic_id(u32 id);
 
 void x2apic_send_IPI_all(int vector);
@@ -42,6 +41,15 @@ static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
 	return icr;
 }
 
+#ifdef CONFIG_X86_X2APIC
+static inline void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
+{
+	unsigned long cfg = __prepare_ICR(0, vector, dest);
+
+	native_x2apic_icr_write(cfg, apicid);
+}
+#endif
+
 void default_init_apic_ldr(void);
 
 void apic_mem_wait_icr_idle(void);
arch/x86/kernel/apic/x2apic_phys.c +0 -6
index 12d4c35..10f7902 100644
@@ -107,12 +107,6 @@ void x2apic_send_IPI_self(int vector)
 	apic_write(APIC_SELF_IPI, vector);
 }
 
-void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
-{
-	unsigned long cfg = __prepare_ICR(0, vector, dest);
-	native_x2apic_icr_write(cfg, apicid);
-}
-
 static int x2apic_phys_probe(void)
 {
 	if (!x2apic_mode)