Skip to content

Commit 22ca7ee

Browse files
committed
x86/apic: Provide and use helper for send_IPI_allbutself()
To support IPI shorthands wrap invocations of apic->send_IPI_allbutself() in a helper function, so the static key controlling the shorthand mode is only in one place. Fixup all callers. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6a1cb5f commit 22ca7ee

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

arch/x86/include/asm/apic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ extern void lapic_online(void);
177177
extern void lapic_offline(void);
178178
extern bool apic_needs_pit(void);
179179

180+
extern void apic_send_IPI_allbutself(unsigned int vector);
181+
180182
#else /* !CONFIG_X86_LOCAL_APIC */
181183
static inline void lapic_shutdown(void) { }
182184
#define local_apic_timer_c2_ok 1

arch/x86/kernel/apic/ipi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ void apic_smt_update(void)
5050
static_branch_enable(&apic_use_ipi_shorthand);
5151
}
5252
}
53+
54+
void apic_send_IPI_allbutself(unsigned int vector)
55+
{
56+
if (num_online_cpus() < 2)
57+
return;
58+
59+
if (static_branch_likely(&apic_use_ipi_shorthand))
60+
apic->send_IPI_allbutself(vector);
61+
else
62+
apic->send_IPI_mask_allbutself(cpu_online_mask, vector);
63+
}
64+
5365
#endif /* CONFIG_SMP */
5466

5567
static inline int __prepare_ICR2(unsigned int mask)

arch/x86/kernel/kgdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
416416
*/
417417
void kgdb_roundup_cpus(void)
418418
{
419-
apic->send_IPI_allbutself(NMI_VECTOR);
419+
apic_send_IPI_allbutself(NMI_VECTOR);
420420
}
421421
#endif
422422

arch/x86/kernel/reboot.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,6 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
828828
return NMI_HANDLED;
829829
}
830830

831-
static void smp_send_nmi_allbutself(void)
832-
{
833-
apic->send_IPI_allbutself(NMI_VECTOR);
834-
}
835-
836831
/*
837832
* Halt all other CPUs, calling the specified function on each of them
838833
*
@@ -861,7 +856,7 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
861856
*/
862857
wmb();
863858

864-
smp_send_nmi_allbutself();
859+
apic_send_IPI_allbutself(NMI_VECTOR);
865860

866861
/* Kick CPUs looping in NMI context. */
867862
WRITE_ONCE(crash_ipi_issued, 1);

arch/x86/kernel/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static void native_stop_other_cpus(int wait)
215215
/* sync above data before sending IRQ */
216216
wmb();
217217

218-
apic->send_IPI_allbutself(REBOOT_VECTOR);
218+
apic_send_IPI_allbutself(REBOOT_VECTOR);
219219

220220
/*
221221
* Don't wait longer than a second for IPI completion. The
@@ -241,7 +241,7 @@ static void native_stop_other_cpus(int wait)
241241

242242
pr_emerg("Shutting down cpus with NMI\n");
243243

244-
apic->send_IPI_allbutself(NMI_VECTOR);
244+
apic_send_IPI_allbutself(NMI_VECTOR);
245245
}
246246
/*
247247
* Don't wait longer than 10 ms if the caller didn't

0 commit comments

Comments
 (0)