Skip to content

Commit 68e2d17

Browse files
author
Peter Zijlstra
committed
trace: Add trace_ipi_send_cpu()
Because copying cpumasks around when targeting a single CPU is a bit daft... Tested-and-reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20230322103004.GA571242%40hirez.programming.kicks-ass.net
1 parent 68f4ff0 commit 68e2d17

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

include/linux/smp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ extern void arch_smp_send_reschedule(int cpu);
130130
* scheduler_ipi() is inline so can't be passed as callback reason, but the
131131
* callsite IP should be sufficient for root-causing IPIs sent from here.
132132
*/
133-
#define smp_send_reschedule(cpu) ({ \
134-
trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \
135-
arch_smp_send_reschedule(cpu); \
133+
#define smp_send_reschedule(cpu) ({ \
134+
trace_ipi_send_cpu(cpu, _RET_IP_, NULL); \
135+
arch_smp_send_reschedule(cpu); \
136136
})
137137

138138
/*

include/trace/events/ipi.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise,
3535
TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason)
3636
);
3737

38+
TRACE_EVENT(ipi_send_cpu,
39+
40+
TP_PROTO(const unsigned int cpu, unsigned long callsite, void *callback),
41+
42+
TP_ARGS(cpu, callsite, callback),
43+
44+
TP_STRUCT__entry(
45+
__field(unsigned int, cpu)
46+
__field(void *, callsite)
47+
__field(void *, callback)
48+
),
49+
50+
TP_fast_assign(
51+
__entry->cpu = cpu;
52+
__entry->callsite = (void *)callsite;
53+
__entry->callback = callback;
54+
),
55+
56+
TP_printk("cpu=%u callsite=%pS callback=%pS",
57+
__entry->cpu, __entry->callsite, __entry->callback)
58+
);
59+
3860
TRACE_EVENT(ipi_send_cpumask,
3961

4062
TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback),

kernel/irq_work.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ void __weak arch_irq_work_raise(void)
7878

7979
static __always_inline void irq_work_raise(struct irq_work *work)
8080
{
81-
if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt())
82-
trace_ipi_send_cpumask(cpumask_of(smp_processor_id()),
83-
_RET_IP_,
84-
work->func);
81+
if (trace_ipi_send_cpu_enabled() && arch_irq_work_has_interrupt())
82+
trace_ipi_send_cpu(smp_processor_id(), _RET_IP_, work->func);
8583

8684
arch_irq_work_raise();
8785
}

kernel/sched/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#include "../../io_uring/io-wq.h"
9797
#include "../smpboot.h"
9898

99+
EXPORT_TRACEPOINT_SYMBOL_GPL(ipi_send_cpu);
99100
EXPORT_TRACEPOINT_SYMBOL_GPL(ipi_send_cpumask);
100101

101102
/*

kernel/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static __always_inline void
107107
send_call_function_single_ipi(int cpu, smp_call_func_t func)
108108
{
109109
if (call_function_single_prep_ipi(cpu)) {
110-
trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func);
110+
trace_ipi_send_cpu(cpu, _RET_IP_, func);
111111
arch_send_call_function_single_ipi(cpu);
112112
}
113113
}
@@ -346,7 +346,7 @@ void __smp_call_single_queue(int cpu, struct llist_node *node)
346346
* even if we haven't sent the smp_call IPI yet (e.g. the stopper
347347
* executes migration_cpu_stop() on the remote CPU).
348348
*/
349-
if (trace_ipi_send_cpumask_enabled()) {
349+
if (trace_ipi_send_cpu_enabled()) {
350350
call_single_data_t *csd;
351351
smp_call_func_t func;
352352

0 commit comments

Comments
 (0)