Commit 4c8c3c7f authored by Valentin Schneider's avatar Valentin Schneider Committed by Peter Zijlstra

treewide: Trace IPIs sent via smp_send_reschedule()

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: default avatarValentin Schneider <vschneid@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarGuo Ren <guoren@kernel.org>
Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20230307143558.294354-6-vschneid@redhat.com
parent 4468161a
...@@ -562,7 +562,7 @@ handle_ipi(struct pt_regs *regs) ...@@ -562,7 +562,7 @@ handle_ipi(struct pt_regs *regs)
} }
void void
smp_send_reschedule(int cpu) arch_smp_send_reschedule(int cpu)
{ {
#ifdef DEBUG_IPI_MSG #ifdef DEBUG_IPI_MSG
if (cpu == hard_smp_processor_id()) if (cpu == hard_smp_processor_id())
......
...@@ -292,7 +292,7 @@ static void ipi_send_msg(const struct cpumask *callmap, enum ipi_msg_type msg) ...@@ -292,7 +292,7 @@ static void ipi_send_msg(const struct cpumask *callmap, enum ipi_msg_type msg)
ipi_send_msg_one(cpu, 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); ipi_send_msg_one(cpu, IPI_RESCHEDULE);
} }
......
...@@ -746,7 +746,7 @@ void __init set_smp_ipi_range(int ipi_base, int n) ...@@ -746,7 +746,7 @@ void __init set_smp_ipi_range(int ipi_base, int n)
ipi_setup(smp_processor_id()); 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); smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <asm/smp_plat.h> #include <asm/smp_plat.h>
#include <asm/smp_scu.h> #include <asm/smp_scu.h>
#include <trace/events/ipi.h>
#define OWL_CPU1_ADDR 0x50 #define OWL_CPU1_ADDR 0x50
#define OWL_CPU1_FLAG 0x5c #define OWL_CPU1_FLAG 0x5c
......
...@@ -976,7 +976,7 @@ void __init set_smp_ipi_range(int ipi_base, int n) ...@@ -976,7 +976,7 @@ void __init set_smp_ipi_range(int ipi_base, int n)
ipi_setup(smp_processor_id()); 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); smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -140,7 +140,7 @@ void smp_send_stop(void) ...@@ -140,7 +140,7 @@ void smp_send_stop(void)
on_each_cpu(ipi_stop, NULL, 1); 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); send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -217,7 +217,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) ...@@ -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); send_ipi(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -220,11 +220,11 @@ kdump_smp_send_init(void) ...@@ -220,11 +220,11 @@ kdump_smp_send_init(void)
* Called with preemption disabled. * Called with preemption disabled.
*/ */
void void
smp_send_reschedule (int cpu) arch_smp_send_reschedule (int cpu)
{ {
ia64_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0); 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. * Called with preemption disabled.
......
...@@ -155,11 +155,11 @@ void loongson_send_ipi_mask(const struct cpumask *mask, unsigned int action) ...@@ -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 * it goes straight through and wastes no time serializing
* anything. Worst case is that we lose a reschedule ... * 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); 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) irqreturn_t loongson_ipi_interrupt(int irq, void *dev)
{ {
......
...@@ -66,7 +66,7 @@ extern void calculate_cpu_foreign_map(void); ...@@ -66,7 +66,7 @@ extern void calculate_cpu_foreign_map(void);
* it goes straight through and wastes no time serializing * it goes straight through and wastes no time serializing
* anything. Worst case is that we lose a reschedule ... * 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 */ extern const struct plat_smp_ops *mp_ops; /* private */
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <asm/vpe.h> #include <asm/vpe.h>
#include <asm/rtlx.h> #include <asm/rtlx.h>
#include <trace/events/ipi.h>
static int major; static int major;
static void rtlx_interrupt(void) static void rtlx_interrupt(void)
......
...@@ -173,7 +173,7 @@ void handle_IPI(unsigned int ipi_msg) ...@@ -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); smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -246,8 +246,8 @@ void kgdb_roundup_cpus(void) ...@@ -246,8 +246,8 @@ void kgdb_roundup_cpus(void)
inline void inline void
smp_send_stop(void) { send_IPI_allbutself(IPI_CPU_STOP); } smp_send_stop(void) { send_IPI_allbutself(IPI_CPU_STOP); }
void void
smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); } arch_smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
void void
smp_send_all_nop(void) smp_send_all_nop(void)
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#include <asm/kup.h> #include <asm/kup.h>
#include <asm/fadump.h> #include <asm/fadump.h>
#include <trace/events/ipi.h>
#ifdef DEBUG #ifdef DEBUG
#include <asm/udbg.h> #include <asm/udbg.h>
#define DBG(fmt...) udbg_printf(fmt) #define DBG(fmt...) udbg_printf(fmt)
...@@ -364,12 +366,12 @@ static inline void do_message_pass(int cpu, int msg) ...@@ -364,12 +366,12 @@ static inline void do_message_pass(int cpu, int msg)
#endif #endif
} }
void smp_send_reschedule(int cpu) void arch_smp_send_reschedule(int cpu)
{ {
if (likely(smp_ops)) if (likely(smp_ops))
do_message_pass(cpu, PPC_MSG_RESCHEDULE); 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) void arch_send_call_function_single_ipi(int cpu)
{ {
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/smp.h>
#include <asm/ftrace.h> #include <asm/ftrace.h>
#include <asm/reg.h> #include <asm/reg.h>
...@@ -80,6 +81,8 @@ ...@@ -80,6 +81,8 @@
#include <asm/dtl.h> #include <asm/dtl.h>
#include <asm/plpar_wrappers.h> #include <asm/plpar_wrappers.h>
#include <trace/events/ipi.h>
#include "book3s.h" #include "book3s.h"
#include "book3s_hv.h" #include "book3s_hv.h"
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <asm/opal.h> #include <asm/opal.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <trace/events/ipi.h>
#include "subcore.h" #include "subcore.h"
#include "powernv.h" #include "powernv.h"
......
...@@ -328,8 +328,8 @@ bool smp_crash_stop_failed(void) ...@@ -328,8 +328,8 @@ bool smp_crash_stop_failed(void)
} }
#endif #endif
void smp_send_reschedule(int cpu) void arch_smp_send_reschedule(int cpu)
{ {
send_ipi_single(cpu, IPI_RESCHEDULE); send_ipi_single(cpu, IPI_RESCHEDULE);
} }
EXPORT_SYMBOL_GPL(smp_send_reschedule); EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
...@@ -553,7 +553,7 @@ void arch_send_call_function_single_ipi(int cpu) ...@@ -553,7 +553,7 @@ void arch_send_call_function_single_ipi(int cpu)
* it goes straight through and wastes no time serializing * it goes straight through and wastes no time serializing
* anything. Worst case is that we lose a reschedule ... * 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); pcpu_ec_call(pcpu_devices + cpu, ec_schedule);
} }
......
...@@ -256,7 +256,7 @@ void __init smp_cpus_done(unsigned int max_cpus) ...@@ -256,7 +256,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
(bogosum / (5000/HZ)) % 100); (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); mp_ops->send_ipi(cpu, SMP_MSG_RESCHEDULE);
} }
......
...@@ -120,7 +120,7 @@ void cpu_panic(void) ...@@ -120,7 +120,7 @@ void cpu_panic(void)
struct linux_prom_registers smp_penguin_ctable = { 0 }; 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 * CPU model dependent way of implementing IPI generation targeting
......
...@@ -1430,7 +1430,7 @@ static unsigned long send_cpu_poke(int cpu) ...@@ -1430,7 +1430,7 @@ static unsigned long send_cpu_poke(int cpu)
return hv_err; return hv_err;
} }
void smp_send_reschedule(int cpu) void arch_smp_send_reschedule(int cpu)
{ {
if (cpu == smp_processor_id()) { if (cpu == smp_processor_id()) {
WARN_ON_ONCE(preemptible()); WARN_ON_ONCE(preemptible());
......
...@@ -98,7 +98,7 @@ static inline void play_dead(void) ...@@ -98,7 +98,7 @@ static inline void play_dead(void)
smp_ops.play_dead(); 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); smp_ops.smp_send_reschedule(cpu);
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/cc_platform.h> #include <linux/cc_platform.h>
#include <linux/smp.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/perf_event.h> #include <asm/perf_event.h>
...@@ -41,6 +42,9 @@ ...@@ -41,6 +42,9 @@
#include <asm/fpu/api.h> #include <asm/fpu/api.h>
#include <asm/virtext.h> #include <asm/virtext.h>
#include <trace/events/ipi.h>
#include "trace.h" #include "trace.h"
#include "svm.h" #include "svm.h"
......
...@@ -60,7 +60,9 @@ ...@@ -60,7 +60,9 @@
#include <linux/mem_encrypt.h> #include <linux/mem_encrypt.h>
#include <linux/entry-kvm.h> #include <linux/entry-kvm.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/smp.h>
#include <trace/events/ipi.h>
#include <trace/events/kvm.h> #include <trace/events/kvm.h>
#include <asm/debugreg.h> #include <asm/debugreg.h>
......
...@@ -389,7 +389,7 @@ void arch_send_call_function_single_ipi(int cpu) ...@@ -389,7 +389,7 @@ void arch_send_call_function_single_ipi(int cpu)
send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC); 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); send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
} }
......
...@@ -125,8 +125,15 @@ extern void smp_send_stop(void); ...@@ -125,8 +125,15 @@ extern void smp_send_stop(void);
/* /*
* sends a 'reschedule' event to another CPU: * 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. * Prepare machine for booting other CPUs.
......
...@@ -62,11 +62,14 @@ ...@@ -62,11 +62,14 @@
#include "kvm_mm.h" #include "kvm_mm.h"
#include "vfio.h" #include "vfio.h"
#include <trace/events/ipi.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/kvm.h> #include <trace/events/kvm.h>
#include <linux/kvm_dirty_ring.h> #include <linux/kvm_dirty_ring.h>
/* Worst case buffer size needed for holding an integer. */ /* Worst case buffer size needed for holding an integer. */
#define ITOA_MAX_LEN 12 #define ITOA_MAX_LEN 12
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment