treewide: Trace IPIs sent via smp_send_reschedule()
authorValentin Schneider <vschneid@redhat.com>
Tue, 7 Mar 2023 14:35:56 +0000 (14:35 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 24 Mar 2023 10:01:28 +0000 (11:01 +0100)
To be able to trace invocations of smp_send_reschedule(), rename the
arch-specific definitions of it to arch_smp_send_reschedule() and wrap it
into an smp_send_reschedule() that contains a tracepoint.

Changes to include the declaration of the tracepoint were driven by the
following coccinelle script:

  @func_use@
  @@
  smp_send_reschedule(...);

  @include@
  @@
  #include <trace/events/ipi.h>

  @no_include depends on func_use && !include@
  @@
    #include <...>
  +
  + #include <trace/events/ipi.h>

[csky bits]
[riscv bits]
Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Guo Ren <guoren@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20230307143558.294354-6-vschneid@redhat.com
27 files changed:
arch/alpha/kernel/smp.c
arch/arc/kernel/smp.c
arch/arm/kernel/smp.c
arch/arm/mach-actions/platsmp.c
arch/arm64/kernel/smp.c
arch/csky/kernel/smp.c
arch/hexagon/kernel/smp.c
arch/ia64/kernel/smp.c
arch/loongarch/kernel/smp.c
arch/mips/include/asm/smp.h
arch/mips/kernel/rtlx-cmp.c
arch/openrisc/kernel/smp.c
arch/parisc/kernel/smp.c
arch/powerpc/kernel/smp.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/platforms/powernv/subcore.c
arch/riscv/kernel/smp.c
arch/s390/kernel/smp.c
arch/sh/kernel/smp.c
arch/sparc/kernel/smp_32.c
arch/sparc/kernel/smp_64.c
arch/x86/include/asm/smp.h
arch/x86/kvm/svm/svm.c
arch/x86/kvm/x86.c
arch/xtensa/kernel/smp.c
include/linux/smp.h
virt/kvm/kvm_main.c

index 0ede4b044e869dcf7c635735a1b20abb15b08614..7439b2377df5799e371669faa7cc96229dadca38 100644 (file)
@@ -562,7 +562,7 @@ handle_ipi(struct pt_regs *regs)
 }
 
 void
-smp_send_reschedule(int cpu)
+arch_smp_send_reschedule(int cpu)
 {
 #ifdef DEBUG_IPI_MSG
        if (cpu == hard_smp_processor_id())
index ad93fe6e4b77d3ed3dae87c0a04e02e763755ee3..409cfa4675b40d535b74a31f45707d0bab228ade 100644 (file)
@@ -292,7 +292,7 @@ static void ipi_send_msg(const struct cpumask *callmap, enum ipi_msg_type msg)
                ipi_send_msg_one(cpu, msg);
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        ipi_send_msg_one(cpu, IPI_RESCHEDULE);
 }
index 5edf09237b2f07f10b44c32bcd386bbca389fb0e..b350bfc9d1f8085f040707f9f217c0685f10247f 100644 (file)
@@ -746,7 +746,7 @@ void __init set_smp_ipi_range(int ipi_base, int n)
        ipi_setup(smp_processor_id());
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index f26618b435145d255655b711874e48f9b2851eb0..7b208e96fbb67edc6d1074124fcfc65f55495443 100644 (file)
@@ -20,6 +20,8 @@
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 
+#include <trace/events/ipi.h>
+
 #define OWL_CPU1_ADDR  0x50
 #define OWL_CPU1_FLAG  0x5c
 
index 438c16fc44633ac87e71a829a646876d1946e9b0..66f2745062dda83854ee2c8abd3ff95ce8974aea 100644 (file)
@@ -976,7 +976,7 @@ void __init set_smp_ipi_range(int ipi_base, int n)
        ipi_setup(smp_processor_id());
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index b45d1073307f2b56bab0d0c36272fa4c55293c78..be77383acb5fc0afd82f8945070fbc487eb5a3ae 100644 (file)
@@ -140,7 +140,7 @@ void smp_send_stop(void)
        on_each_cpu(ipi_stop, NULL, 1);
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index 4ba93e59370c4147ea04bc814b40e55c98277683..4e8bee25b8c682257d0abde6e2f0710c68d7e5c0 100644 (file)
@@ -217,7 +217,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
        }
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        send_ipi(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index e2cc59db86bc2dc70314d7739ab47e793abd4d6c..ea4f009a232b4ae0351ab52b4d5a827f87f5fdb8 100644 (file)
@@ -220,11 +220,11 @@ kdump_smp_send_init(void)
  * Called with preemption disabled.
  */
 void
-smp_send_reschedule (int cpu)
+arch_smp_send_reschedule (int cpu)
 {
        ia64_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0);
 }
-EXPORT_SYMBOL_GPL(smp_send_reschedule);
+EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
 
 /*
  * Called with preemption disabled.
index 8c6e227cb29df47b8d143dbf9766229a785813b9..83225610a148074f7e1b43a500ee9aa757dddf31 100644 (file)
@@ -155,11 +155,11 @@ void loongson_send_ipi_mask(const struct cpumask *mask, unsigned int action)
  * it goes straight through and wastes no time serializing
  * anything. Worst case is that we lose a reschedule ...
  */
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        loongson_send_ipi_single(cpu, SMP_RESCHEDULE);
 }
-EXPORT_SYMBOL_GPL(smp_send_reschedule);
+EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
 
 irqreturn_t loongson_ipi_interrupt(int irq, void *dev)
 {
index 5d9ff61004ca7c686184c7f9f380c30cb2194852..9806e79895d99d019e086cef49150fea1bec8513 100644 (file)
@@ -66,7 +66,7 @@ extern void calculate_cpu_foreign_map(void);
  * it goes straight through and wastes no time serializing
  * anything. Worst case is that we lose a reschedule ...
  */
-static inline void smp_send_reschedule(int cpu)
+static inline void arch_smp_send_reschedule(int cpu)
 {
        extern const struct plat_smp_ops *mp_ops;       /* private */
 
index d26dcc4b46e7414e79c866054cd0078cc68409ca..e991cc936c1cd98de63c45eb1e14e6e0e1e0e135 100644 (file)
@@ -17,6 +17,8 @@
 #include <asm/vpe.h>
 #include <asm/rtlx.h>
 
+#include <trace/events/ipi.h>
+
 static int major;
 
 static void rtlx_interrupt(void)
index e1419095a6f0aff4ddbc3bb65cbfd25b3517f5e7..0a7a059e2dff4d67e69fc6fa63d9469a51f53e13 100644 (file)
@@ -173,7 +173,7 @@ void handle_IPI(unsigned int ipi_msg)
        }
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index 7dbd92cafae38a56419fd12ed442b05ad4c4d1eb..b7fc859fa87dbae3270b4dd692e28357d8879595 100644 (file)
@@ -246,8 +246,8 @@ void kgdb_roundup_cpus(void)
 inline void 
 smp_send_stop(void)    { send_IPI_allbutself(IPI_CPU_STOP); }
 
-void 
-smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
+void
+arch_smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
 
 void
 smp_send_all_nop(void)
index 6b90f10a6c819b2cf95accf64950e23ce92cc538..35f101ccb540d95a7a4029f168ca6a0e16c5e74a 100644 (file)
@@ -61,6 +61,8 @@
 #include <asm/kup.h>
 #include <asm/fadump.h>
 
+#include <trace/events/ipi.h>
+
 #ifdef DEBUG
 #include <asm/udbg.h>
 #define DBG(fmt...) udbg_printf(fmt)
@@ -364,12 +366,12 @@ static inline void do_message_pass(int cpu, int msg)
 #endif
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        if (likely(smp_ops))
                do_message_pass(cpu, PPC_MSG_RESCHEDULE);
 }
-EXPORT_SYMBOL_GPL(smp_send_reschedule);
+EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
 
 void arch_send_call_function_single_ipi(int cpu)
 {
index 6ba68dd6190bd30a4ab31c417df2e909077d62a5..3b70b5f80bd563d3fec244c35a5bbaa27c993dd0 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/compiler.h>
 #include <linux/of.h>
 #include <linux/irqdomain.h>
+#include <linux/smp.h>
 
 #include <asm/ftrace.h>
 #include <asm/reg.h>
@@ -80,6 +81,8 @@
 #include <asm/dtl.h>
 #include <asm/plpar_wrappers.h>
 
+#include <trace/events/ipi.h>
+
 #include "book3s.h"
 #include "book3s_hv.h"
 
index 7e98b00ea2e843939da0a1b97fa18b749622d984..c53c4c79776801aebddc3ea1a87234f4cbb6fd9f 100644 (file)
@@ -20,6 +20,8 @@
 #include <asm/opal.h>
 #include <asm/smp.h>
 
+#include <trace/events/ipi.h>
+
 #include "subcore.h"
 #include "powernv.h"
 
index 8c3b59f1f9b802947a39099cf94fb12702e64229..42e9656a1db2e07bbd8357bad030341885b630b7 100644 (file)
@@ -328,8 +328,8 @@ bool smp_crash_stop_failed(void)
 }
 #endif
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        send_ipi_single(cpu, IPI_RESCHEDULE);
 }
-EXPORT_SYMBOL_GPL(smp_send_reschedule);
+EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
index d4888453bbf8b180714e24ad9c685f26db3f3636..a710319f97e94cef1e82888e0affd31d147fe656 100644 (file)
@@ -553,7 +553,7 @@ void arch_send_call_function_single_ipi(int cpu)
  * it goes straight through and wastes no time serializing
  * anything. Worst case is that we lose a reschedule ...
  */
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        pcpu_ec_call(pcpu_devices + cpu, ec_schedule);
 }
index 65924d9ec24598f81e995bee85bf4cb135b1d84b..5cf35a774dc700823fe0177c016e09d5edec8efb 100644 (file)
@@ -256,7 +256,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
               (bogosum / (5000/HZ)) % 100);
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        mp_ops->send_ipi(cpu, SMP_MSG_RESCHEDULE);
 }
index ad8094d955eba6b3e6ec6cae8817929f63df9b37..87eaa7719fa27a4c9581cddebd2f509386f17aad 100644 (file)
@@ -120,7 +120,7 @@ void cpu_panic(void)
 
 struct linux_prom_registers smp_penguin_ctable = { 0 };
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        /*
         * CPU model dependent way of implementing IPI generation targeting
index a55295d1b924481f50a9541c88af49d823bc1083..e5964d1d8b37dc5cf5468c7cc2bdb2d22a7552e2 100644 (file)
@@ -1430,7 +1430,7 @@ static unsigned long send_cpu_poke(int cpu)
        return hv_err;
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        if (cpu == smp_processor_id()) {
                WARN_ON_ONCE(preemptible());
index b4dbb20dab1a11d509b4f702f4bde6a6269b4d18..f9757123d8fa10d639d05d6b1a823b81756bd932 100644 (file)
@@ -98,7 +98,7 @@ static inline void play_dead(void)
        smp_ops.play_dead();
 }
 
-static inline void smp_send_reschedule(int cpu)
+static inline void arch_smp_send_reschedule(int cpu)
 {
        smp_ops.smp_send_reschedule(cpu);
 }
index 252e7f37e4e2e27f2194d008c7c18e7c26c00eb1..424fcdba4c783fec4732c501558a320e3df0177c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/swap.h>
 #include <linux/rwsem.h>
 #include <linux/cc_platform.h>
+#include <linux/smp.h>
 
 #include <asm/apic.h>
 #include <asm/perf_event.h>
@@ -41,6 +42,9 @@
 #include <asm/fpu/api.h>
 
 #include <asm/virtext.h>
+
+#include <trace/events/ipi.h>
+
 #include "trace.h"
 
 #include "svm.h"
index 7713420abab093b19d6c19e41d9ca9454c006a08..07ba937bdb6f19b910f224f16255d9ba28e697cb 100644 (file)
@@ -60,7 +60,9 @@
 #include <linux/mem_encrypt.h>
 #include <linux/entry-kvm.h>
 #include <linux/suspend.h>
+#include <linux/smp.h>
 
+#include <trace/events/ipi.h>
 #include <trace/events/kvm.h>
 
 #include <asm/debugreg.h>
index 4dc109dd6214e27c47241ac1fcc081b3923dcfbd..d95907b8e4d3819a09fbfc0da91234084575195a 100644 (file)
@@ -389,7 +389,7 @@ void arch_send_call_function_single_ipi(int cpu)
        send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC);
 }
 
-void smp_send_reschedule(int cpu)
+void arch_smp_send_reschedule(int cpu)
 {
        send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
 }
index a80ab58ae3f1d1b30f1a3bc6b16fabfd27c43ad2..c036a2228d8d0e3c916db0653806ba7896ab9f7b 100644 (file)
@@ -125,8 +125,15 @@ extern void smp_send_stop(void);
 /*
  * sends a 'reschedule' event to another CPU:
  */
-extern void smp_send_reschedule(int cpu);
-
+extern void arch_smp_send_reschedule(int cpu);
+/*
+ * scheduler_ipi() is inline so can't be passed as callback reason, but the
+ * callsite IP should be sufficient for root-causing IPIs sent from here.
+ */
+#define smp_send_reschedule(cpu) ({                              \
+       trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL);  \
+       arch_smp_send_reschedule(cpu);                            \
+})
 
 /*
  * Prepare machine for booting other CPUs.
index d255964ec331ef5c9aebf90243990ef4da0aec2b..7d1889629bfeb377d880fbf6dcd56efcf1acaeb2 100644 (file)
 #include "kvm_mm.h"
 #include "vfio.h"
 
+#include <trace/events/ipi.h>
+
 #define CREATE_TRACE_POINTS
 #include <trace/events/kvm.h>
 
 #include <linux/kvm_dirty_ring.h>
 
+
 /* Worst case buffer size needed for holding an integer. */
 #define ITOA_MAX_LEN 12