* [PATCH v3 0/8] Generic IPI sending tracepoint
@ 2022-12-02 15:58 ` Valentin Schneider
0 siblings, 0 replies; 90+ messages in thread
From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw)
To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel,
linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips,
openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390,
linux-sh, sparclinux, linux-xtensa, x86
Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner,
Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira,
Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar,
Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier,
Mark Rutland, Russell King, Nicholas Piggin, Guo Ren,
David S. Miller
Background
==========
Detecting IPI *reception* is relatively easy, e.g. using
trace_irq_handler_{entry,exit} or even just function-trace
flush_smp_call_function_queue() for SMP calls.
Figuring out their *origin*, is trickier as there is no generic tracepoint tied
to e.g. smp_call_function():
o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them
(cf. trace_call_function{_single}_entry()).
o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a
mostly useless string (smp_calls will all be "Function call interrupts").
o Other architectures don't seem to have any IPI-sending related tracepoint.
I believe one reason those tracepoints used by arm/arm64 ended up as they were
is because these archs used to handle IPIs differently from regular interrupts
(the IRQ driver would directly invoke an IPI-handling routine), which meant they
never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit}
tracepoints gave a way to trace IPI reception but those have become redundant as
of:
56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts")
d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts")
which gave IPIs a "proper" handler function used through
generic_handle_domain_irq(), which makes them show up via
trace_irq_handler_{entry, exit}.
Changing stuff up
=================
Per the above, it would make sense to reshuffle trace_ipi_raise() and move it
into generic code. This also came up during Daniel's talk on Osnoise at the CPU
isolation MC of LPC 2022 [1].
Now, to be useful, such a tracepoint needs to export:
o targeted CPU(s)
o calling context
The only way to get the calling context with trace_ipi_raise() is to trigger a
stack dump, e.g. $(trace-cmd -e ipi* -T echo 42).
This is instead introducing a new tracepoint which exports the relevant context
(callsite, and requested callback for when the callsite isn't helpful), and is
usable by all architectures as it sits in generic code.
Another thing worth mentioning is that depending on the callsite, the _RET_IP_
fed to the tracepoint is not always useful - generic_exec_single() doesn't tell
you much about the actual callback being sent via IPI, which is why the new
tracepoint also has a @callback argument.
Patches
=======
o Patch 1 is included for convenience and will be merged independently. FYI I
have libtraceevent patches [2] to improve the
pretty-printing of cpumasks using the new type, which look like:
<...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0
<...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0
o Patches 2-6 spread out the tracepoint across relevant sites.
Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not
the biggest fan of, but is the least horrible solution I've been able to come
up with so far.
o Patch 8 is trying to be smart about tracing the callback associated with the
IPI.
This results in having IPI trace events for:
o smp_call_function*()
o smp_send_reschedule()
o irq_work_queue*()
o standalone uses of __smp_call_single_queue()
This is incomplete, just looking at arm64 there's more IPI types that aren't
covered:
IPI_CPU_STOP,
IPI_CPU_CRASH_STOP,
IPI_TIMER,
IPI_WAKEUP,
... But it feels like a good starting point.
Links
=====
[1]: https://youtu.be/5gT57y4OzBM?t=14234
[2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/
Revisions
=========
v2 -> v3
++++++++
o Dropped the generic export of smp_send_reschedule(), turned it into a macro
and a bunch of imports
o Dropped the send_call_function_single_ipi() macro madness, split it into sched
and smp bits using some of Peter's suggestions
v1 -> v2
++++++++
o Ditched single-CPU tracepoint
o Changed tracepoint signature to include callback
o Changed tracepoint callsite field to void *; the parameter is still UL to save
up on casts due to using _RET_IP_.
o Fixed linking failures due to not exporting smp_send_reschedule()
Steven Rostedt (Google) (1):
tracing: Add __cpumask to denote a trace event field that is a
cpumask_t
Valentin Schneider (7):
trace: Add trace_ipi_send_cpumask()
sched, smp: Trace IPIs sent via send_call_function_single_ipi()
smp: Trace IPIs sent via arch_send_call_function_ipi_mask()
irq_work: Trace self-IPIs sent via arch_irq_work_raise()
treewide: Trace IPIs sent via smp_send_reschedule()
smp: reword smp call IPI comment
sched, smp: Trace smp callback causing an IPI
arch/alpha/kernel/smp.c | 2 +-
arch/arc/kernel/smp.c | 2 +-
arch/arm/kernel/smp.c | 5 +-
arch/arm/mach-actions/platsmp.c | 2 +
arch/arm64/kernel/smp.c | 3 +-
arch/csky/kernel/smp.c | 2 +-
arch/hexagon/kernel/smp.c | 2 +-
arch/ia64/kernel/smp.c | 4 +-
arch/loongarch/include/asm/smp.h | 2 +-
arch/mips/include/asm/smp.h | 2 +-
arch/mips/kernel/rtlx-cmp.c | 2 +
arch/openrisc/kernel/smp.c | 2 +-
arch/parisc/kernel/smp.c | 4 +-
arch/powerpc/kernel/smp.c | 6 +-
arch/powerpc/kvm/book3s_hv.c | 3 +
arch/powerpc/platforms/powernv/subcore.c | 2 +
arch/riscv/kernel/smp.c | 4 +-
arch/s390/kernel/smp.c | 2 +-
arch/sh/kernel/smp.c | 2 +-
arch/sparc/kernel/smp_32.c | 2 +-
arch/sparc/kernel/smp_64.c | 2 +-
arch/x86/include/asm/smp.h | 2 +-
arch/x86/kvm/svm/svm.c | 4 +
arch/x86/kvm/x86.c | 2 +
arch/xtensa/kernel/smp.c | 2 +-
include/linux/smp.h | 8 +-
include/trace/bpf_probe.h | 6 ++
include/trace/events/ipi.h | 22 ++++++
include/trace/perf.h | 6 ++
include/trace/stages/stage1_struct_define.h | 6 ++
include/trace/stages/stage2_data_offsets.h | 6 ++
include/trace/stages/stage3_trace_output.h | 6 ++
include/trace/stages/stage4_event_fields.h | 6 ++
include/trace/stages/stage5_get_offsets.h | 6 ++
include/trace/stages/stage6_event_callback.h | 20 +++++
include/trace/stages/stage7_class_define.h | 2 +
kernel/irq_work.c | 14 +++-
kernel/sched/core.c | 19 +++--
kernel/sched/smp.h | 2 +-
kernel/smp.c | 78 ++++++++++++++++----
samples/trace_events/trace-events-sample.c | 2 +-
samples/trace_events/trace-events-sample.h | 34 +++++++--
virt/kvm/kvm_main.c | 1 +
43 files changed, 250 insertions(+), 61 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 90+ messages in thread* [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Background ========== Detecting IPI *reception* is relatively easy, e.g. using trace_irq_handler_{entry,exit} or even just function-trace flush_smp_call_function_queue() for SMP calls. Figuring out their *origin*, is trickier as there is no generic tracepoint tied to e.g. smp_call_function(): o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them (cf. trace_call_function{_single}_entry()). o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a mostly useless string (smp_calls will all be "Function call interrupts"). o Other architectures don't seem to have any IPI-sending related tracepoint. I believe one reason those tracepoints used by arm/arm64 ended up as they were is because these archs used to handle IPIs differently from regular interrupts (the IRQ driver would directly invoke an IPI-handling routine), which meant they never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} tracepoints gave a way to trace IPI reception but those have become redundant as of: 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") which gave IPIs a "proper" handler function used through generic_handle_domain_irq(), which makes them show up via trace_irq_handler_{entry, exit}. Changing stuff up ================= Per the above, it would make sense to reshuffle trace_ipi_raise() and move it into generic code. This also came up during Daniel's talk on Osnoise at the CPU isolation MC of LPC 2022 [1]. Now, to be useful, such a tracepoint needs to export: o targeted CPU(s) o calling context The only way to get the calling context with trace_ipi_raise() is to trigger a stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). This is instead introducing a new tracepoint which exports the relevant context (callsite, and requested callback for when the callsite isn't helpful), and is usable by all architectures as it sits in generic code. Another thing worth mentioning is that depending on the callsite, the _RET_IP_ fed to the tracepoint is not always useful - generic_exec_single() doesn't tell you much about the actual callback being sent via IPI, which is why the new tracepoint also has a @callback argument. Patches ======= o Patch 1 is included for convenience and will be merged independently. FYI I have libtraceevent patches [2] to improve the pretty-printing of cpumasks using the new type, which look like: <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 o Patches 2-6 spread out the tracepoint across relevant sites. Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not the biggest fan of, but is the least horrible solution I've been able to come up with so far. o Patch 8 is trying to be smart about tracing the callback associated with the IPI. This results in having IPI trace events for: o smp_call_function*() o smp_send_reschedule() o irq_work_queue*() o standalone uses of __smp_call_single_queue() This is incomplete, just looking at arm64 there's more IPI types that aren't covered: IPI_CPU_STOP, IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_WAKEUP, ... But it feels like a good starting point. Links ===== [1]: https://youtu.be/5gT57y4OzBM?t=14234 [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ Revisions ========= v2 -> v3 ++++++++ o Dropped the generic export of smp_send_reschedule(), turned it into a macro and a bunch of imports o Dropped the send_call_function_single_ipi() macro madness, split it into sched and smp bits using some of Peter's suggestions v1 -> v2 ++++++++ o Ditched single-CPU tracepoint o Changed tracepoint signature to include callback o Changed tracepoint callsite field to void *; the parameter is still UL to save up on casts due to using _RET_IP_. o Fixed linking failures due to not exporting smp_send_reschedule() Steven Rostedt (Google) (1): tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider (7): trace: Add trace_ipi_send_cpumask() sched, smp: Trace IPIs sent via send_call_function_single_ipi() smp: Trace IPIs sent via arch_send_call_function_ipi_mask() irq_work: Trace self-IPIs sent via arch_irq_work_raise() treewide: Trace IPIs sent via smp_send_reschedule() smp: reword smp call IPI comment sched, smp: Trace smp callback causing an IPI arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 5 +- arch/arm/mach-actions/platsmp.c | 2 + arch/arm64/kernel/smp.c | 3 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 +- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 + arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 3 + arch/powerpc/platforms/powernv/subcore.c | 2 + arch/riscv/kernel/smp.c | 4 +- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 + arch/x86/kvm/x86.c | 2 + arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 +- include/trace/bpf_probe.h | 6 ++ include/trace/events/ipi.h | 22 ++++++ include/trace/perf.h | 6 ++ include/trace/stages/stage1_struct_define.h | 6 ++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 6 ++ include/trace/stages/stage4_event_fields.h | 6 ++ include/trace/stages/stage5_get_offsets.h | 6 ++ include/trace/stages/stage6_event_callback.h | 20 +++++ include/trace/stages/stage7_class_define.h | 2 + kernel/irq_work.c | 14 +++- kernel/sched/core.c | 19 +++-- kernel/sched/smp.h | 2 +- kernel/smp.c | 78 ++++++++++++++++---- samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++-- virt/kvm/kvm_main.c | 1 + 43 files changed, 250 insertions(+), 61 deletions(-) -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker Background ========== Detecting IPI *reception* is relatively easy, e.g. using trace_irq_handler_{entry,exit} or even just function-trace flush_smp_call_function_queue() for SMP calls. Figuring out their *origin*, is trickier as there is no generic tracepoint tied to e.g. smp_call_function(): o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them (cf. trace_call_function{_single}_entry()). o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a mostly useless string (smp_calls will all be "Function call interrupts"). o Other architectures don't seem to have any IPI-sending related tracepoint. I believe one reason those tracepoints used by arm/arm64 ended up as they were is because these archs used to handle IPIs differently from regular interrupts (the IRQ driver would directly invoke an IPI-handling routine), which meant they never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} tracepoints gave a way to trace IPI reception but those have become redundant as of: 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") which gave IPIs a "proper" handler function used through generic_handle_domain_irq(), which makes them show up via trace_irq_handler_{entry, exit}. Changing stuff up ================= Per the above, it would make sense to reshuffle trace_ipi_raise() and move it into generic code. This also came up during Daniel's talk on Osnoise at the CPU isolation MC of LPC 2022 [1]. Now, to be useful, such a tracepoint needs to export: o targeted CPU(s) o calling context The only way to get the calling context with trace_ipi_raise() is to trigger a stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). This is instead introducing a new tracepoint which exports the relevant context (callsite, and requested callback for when the callsite isn't helpful), and is usable by all architectures as it sits in generic code. Another thing worth mentioning is that depending on the callsite, the _RET_IP_ fed to the tracepoint is not always useful - generic_exec_single() doesn't tell you much about the actual callback being sent via IPI, which is why the new tracepoint also has a @callback argument. Patches ======= o Patch 1 is included for convenience and will be merged independently. FYI I have libtraceevent patches [2] to improve the pretty-printing of cpumasks using the new type, which look like: <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 o Patches 2-6 spread out the tracepoint across relevant sites. Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not the biggest fan of, but is the least horrible solution I've been able to come up with so far. o Patch 8 is trying to be smart about tracing the callback associated with the IPI. This results in having IPI trace events for: o smp_call_function*() o smp_send_reschedule() o irq_work_queue*() o standalone uses of __smp_call_single_queue() This is incomplete, just looking at arm64 there's more IPI types that aren't covered: IPI_CPU_STOP, IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_WAKEUP, ... But it feels like a good starting point. Links ===== [1]: https://youtu.be/5gT57y4OzBM?t=14234 [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ Revisions ========= v2 -> v3 ++++++++ o Dropped the generic export of smp_send_reschedule(), turned it into a macro and a bunch of imports o Dropped the send_call_function_single_ipi() macro madness, split it into sched and smp bits using some of Peter's suggestions v1 -> v2 ++++++++ o Ditched single-CPU tracepoint o Changed tracepoint signature to include callback o Changed tracepoint callsite field to void *; the parameter is still UL to save up on casts due to using _RET_IP_. o Fixed linking failures due to not exporting smp_send_reschedule() Steven Rostedt (Google) (1): tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider (7): trace: Add trace_ipi_send_cpumask() sched, smp: Trace IPIs sent via send_call_function_single_ipi() smp: Trace IPIs sent via arch_send_call_function_ipi_mask() irq_work: Trace self-IPIs sent via arch_irq_work_raise() treewide: Trace IPIs sent via smp_send_reschedule() smp: reword smp call IPI comment sched, smp: Trace smp callback causing an IPI arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 5 +- arch/arm/mach-actions/platsmp.c | 2 + arch/arm64/kernel/smp.c | 3 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 +- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 + arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 3 + arch/powerpc/platforms/powernv/subcore.c | 2 + arch/riscv/kernel/smp.c | 4 +- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 + arch/x86/kvm/x86.c | 2 + arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 +- include/trace/bpf_probe.h | 6 ++ include/trace/events/ipi.h | 22 ++++++ include/trace/perf.h | 6 ++ include/trace/stages/stage1_struct_define.h | 6 ++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 6 ++ include/trace/stages/stage4_event_fields.h | 6 ++ include/trace/stages/stage5_get_offsets.h | 6 ++ include/trace/stages/stage6_event_callback.h | 20 +++++ include/trace/stages/stage7_class_define.h | 2 + kernel/irq_work.c | 14 +++- kernel/sched/core.c | 19 +++-- kernel/sched/smp.h | 2 +- kernel/smp.c | 78 ++++++++++++++++---- samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++-- virt/kvm/kvm_main.c | 1 + 43 files changed, 250 insertions(+), 61 deletions(-) -- 2.31.1 ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Background ========== Detecting IPI *reception* is relatively easy, e.g. using trace_irq_handler_{entry,exit} or even just function-trace flush_smp_call_function_queue() for SMP calls. Figuring out their *origin*, is trickier as there is no generic tracepoint tied to e.g. smp_call_function(): o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them (cf. trace_call_function{_single}_entry()). o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a mostly useless string (smp_calls will all be "Function call interrupts"). o Other architectures don't seem to have any IPI-sending related tracepoint. I believe one reason those tracepoints used by arm/arm64 ended up as they were is because these archs used to handle IPIs differently from regular interrupts (the IRQ driver would directly invoke an IPI-handling routine), which meant they never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} tracepoints gave a way to trace IPI reception but those have become redundant as of: 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") which gave IPIs a "proper" handler function used through generic_handle_domain_irq(), which makes them show up via trace_irq_handler_{entry, exit}. Changing stuff up ================= Per the above, it would make sense to reshuffle trace_ipi_raise() and move it into generic code. This also came up during Daniel's talk on Osnoise at the CPU isolation MC of LPC 2022 [1]. Now, to be useful, such a tracepoint needs to export: o targeted CPU(s) o calling context The only way to get the calling context with trace_ipi_raise() is to trigger a stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). This is instead introducing a new tracepoint which exports the relevant context (callsite, and requested callback for when the callsite isn't helpful), and is usable by all architectures as it sits in generic code. Another thing worth mentioning is that depending on the callsite, the _RET_IP_ fed to the tracepoint is not always useful - generic_exec_single() doesn't tell you much about the actual callback being sent via IPI, which is why the new tracepoint also has a @callback argument. Patches ======= o Patch 1 is included for convenience and will be merged independently. FYI I have libtraceevent patches [2] to improve the pretty-printing of cpumasks using the new type, which look like: <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 o Patches 2-6 spread out the tracepoint across relevant sites. Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not the biggest fan of, but is the least horrible solution I've been able to come up with so far. o Patch 8 is trying to be smart about tracing the callback associated with the IPI. This results in having IPI trace events for: o smp_call_function*() o smp_send_reschedule() o irq_work_queue*() o standalone uses of __smp_call_single_queue() This is incomplete, just looking at arm64 there's more IPI types that aren't covered: IPI_CPU_STOP, IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_WAKEUP, ... But it feels like a good starting point. Links ===== [1]: https://youtu.be/5gT57y4OzBM?t=14234 [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ Revisions ========= v2 -> v3 ++++++++ o Dropped the generic export of smp_send_reschedule(), turned it into a macro and a bunch of imports o Dropped the send_call_function_single_ipi() macro madness, split it into sched and smp bits using some of Peter's suggestions v1 -> v2 ++++++++ o Ditched single-CPU tracepoint o Changed tracepoint signature to include callback o Changed tracepoint callsite field to void *; the parameter is still UL to save up on casts due to using _RET_IP_. o Fixed linking failures due to not exporting smp_send_reschedule() Steven Rostedt (Google) (1): tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider (7): trace: Add trace_ipi_send_cpumask() sched, smp: Trace IPIs sent via send_call_function_single_ipi() smp: Trace IPIs sent via arch_send_call_function_ipi_mask() irq_work: Trace self-IPIs sent via arch_irq_work_raise() treewide: Trace IPIs sent via smp_send_reschedule() smp: reword smp call IPI comment sched, smp: Trace smp callback causing an IPI arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 5 +- arch/arm/mach-actions/platsmp.c | 2 + arch/arm64/kernel/smp.c | 3 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 +- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 + arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 3 + arch/powerpc/platforms/powernv/subcore.c | 2 + arch/riscv/kernel/smp.c | 4 +- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 + arch/x86/kvm/x86.c | 2 + arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 +- include/trace/bpf_probe.h | 6 ++ include/trace/events/ipi.h | 22 ++++++ include/trace/perf.h | 6 ++ include/trace/stages/stage1_struct_define.h | 6 ++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 6 ++ include/trace/stages/stage4_event_fields.h | 6 ++ include/trace/stages/stage5_get_offsets.h | 6 ++ include/trace/stages/stage6_event_callback.h | 20 +++++ include/trace/stages/stage7_class_define.h | 2 + kernel/irq_work.c | 14 +++- kernel/sched/core.c | 19 +++-- kernel/sched/smp.h | 2 +- kernel/smp.c | 78 ++++++++++++++++---- samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++-- virt/kvm/kvm_main.c | 1 + 43 files changed, 250 insertions(+), 61 deletions(-) -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Background ========== Detecting IPI *reception* is relatively easy, e.g. using trace_irq_handler_{entry,exit} or even just function-trace flush_smp_call_function_queue() for SMP calls. Figuring out their *origin*, is trickier as there is no generic tracepoint tied to e.g. smp_call_function(): o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them (cf. trace_call_function{_single}_entry()). o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a mostly useless string (smp_calls will all be "Function call interrupts"). o Other architectures don't seem to have any IPI-sending related tracepoint. I believe one reason those tracepoints used by arm/arm64 ended up as they were is because these archs used to handle IPIs differently from regular interrupts (the IRQ driver would directly invoke an IPI-handling routine), which meant they never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} tracepoints gave a way to trace IPI reception but those have become redundant as of: 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") which gave IPIs a "proper" handler function used through generic_handle_domain_irq(), which makes them show up via trace_irq_handler_{entry, exit}. Changing stuff up ================= Per the above, it would make sense to reshuffle trace_ipi_raise() and move it into generic code. This also came up during Daniel's talk on Osnoise at the CPU isolation MC of LPC 2022 [1]. Now, to be useful, such a tracepoint needs to export: o targeted CPU(s) o calling context The only way to get the calling context with trace_ipi_raise() is to trigger a stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). This is instead introducing a new tracepoint which exports the relevant context (callsite, and requested callback for when the callsite isn't helpful), and is usable by all architectures as it sits in generic code. Another thing worth mentioning is that depending on the callsite, the _RET_IP_ fed to the tracepoint is not always useful - generic_exec_single() doesn't tell you much about the actual callback being sent via IPI, which is why the new tracepoint also has a @callback argument. Patches ======= o Patch 1 is included for convenience and will be merged independently. FYI I have libtraceevent patches [2] to improve the pretty-printing of cpumasks using the new type, which look like: <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 o Patches 2-6 spread out the tracepoint across relevant sites. Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not the biggest fan of, but is the least horrible solution I've been able to come up with so far. o Patch 8 is trying to be smart about tracing the callback associated with the IPI. This results in having IPI trace events for: o smp_call_function*() o smp_send_reschedule() o irq_work_queue*() o standalone uses of __smp_call_single_queue() This is incomplete, just looking at arm64 there's more IPI types that aren't covered: IPI_CPU_STOP, IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_WAKEUP, ... But it feels like a good starting point. Links ===== [1]: https://youtu.be/5gT57y4OzBM?t=14234 [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ Revisions ========= v2 -> v3 ++++++++ o Dropped the generic export of smp_send_reschedule(), turned it into a macro and a bunch of imports o Dropped the send_call_function_single_ipi() macro madness, split it into sched and smp bits using some of Peter's suggestions v1 -> v2 ++++++++ o Ditched single-CPU tracepoint o Changed tracepoint signature to include callback o Changed tracepoint callsite field to void *; the parameter is still UL to save up on casts due to using _RET_IP_. o Fixed linking failures due to not exporting smp_send_reschedule() Steven Rostedt (Google) (1): tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider (7): trace: Add trace_ipi_send_cpumask() sched, smp: Trace IPIs sent via send_call_function_single_ipi() smp: Trace IPIs sent via arch_send_call_function_ipi_mask() irq_work: Trace self-IPIs sent via arch_irq_work_raise() treewide: Trace IPIs sent via smp_send_reschedule() smp: reword smp call IPI comment sched, smp: Trace smp callback causing an IPI arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 5 +- arch/arm/mach-actions/platsmp.c | 2 + arch/arm64/kernel/smp.c | 3 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 +- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 + arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 3 + arch/powerpc/platforms/powernv/subcore.c | 2 + arch/riscv/kernel/smp.c | 4 +- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 + arch/x86/kvm/x86.c | 2 + arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 +- include/trace/bpf_probe.h | 6 ++ include/trace/events/ipi.h | 22 ++++++ include/trace/perf.h | 6 ++ include/trace/stages/stage1_struct_define.h | 6 ++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 6 ++ include/trace/stages/stage4_event_fields.h | 6 ++ include/trace/stages/stage5_get_offsets.h | 6 ++ include/trace/stages/stage6_event_callback.h | 20 +++++ include/trace/stages/stage7_class_define.h | 2 + kernel/irq_work.c | 14 +++- kernel/sched/core.c | 19 +++-- kernel/sched/smp.h | 2 +- kernel/smp.c | 78 ++++++++++++++++---- samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++-- virt/kvm/kvm_main.c | 1 + 43 files changed, 250 insertions(+), 61 deletions(-) -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Background ===== Detecting IPI *reception* is relatively easy, e.g. using trace_irq_handler_{entry,exit} or even just function-trace flush_smp_call_function_queue() for SMP calls. Figuring out their *origin*, is trickier as there is no generic tracepoint tied to e.g. smp_call_function(): o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them (cf. trace_call_function{_single}_entry()). o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a mostly useless string (smp_calls will all be "Function call interrupts"). o Other architectures don't seem to have any IPI-sending related tracepoint. I believe one reason those tracepoints used by arm/arm64 ended up as they were is because these archs used to handle IPIs differently from regular interrupts (the IRQ driver would directly invoke an IPI-handling routine), which meant they never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} tracepoints gave a way to trace IPI reception but those have become redundant as of: 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") which gave IPIs a "proper" handler function used through generic_handle_domain_irq(), which makes them show up via trace_irq_handler_{entry, exit}. Changing stuff up ======== Per the above, it would make sense to reshuffle trace_ipi_raise() and move it into generic code. This also came up during Daniel's talk on Osnoise at the CPU isolation MC of LPC 2022 [1]. Now, to be useful, such a tracepoint needs to export: o targeted CPU(s) o calling context The only way to get the calling context with trace_ipi_raise() is to trigger a stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). This is instead introducing a new tracepoint which exports the relevant context (callsite, and requested callback for when the callsite isn't helpful), and is usable by all architectures as it sits in generic code. Another thing worth mentioning is that depending on the callsite, the _RET_IP_ fed to the tracepoint is not always useful - generic_exec_single() doesn't tell you much about the actual callback being sent via IPI, which is why the new tracepoint also has a @callback argument. Patches === o Patch 1 is included for convenience and will be merged independently. FYI I have libtraceevent patches [2] to improve the pretty-printing of cpumasks using the new type, which look like: <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask\x14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 o Patches 2-6 spread out the tracepoint across relevant sites. Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not the biggest fan of, but is the least horrible solution I've been able to come up with so far. o Patch 8 is trying to be smart about tracing the callback associated with the IPI. This results in having IPI trace events for: o smp_call_function*() o smp_send_reschedule() o irq_work_queue*() o standalone uses of __smp_call_single_queue() This is incomplete, just looking at arm64 there's more IPI types that aren't covered: IPI_CPU_STOP, IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_WAKEUP, ... But it feels like a good starting point. Links == [1]: https://youtu.be/5gT57y4OzBM?t\x14234 [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ Revisions ==== v2 -> v3 ++++++++ o Dropped the generic export of smp_send_reschedule(), turned it into a macro and a bunch of imports o Dropped the send_call_function_single_ipi() macro madness, split it into sched and smp bits using some of Peter's suggestions v1 -> v2 ++++++++ o Ditched single-CPU tracepoint o Changed tracepoint signature to include callback o Changed tracepoint callsite field to void *; the parameter is still UL to save up on casts due to using _RET_IP_. o Fixed linking failures due to not exporting smp_send_reschedule() Steven Rostedt (Google) (1): tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider (7): trace: Add trace_ipi_send_cpumask() sched, smp: Trace IPIs sent via send_call_function_single_ipi() smp: Trace IPIs sent via arch_send_call_function_ipi_mask() irq_work: Trace self-IPIs sent via arch_irq_work_raise() treewide: Trace IPIs sent via smp_send_reschedule() smp: reword smp call IPI comment sched, smp: Trace smp callback causing an IPI arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 5 +- arch/arm/mach-actions/platsmp.c | 2 + arch/arm64/kernel/smp.c | 3 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 +- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 + arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 3 + arch/powerpc/platforms/powernv/subcore.c | 2 + arch/riscv/kernel/smp.c | 4 +- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 + arch/x86/kvm/x86.c | 2 + arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 +- include/trace/bpf_probe.h | 6 ++ include/trace/events/ipi.h | 22 ++++++ include/trace/perf.h | 6 ++ include/trace/stages/stage1_struct_define.h | 6 ++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 6 ++ include/trace/stages/stage4_event_fields.h | 6 ++ include/trace/stages/stage5_get_offsets.h | 6 ++ include/trace/stages/stage6_event_callback.h | 20 +++++ include/trace/stages/stage7_class_define.h | 2 + kernel/irq_work.c | 14 +++- kernel/sched/core.c | 19 +++-- kernel/sched/smp.h | 2 +- kernel/smp.c | 78 ++++++++++++++++---- samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++-- virt/kvm/kvm_main.c | 1 + 43 files changed, 250 insertions(+), 61 deletions(-) -- 2.31.1 ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt (Google), Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt (Google), Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt (Google), David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt (Google), Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt (Google), Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_ @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt (Google), David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The trace events have a __bitmask field that can be used for anything that requires bitmasks. Although currently it is only used for CPU masks, it could be used in the future for any type of bitmasks. There is some user space tooling that wants to know if a field is a CPU mask and not just some random unsigned long bitmask. Introduce "__cpumask()" helper functions that work the same as the current __bitmask() helpers but displays in the format file: field:__data_loc cpumask_t *[] mask; offset:36; size:4; signed:0; Instead of: field:__data_loc unsigned long[] mask; offset:32; size:4; signed:0; The main difference is the type. Instead of "unsigned long" it is "cpumask_t *". Note, this type field needs to be a real type in the __dynamic_array() logic that both __cpumask and__bitmask use, but the comparison field requires it to be a scalar type whereas cpumask_t is a structure (non-scalar). But everything works when making it a pointer. Valentin added changes to remove the need of passing in "nr_bits" and the __cpumask will always use nr_cpumask_bits as its size. Link: https://lkml.kernel.org/r/20221014080456.1d32b989@rorschach.local.home Requested-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Valentin Schneider <vschneid@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/bpf_probe.h | 6 ++++ include/trace/perf.h | 6 ++++ include/trace/stages/stage1_struct_define.h | 6 ++++ include/trace/stages/stage2_data_offsets.h | 6 ++++ include/trace/stages/stage3_trace_output.h | 6 ++++ include/trace/stages/stage4_event_fields.h | 6 ++++ include/trace/stages/stage5_get_offsets.h | 6 ++++ include/trace/stages/stage6_event_callback.h | 20 ++++++++++++ include/trace/stages/stage7_class_define.h | 2 ++ samples/trace_events/trace-events-sample.c | 2 +- samples/trace_events/trace-events-sample.h | 34 +++++++++++++++----- 11 files changed, 91 insertions(+), 9 deletions(-) diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 6a13220d2d27b..155c495b89ead 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -40,6 +43,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/perf.h b/include/trace/perf.h index 5800d13146c3d..8f3bf1e177070 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -21,6 +21,9 @@ #undef __get_bitmask #define __get_bitmask(field) (char *)__get_dynamic_array(field) +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) @@ -41,6 +44,9 @@ #undef __get_rel_bitmask #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + #undef __get_rel_sockaddr #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) diff --git a/include/trace/stages/stage1_struct_define.h b/include/trace/stages/stage1_struct_define.h index 1b7bab60434c1..69e0dae453bfa 100644 --- a/include/trace/stages/stage1_struct_define.h +++ b/include/trace/stages/stage1_struct_define.h @@ -32,6 +32,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(char, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -47,6 +50,9 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(char, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h index 1b7a8f764fddd..469b6a64293de 100644 --- a/include/trace/stages/stage2_data_offsets.h +++ b/include/trace/stages/stage2_data_offsets.h @@ -38,6 +38,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -53,5 +56,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index e3b183e9d18ea..66374df61ed30 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -42,6 +42,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_cpumask +#define __get_cpumask(field) __get_bitmask(field) + #undef __get_rel_bitmask #define __get_rel_bitmask(field) \ ({ \ @@ -51,6 +54,9 @@ trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ }) +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) __get_rel_bitmask(field) + #undef __get_sockaddr #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) diff --git a/include/trace/stages/stage4_event_fields.h b/include/trace/stages/stage4_event_fields.h index a8fb25f39a99d..f2990d22313cf 100644 --- a/include/trace/stages/stage4_event_fields.h +++ b/include/trace/stages/stage4_event_fields.h @@ -46,6 +46,9 @@ #undef __bitmask #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) +#undef __cpumask +#define __cpumask(item) __dynamic_array(cpumask_t *, item, -1) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -64,5 +67,8 @@ #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(cpumask_t *, item, -1) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h index fba4c24ed9e60..ac5c24d3beeb2 100644 --- a/include/trace/stages/stage5_get_offsets.h +++ b/include/trace/stages/stage5_get_offsets.h @@ -82,10 +82,16 @@ #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __cpumask +#define __cpumask(item) __bitmask(item, nr_cpumask_bits) + #undef __rel_bitmask #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ __bitmask_size_in_longs(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_bitmask(item, nr_cpumask_bits) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 3c554a5853204..49c32394b53fb 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -57,6 +57,16 @@ #define __assign_bitmask(dst, src, nr_bits) \ memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __cpumask +#define __cpumask(item) __dynamic_array(unsigned long, item, -1) + +#undef __get_cpumask +#define __get_cpumask(field) (char *)__get_dynamic_array(field) + +#undef __assign_cpumask +#define __assign_cpumask(dst, src) \ + memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __sockaddr #define __sockaddr(field, len) __dynamic_array(u8, field, len) @@ -98,6 +108,16 @@ #define __assign_rel_bitmask(dst, src, nr_bits) \ memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) +#undef __rel_cpumask +#define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) + +#undef __assign_rel_cpumask +#define __assign_rel_cpumask(dst, src) \ + memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) + #undef __rel_sockaddr #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246dd..8795429f388b0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -13,11 +13,13 @@ #undef __get_dynamic_array_len #undef __get_str #undef __get_bitmask +#undef __get_cpumask #undef __get_sockaddr #undef __get_rel_dynamic_array #undef __get_rel_dynamic_array_len #undef __get_rel_str #undef __get_rel_bitmask +#undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c index 608c4ae3b08a3..ecc7db237f2ef 100644 --- a/samples/trace_events/trace-events-sample.c +++ b/samples/trace_events/trace-events-sample.c @@ -50,7 +50,7 @@ static void do_simple_thread_func(int cnt, const char *fmt, ...) trace_foo_with_template_print("I have to be different", cnt); - trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask, current->cpus_ptr); } static void simple_thread_func(int cnt) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 1a92226202fc5..fb4548a44153c 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -200,6 +200,16 @@ * * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits); * + * __cpumask: This is pretty much the same as __bitmask but is specific for + * CPU masks. The type displayed to the user via the format files will + * be "cpumaks_t" such that user space may deal with them differently + * if they choose to do so, and the bits is always set to nr_cpumask_bits. + * + * __cpumask(target_cpu) + * + * To assign a cpumask, use the __assign_cpumask() helper macro. + * + * __assign_cpumask(target_cpus, cpumask_bits(bar)); * * fast_assign: This is a C like function that is used to store the items * into the ring buffer. A special variable called "__entry" will be the @@ -212,8 +222,8 @@ * This is also used to print out the data from the trace files. * Again, the __entry macro is used to access the data from the ring buffer. * - * Note, __dynamic_array, __string, and __bitmask require special helpers - * to access the data. + * Note, __dynamic_array, __string, __bitmask and __cpumask require special + * helpers to access the data. * * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo) * Use __get_dynamic_array_len(foo) to get the length of the array @@ -226,6 +236,8 @@ * * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus) * + * For __cpumask(target_cpus) use __get_cpumask(target_cpus) + * * * Note, that for both the assign and the printk, __entry is the handler * to the data structure in the ring buffer, and is defined by the @@ -288,6 +300,7 @@ TRACE_EVENT(foo_bar, __dynamic_array(int, list, __length_of(lst)) __string( str, string ) __bitmask( cpus, num_possible_cpus() ) + __cpumask( cpum ) __vstring( vstr, fmt, va ) ), @@ -299,9 +312,10 @@ TRACE_EVENT(foo_bar, __assign_str(str, string); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); + __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -345,7 +359,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_str(vstr)) + __get_str(str), __get_bitmask(cpus), __get_cpumask(cpus), + __get_str(vstr)) ); /* @@ -542,15 +557,16 @@ DEFINE_EVENT_PRINT(foo_template, foo_with_template_print, TRACE_EVENT(foo_rel_loc, - TP_PROTO(const char *foo, int bar, unsigned long *mask), + TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus), - TP_ARGS(foo, bar, mask), + TP_ARGS(foo, bar, mask, cpus), TP_STRUCT__entry( __rel_string( foo, foo ) __field( int, bar ) __rel_bitmask( bitmask, BITS_PER_BYTE * sizeof(unsigned long) ) + __rel_cpumask( cpumask ) ), TP_fast_assign( @@ -558,10 +574,12 @@ TRACE_EVENT(foo_rel_loc, __entry->bar = bar; __assign_rel_bitmask(bitmask, mask, BITS_PER_BYTE * sizeof(unsigned long)); + __assign_rel_cpumask(cpumask, cpus); ), - TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, - __get_rel_bitmask(bitmask)) + TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar, + __get_rel_bitmask(bitmask), + __get_rel_cpumask(cpumask)) ); #endif -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker trace_ipi_raise() is unsuitable for generically tracing IPI sources due to its "reason" argument being an uninformative string (on arm64 all you get is "Function call interrupts" for SMP calls). Add a variant of it that exports a target CPU, a callsite and a callback. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- include/trace/events/ipi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h index 0be71dad6ec03..b1125dc27682c 100644 --- a/include/trace/events/ipi.h +++ b/include/trace/events/ipi.h @@ -35,6 +35,28 @@ TRACE_EVENT(ipi_raise, TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) ); +TRACE_EVENT(ipi_send_cpumask, + + TP_PROTO(const struct cpumask *cpumask, unsigned long callsite, void *callback), + + TP_ARGS(cpumask, callsite, callback), + + TP_STRUCT__entry( + __cpumask(cpumask) + __field(void *, callsite) + __field(void *, callback) + ), + + TP_fast_assign( + __assign_cpumask(cpumask, cpumask_bits(cpumask)); + __entry->callsite = (void *)callsite; + __entry->callback = callback; + ), + + TP_printk("cpumask=%s callsite=%pS callback=%pS", + __get_cpumask(cpumask), __entry->callsite, __entry->callback) +); + DECLARE_EVENT_CLASS(ipi_handler, TP_PROTO(const char *reason), -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller send_call_function_single_ipi() is the thing that sends IPIs at the bottom of smp_call_function*() via either generic_exec_single() or smp_call_function_many_cond(). Give it an IPI-related tracepoint. Note that this ends up tracing any IPI sent via __smp_call_single_queue(), which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- arch/arm/kernel/smp.c | 3 --- arch/arm64/kernel/smp.c | 1 - kernel/sched/core.c | 7 +++++-- kernel/smp.c | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 978db2d96b446..3b280d55c1c40 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -48,9 +48,6 @@ #include <asm/mach/arch.h> #include <asm/mpu.h> -#define CREATE_TRACE_POINTS -#include <trace/events/ipi.h> - /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf6955..937d2623e06ba 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -51,7 +51,6 @@ #include <asm/ptrace.h> #include <asm/virt.h> -#define CREATE_TRACE_POINTS #include <trace/events/ipi.h> DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f003858..40587b0d99329 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -81,6 +81,7 @@ #include <linux/sched/rseq_api.h> #include <trace/events/sched.h> #undef CREATE_TRACE_POINTS +#include <trace/events/ipi.h> #include "sched.h" #include "stats.h" @@ -3746,10 +3747,12 @@ void send_call_function_single_ipi(int cpu) { struct rq *rq = cpu_rq(cpu); - if (!set_nr_if_polling(rq->idle)) + if (!set_nr_if_polling(rq->idle)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); arch_send_call_function_single_ipi(cpu); - else + } else { trace_sched_wake_idle_without_ipi(cpu); + } } /* diff --git a/kernel/smp.c b/kernel/smp.c index 06a413987a14a..e2ca1e2f31274 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -26,6 +26,10 @@ #include <linux/sched/debug.h> #include <linux/jump_label.h> +#define CREATE_TRACE_POINTS +#include <trace/events/ipi.h> +#undef CREATE_TRACE_POINTS + #include "smpboot.h" #include "sched/smp.h" -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() 2022-12-02 15:58 ` Valentin Schneider ` (5 preceding siblings ...) (?) @ 2023-01-07 11:04 ` Ingo Molnar -1 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Dani * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel, linux-parisc, Daniel Bristot de Oliveira, Marcelo Tosatti, linux-kernel, linux-alpha, linuxppc-dev, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-07 11:04 ` Ingo Molnar 0 siblings, 0 replies; 90+ messages in thread From: Ingo Molnar @ 2023-01-07 11:04 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller * Valentin Schneider <vschneid@redhat.com> wrote: > send_call_function_single_ipi() is the thing that sends IPIs at the bottom > of smp_call_function*() via either generic_exec_single() or > smp_call_function_many_cond(). Give it an IPI-related tracepoint. > > Note that this ends up tracing any IPI sent via __smp_call_single_queue(), > which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@kernel.org> Patch series logistics: - No objections from the scheduler side, this feature looks pretty useful. - Certain patches are incomplete, others are noted as being merged separately, so I presume you'll send an updated/completed series eventually? - We can merge this via the scheduler tree I suspect, as most callbacks affected relate to tip:sched/core and tmp:smp/core - but if you have some other preferred tree that's fine too. Thanks, Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() 2023-01-07 11:04 ` Ingo Molnar ` (3 preceding siblings ...) (?) @ 2023-01-09 19:02 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-09 19:02 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-09 19:02 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel, linux-parisc, Daniel Bristot de Oliveira, Marcelo Tosatti, linux-kernel, linux-alpha, linuxppc-dev, David S. Miller On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-09 19:02 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-09 19:02 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() @ 2023-01-09 19:02 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:02 UTC (permalink / raw) To: Ingo Molnar Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller On 07/01/23 12:04, Ingo Molnar wrote: > * Valentin Schneider <vschneid@redhat.com> wrote: > >> send_call_function_single_ipi() is the thing that sends IPIs at the bottom >> of smp_call_function*() via either generic_exec_single() or >> smp_call_function_many_cond(). Give it an IPI-related tracepoint. >> >> Note that this ends up tracing any IPI sent via __smp_call_single_queue(), >> which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free". >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > Acked-by: Ingo Molnar <mingo@kernel.org> > > Patch series logistics: > > - No objections from the scheduler side, this feature looks pretty useful. > Thanks! > - Certain patches are incomplete, others are noted as being merged > separately, so I presume you'll send an updated/completed series > eventually? > The first patch from Steve is now in, so can drop it. The other patches are complete, though I need to rebase them and regenerate the treewide patch to catch any changes that came with 6.2. I'll do that this week. The "incompleteness" pointed out in the cover letter is about the types of IPIs that can be traced. This series covers the ones that end up invoking some core code (coincidentally those are the most common ones), others such as e.g. tick_broadcast() for arm, arm64, riscv and hexagon remain unaffected. I'm not that much interested in these (other than maybe the tick broadcast one they are all fairly unfrequent), but I'm happy to have a shot at them for the sake of completeness - either in that series or in a followup, up to you. > - We can merge this via the scheduler tree I suspect, as most callbacks > affected relate to tip:sched/core and tmp:smp/core - but if you have > some other preferred tree that's fine too. > Either sound good to me. > Thanks, > > Ingo ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus == 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus == 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus == 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus == 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus == 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller This simply wraps around the arch function and prepends it with a tracepoint, similar to send_call_function_single_ipi(). Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/smp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index e2ca1e2f31274..93b4386cd3096 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -160,6 +160,13 @@ void __init call_function_init(void) smpcfd_prepare_cpu(smp_processor_id()); } +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + arch_send_call_function_ipi_mask(mask); +} + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG static DEFINE_STATIC_KEY_FALSE(csdlock_debug_enabled); @@ -970,7 +977,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (nr_cpus = 1) send_call_function_single_ipi(last_cpu); else if (likely(nr_cpus > 1)) - arch_send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Steven Rostedt, Paul E. McKenney, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller IPIs sent to remote CPUs via irq_work_queue_on() are now covered by trace_ipi_send_cpumask(), add another instance of the tracepoint to cover self-IPIs. Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/irq_work.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 7afa40fe5cc43..c33e88e32a67a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -22,6 +22,8 @@ #include <asm/processor.h> #include <linux/kasan.h> +#include <trace/events/ipi.h> + static DEFINE_PER_CPU(struct llist_head, raised_list); static DEFINE_PER_CPU(struct llist_head, lazy_list); static DEFINE_PER_CPU(struct task_struct *, irq_workd); @@ -74,6 +76,16 @@ void __weak arch_irq_work_raise(void) */ } +static __always_inline void irq_work_raise(struct irq_work *work) +{ + if (trace_ipi_send_cpumask_enabled() && arch_irq_work_has_interrupt()) + trace_ipi_send_cpumask(cpumask_of(smp_processor_id()), + _RET_IP_, + work->func); + + arch_irq_work_raise(); +} + /* Enqueue on current CPU, work must already be claimed and preempt disabled */ static void __irq_work_queue_local(struct irq_work *work) { @@ -99,7 +111,7 @@ static void __irq_work_queue_local(struct irq_work *work) /* If the work is "lazy", handle it from next tick if any */ if (!lazy_work || tick_nohz_tick_stopped()) - arch_irq_work_raise(); + irq_work_raise(work); } /* Enqueue the irq work @work on the current CPU */ -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Guo Ren, Nicholas Piggin, H. Peter Anvin, Borislav Petkov, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller 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> Signed-off-by: Valentin Schneider <vschneid@redhat.com> [csky bits] Acked-by: Guo Ren <guoren@kernel.org> --- arch/alpha/kernel/smp.c | 2 +- arch/arc/kernel/smp.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm/mach-actions/platsmp.c | 2 ++ arch/arm64/kernel/smp.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/hexagon/kernel/smp.c | 2 +- arch/ia64/kernel/smp.c | 4 ++-- arch/loongarch/include/asm/smp.h | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/rtlx-cmp.c | 2 ++ arch/openrisc/kernel/smp.c | 2 +- arch/parisc/kernel/smp.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 ++++-- arch/powerpc/kvm/book3s_hv.c | 3 +++ arch/powerpc/platforms/powernv/subcore.c | 2 ++ arch/riscv/kernel/smp.c | 4 ++-- arch/s390/kernel/smp.c | 2 +- arch/sh/kernel/smp.c | 2 +- arch/sparc/kernel/smp_32.c | 2 +- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kvm/svm/svm.c | 4 ++++ arch/x86/kvm/x86.c | 2 ++ arch/xtensa/kernel/smp.c | 2 +- include/linux/smp.h | 8 ++++++-- virt/kvm/kvm_main.c | 1 + 27 files changed, 47 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f4e20f75438f8..38637eb9eebd5 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -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()) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index ad93fe6e4b77d..409cfa4675b40 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -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); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 3b280d55c1c40..f216ac890b6f9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -745,7 +745,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); } diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c index f26618b435145..7b208e96fbb67 100644 --- a/arch/arm/mach-actions/platsmp.c +++ b/arch/arm/mach-actions/platsmp.c @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 937d2623e06ba..8d108edc4a89f 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -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); } diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 4b605aa2e1d65..fd7f81be16dd6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -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); } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 4ba93e59370c4..4e8bee25b8c68 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -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); } diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index e2cc59db86bc2..ea4f009a232b4 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -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. diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h index 3dd172d9ffea0..99f6f6d51d33a 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); * 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) { loongson_send_ipi_single(cpu, SMP_RESCHEDULE); } diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca7..9806e79895d99 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -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 */ diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index d26dcc4b46e74..e991cc936c1cd 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -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) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index e1419095a6f0a..0a7a059e2dff4 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -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); } diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 7dbd92cafae38..b7fc859fa87db 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -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) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 0da6e59161cd4..11cfa76fd3699 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -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) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 6ba68dd6190bd..3b70b5f80bd56 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -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" diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c index 7e98b00ea2e84..c53c4c7977680 100644 --- a/arch/powerpc/platforms/powernv/subcore.c +++ b/arch/powerpc/platforms/powernv/subcore.c @@ -20,6 +20,8 @@ #include <asm/opal.h> #include <asm/smp.h> +#include <trace/events/ipi.h> + #include "subcore.h" #include "powernv.h" diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 760a64518c585..213602e89a8b2 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -235,8 +235,8 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } -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); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 0031325ce4bc9..6c4da1e26e568 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -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); } diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 65924d9ec2459..5cf35a774dc70 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -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); } diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index ad8094d955eba..87eaa7719fa27 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -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 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index a55295d1b9244..e5964d1d8b37d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -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()); diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a73bced40e241..5ff5815149bd3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -99,7 +99,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); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a5676..cfc622d8fc2d8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -26,6 +26,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> @@ -40,6 +41,9 @@ #include <asm/fpu/api.h> #include <asm/virtext.h> + +#include <trace/events/ipi.h> + #include "trace.h" #include "svm.h" diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd7966391..4c2baf8090bdc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -58,7 +58,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> diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214e..d95907b8e4d38 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -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); } diff --git a/include/linux/smp.h b/include/linux/smp.h index a80ab58ae3f1d..96836af927893 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -125,8 +125,12 @@ 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); +#define smp_send_reschedule(cpu) ({ \ + /* XXX scheduler_ipi is inline :/ */ \ + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ + arch_smp_send_reschedule(cpu); \ +}) /* * Prepare machine for booting other CPUs. diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fab4d37905785..a1fc2c947edfe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -62,6 +62,7 @@ #include "kvm_mm.h" #include "vfio.h" +#include <trace/events/ipi.h> #define CREATE_TRACE_POINTS #include <trace/events/kvm.h> -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() 2022-12-02 15:58 ` Valentin Schneider ` (5 preceding siblings ...) (?) @ 2023-01-08 12:17 ` Huacai Chen -1 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel, linux-parisc, Daniel Bristot de Oliveira, Marcelo Tosatti, linux-kernel, linux-alpha, linuxppc-dev, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-08 12:17 ` Huacai Chen 0 siblings, 0 replies; 90+ messages in thread From: Huacai Chen @ 2023-01-08 12:17 UTC (permalink / raw) To: Valentin Schneider Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller Hi, Valentin, On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: > > 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> > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > [csky bits] > Acked-by: Guo Ren <guoren@kernel.org> > --- > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 2 +- > arch/arm/mach-actions/platsmp.c | 2 ++ > arch/arm64/kernel/smp.c | 2 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 ++ > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 ++-- > arch/powerpc/kernel/smp.c | 6 ++++-- > arch/powerpc/kvm/book3s_hv.c | 3 +++ > arch/powerpc/platforms/powernv/subcore.c | 2 ++ > arch/riscv/kernel/smp.c | 4 ++-- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++++ > arch/x86/kvm/x86.c | 2 ++ > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 ++++++-- > virt/kvm/kvm_main.c | 1 + > 27 files changed, 47 insertions(+), 25 deletions(-) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f4e20f75438f8..38637eb9eebd5 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -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()) > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index ad93fe6e4b77d..409cfa4675b40 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -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); > } > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3b280d55c1c40..f216ac890b6f9 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -745,7 +745,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); > } > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index f26618b435145..7b208e96fbb67 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -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 > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 937d2623e06ba..8d108edc4a89f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -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); > } > diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c > index 4b605aa2e1d65..fd7f81be16dd6 100644 > --- a/arch/csky/kernel/smp.c > +++ b/arch/csky/kernel/smp.c > @@ -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); > } > diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c > index 4ba93e59370c4..4e8bee25b8c68 100644 > --- a/arch/hexagon/kernel/smp.c > +++ b/arch/hexagon/kernel/smp.c > @@ -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); > } > diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c > index e2cc59db86bc2..ea4f009a232b4 100644 > --- a/arch/ia64/kernel/smp.c > +++ b/arch/ia64/kernel/smp.c > @@ -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. > diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h > index 3dd172d9ffea0..99f6f6d51d33a 100644 > --- a/arch/loongarch/include/asm/smp.h > +++ b/arch/loongarch/include/asm/smp.h > @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); > * 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) > { > loongson_send_ipi_single(cpu, SMP_RESCHEDULE); > } This function has been moved to arch/loongarch/kernel/smp.c since 6.2. Huacai > diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h > index 5d9ff61004ca7..9806e79895d99 100644 > --- a/arch/mips/include/asm/smp.h > +++ b/arch/mips/include/asm/smp.h > @@ -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 */ > > diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c > index d26dcc4b46e74..e991cc936c1cd 100644 > --- a/arch/mips/kernel/rtlx-cmp.c > +++ b/arch/mips/kernel/rtlx-cmp.c > @@ -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) > diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c > index e1419095a6f0a..0a7a059e2dff4 100644 > --- a/arch/openrisc/kernel/smp.c > +++ b/arch/openrisc/kernel/smp.c > @@ -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); > } > diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c > index 7dbd92cafae38..b7fc859fa87db 100644 > --- a/arch/parisc/kernel/smp.c > +++ b/arch/parisc/kernel/smp.c > @@ -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) > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 0da6e59161cd4..11cfa76fd3699 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -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) > { > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 6ba68dd6190bd..3b70b5f80bd56 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -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" > > diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c > index 7e98b00ea2e84..c53c4c7977680 100644 > --- a/arch/powerpc/platforms/powernv/subcore.c > +++ b/arch/powerpc/platforms/powernv/subcore.c > @@ -20,6 +20,8 @@ > #include <asm/opal.h> > #include <asm/smp.h> > > +#include <trace/events/ipi.h> > + > #include "subcore.h" > #include "powernv.h" > > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 760a64518c585..213602e89a8b2 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -235,8 +235,8 @@ void smp_send_stop(void) > cpumask_pr_args(cpu_online_mask)); > } > > -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); > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > index 0031325ce4bc9..6c4da1e26e568 100644 > --- a/arch/s390/kernel/smp.c > +++ b/arch/s390/kernel/smp.c > @@ -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); > } > diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c > index 65924d9ec2459..5cf35a774dc70 100644 > --- a/arch/sh/kernel/smp.c > +++ b/arch/sh/kernel/smp.c > @@ -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); > } > diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c > index ad8094d955eba..87eaa7719fa27 100644 > --- a/arch/sparc/kernel/smp_32.c > +++ b/arch/sparc/kernel/smp_32.c > @@ -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 > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index a55295d1b9244..e5964d1d8b37d 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -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()); > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index a73bced40e241..5ff5815149bd3 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -99,7 +99,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); > } > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ce362e88a5676..cfc622d8fc2d8 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -26,6 +26,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> > @@ -40,6 +41,9 @@ > #include <asm/fpu/api.h> > > #include <asm/virtext.h> > + > +#include <trace/events/ipi.h> > + > #include "trace.h" > > #include "svm.h" > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2835bd7966391..4c2baf8090bdc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -58,7 +58,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> > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214e..d95907b8e4d38 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c > @@ -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); > } > diff --git a/include/linux/smp.h b/include/linux/smp.h > index a80ab58ae3f1d..96836af927893 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -125,8 +125,12 @@ 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); > +#define smp_send_reschedule(cpu) ({ \ > + /* XXX scheduler_ipi is inline :/ */ \ > + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); \ > + arch_smp_send_reschedule(cpu); \ > +}) > > /* > * Prepare machine for booting other CPUs. > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fab4d37905785..a1fc2c947edfe 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -62,6 +62,7 @@ > #include "kvm_mm.h" > #include "vfio.h" > > +#include <trace/events/ipi.h> > #define CREATE_TRACE_POINTS > #include <trace/events/kvm.h> > > -- > 2.31.1 > > ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() 2023-01-08 12:17 ` Huacai Chen ` (4 preceding siblings ...) (?) @ 2023-01-09 19:01 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: Juri Lelli, Mark Rutland, linux-ia64, linux-sh, Peter Zijlstra, Sebastian Andrzej Siewior, Dave Hansen, linux-mips, Guo Ren, H. Peter Anvin, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, Russell King, linux-csky, Ingo Molnar, linux-snps-arc, linux-xtensa, Paul E. McKenney, Frederic Weisbecker, Steven Rostedt, openrisc, Borislav Petkov, Nicholas Piggin, loongarch, Thomas Gleixner, linux-arm-kernel, linux-parisc, Daniel Bristot de Oliveira, Marcelo Tosatti, linux-kernel, linux-alpha, linuxppc-dev, David S. Miller On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() @ 2023-01-09 19:01 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2023-01-09 19:01 UTC (permalink / raw) To: Huacai Chen Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, Guo Ren, Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, David S. Miller On 08/01/23 20:17, Huacai Chen wrote: > Hi, Valentin, > > On Fri, Dec 2, 2022 at 11:59 PM Valentin Schneider <vschneid@redhat.com> wrote: >> @@ -83,7 +83,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); >> * 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) >> { >> loongson_send_ipi_single(cpu, SMP_RESCHEDULE); >> } > This function has been moved to arch/loongarch/kernel/smp.c since 6.2. > Thanks! I'll make sure to rerun the coccinelle script for the next version. ^ permalink raw reply [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 7/8] smp: reword smp call IPI comment @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Accessing the call_single_queue hasn't involved a spinlock since 2014: 6897fc22ea01 ("kernel: use lockless list for smp_call_function_single") The llist operations (namely cmpxchg() and xchg()) provide similar ordering guarantees, update the comment to lessen confusion. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 93b4386cd3096..821b5986721ac 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -495,9 +495,10 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) #endif /* - * The list addition should be visible before sending the IPI - * handler locks the list to pull the entry off it because of - * normal cache coherency rules implied by spinlocks. + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI 2022-12-02 15:58 ` Valentin Schneider ` (3 preceding siblings ...) (?) @ 2022-12-02 15:58 ` Valentin Schneider -1 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Context ======= The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes ======= send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) == CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus == 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Context ======= The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes ======= send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) == CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus == 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Juri Lelli, Mark Rutland, Dave Hansen, Paul E. McKenney, Peter Zijlstra, Marc Zyngier, Sebastian Andrzej Siewior, Marcelo Tosatti, Russell King, Steven Rostedt, David S. Miller, Ingo Molnar, Borislav Petkov, Nicholas Piggin, H. Peter Anvin, Guo Ren, Thomas Gleixner, Daniel Bristot de Oliveira, Frederic Weisbecker Context ======= The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes ======= send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) == CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus == 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Context ======= The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes ======= send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) == CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus == 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Context ======= The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes ======= send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) == CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus == 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 90+ messages in thread
* [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI @ 2022-12-02 15:58 ` Valentin Schneider 0 siblings, 0 replies; 90+ messages in thread From: Valentin Schneider @ 2022-12-02 15:58 UTC (permalink / raw) To: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86 Cc: Paul E. McKenney, Steven Rostedt, Peter Zijlstra, Thomas Gleixner, Sebastian Andrzej Siewior, Juri Lelli, Daniel Bristot de Oliveira, Marcelo Tosatti, Frederic Weisbecker, Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin, Marc Zyngier, Mark Rutland, Russell King, Nicholas Piggin, Guo Ren, David S. Miller Context === The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter which so far has only been fed with NULL. While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing struct layout (meaning their callback func can be accessed without caring about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function attached to its struct. This means we need to check the type of a CSD before eventually dereferencing its associated callback. This isn't as trivial as it sounds: the CSD type is stored in __call_single_node.u_flags, which get cleared right before the callback is executed via csd_unlock(). This implies checking the CSD type before it is enqueued on the call_single_queue, as the target CPU's queue can be flushed before we get to sending an IPI. Furthermore, send_call_function_single_ipi() only has a CPU parameter, and would need to have an additional argument to trickle down the invoked function. This is somewhat silly, as the extra argument will always be pushed down to the function even when nothing is being traced, which is unnecessary overhead. Changes === send_call_function_single_ipi() is only used by smp.c, and is defined in sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of a CPU's idle task). Split it into two parts: the scheduler bits remain in sched/core.c, and the actual IPI emission is moved into smp.c. This lets us define an __always_inline helper function that can take the related callback as parameter without creating useless register pressure in the non-traced path which only gains a (disabled) static branch. Do the same thing for the multi IPI case. Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/sched/core.c | 18 +++++++----- kernel/sched/smp.h | 2 +- kernel/smp.c | 72 +++++++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 40587b0d99329..e59aac936dcb9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3743,16 +3743,20 @@ void sched_ttwu_pending(void *arg) rq_unlock_irqrestore(rq, &rf); } -void send_call_function_single_ipi(int cpu) +/* + * Prepare the scene for sending an IPI for a remote smp_call + * + * Returns true if the caller can proceed with sending the IPI. + * Returns false otherwise. + */ +bool call_function_single_prep_ipi(int cpu) { - struct rq *rq = cpu_rq(cpu); - - if (!set_nr_if_polling(rq->idle)) { - trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, NULL); - arch_send_call_function_single_ipi(cpu); - } else { + if (set_nr_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); + return false; } + + return true; } /* diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h index 2eb23dd0f2856..21ac44428bb02 100644 --- a/kernel/sched/smp.h +++ b/kernel/sched/smp.h @@ -6,7 +6,7 @@ extern void sched_ttwu_pending(void *arg); -extern void send_call_function_single_ipi(int cpu); +extern bool call_function_single_prep_ipi(int cpu); #ifdef CONFIG_SMP extern void flush_smp_call_function_queue(void); diff --git a/kernel/smp.c b/kernel/smp.c index 821b5986721ac..5cd680a7e78ef 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -161,9 +161,18 @@ void __init call_function_init(void) } static __always_inline void -send_call_function_ipi_mask(const struct cpumask *mask) +send_call_function_single_ipi(int cpu, smp_call_func_t func) { - trace_ipi_send_cpumask(mask, _RET_IP_, NULL); + if (call_function_single_prep_ipi(cpu)) { + trace_ipi_send_cpumask(cpumask_of(cpu), _RET_IP_, func); + arch_send_call_function_single_ipi(cpu); + } +} + +static __always_inline void +send_call_function_ipi_mask(const struct cpumask *mask, smp_call_func_t func) +{ + trace_ipi_send_cpumask(mask, _RET_IP_, func); arch_send_call_function_ipi_mask(mask); } @@ -430,12 +439,16 @@ static void __smp_call_single_queue_debug(int cpu, struct llist_node *node) struct cfd_seq_local *seq = this_cpu_ptr(&cfd_seq_local); struct call_function_data *cfd = this_cpu_ptr(&cfd_data); struct cfd_percpu *pcpu = per_cpu_ptr(cfd->pcpu, cpu); + struct __call_single_data *csd; + + csd = container_of(node, call_single_data_t, node.llist); + WARN_ON_ONCE(!(CSD_TYPE(csd) & (CSD_TYPE_SYNC | CSD_TYPE_ASYNC))); cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); if (llist_add(node, &per_cpu(call_single_queue, cpu))) { cfd_seq_store(pcpu->seq_ipi, this_cpu, cpu, CFD_SEQ_IPI); cfd_seq_store(seq->ping, this_cpu, cpu, CFD_SEQ_PING); - send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu, csd->func); cfd_seq_store(seq->pinged, this_cpu, cpu, CFD_SEQ_PINGED); } else { cfd_seq_store(pcpu->seq_noipi, this_cpu, cpu, CFD_SEQ_NOIPI); @@ -477,6 +490,25 @@ static __always_inline void csd_unlock(struct __call_single_data *csd) smp_store_release(&csd->node.u_flags, 0); } +static __always_inline void +raw_smp_call_single_queue(int cpu, struct llist_node *node, smp_call_func_t func) +{ + /* + * The list addition should be visible to the target CPU when it pops + * the head of the list to pull the entry off it in the IPI handler + * because of normal cache coherency rules implied by the underlying + * llist ops. + * + * If IPIs can go out of order to the cache coherency protocol + * in an architecture, sufficient synchronisation should be added + * to arch code to make it appear to obey cache coherency WRT + * locking and barrier primitives. Generic code isn't really + * equipped to do the right thing... + */ + if (llist_add(node, &per_cpu(call_single_queue, cpu))) + send_call_function_single_ipi(cpu, func); +} + static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); void __smp_call_single_queue(int cpu, struct llist_node *node) @@ -493,21 +525,25 @@ void __smp_call_single_queue(int cpu, struct llist_node *node) } } #endif - /* - * The list addition should be visible to the target CPU when it pops - * the head of the list to pull the entry off it in the IPI handler - * because of normal cache coherency rules implied by the underlying - * llist ops. - * - * If IPIs can go out of order to the cache coherency protocol - * in an architecture, sufficient synchronisation should be added - * to arch code to make it appear to obey cache coherency WRT - * locking and barrier primitives. Generic code isn't really - * equipped to do the right thing... + * We have to check the type of the CSD before queueing it, because + * once queued it can have its flags cleared by + * flush_smp_call_function_queue() + * even if we haven't sent the smp_call IPI yet (e.g. the stopper + * executes migration_cpu_stop() on the remote CPU). */ - if (llist_add(node, &per_cpu(call_single_queue, cpu))) - send_call_function_single_ipi(cpu); + if (trace_ipi_send_cpumask_enabled()) { + call_single_data_t *csd; + smp_call_func_t func; + + csd = container_of(node, call_single_data_t, node.llist); + func = CSD_TYPE(csd) = CSD_TYPE_TTWU ? + sched_ttwu_pending : csd->func; + + raw_smp_call_single_queue(cpu, node, func); + } else { + raw_smp_call_single_queue(cpu, node, NULL); + } } /* @@ -976,9 +1012,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask, * provided mask. */ if (nr_cpus = 1) - send_call_function_single_ipi(last_cpu); + send_call_function_single_ipi(last_cpu, func); else if (likely(nr_cpus > 1)) - send_call_function_ipi_mask(cfd->cpumask_ipi); + send_call_function_ipi_mask(cfd->cpumask_ipi, func); cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->pinged, this_cpu, CFD_SEQ_NOCPU, CFD_SEQ_PINGED); } -- 2.31.1 ^ permalink raw reply related [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint 2022-12-02 15:58 ` Valentin Schneider ` (4 preceding siblings ...) (?) @ 2022-12-13 16:18 ` Palmer Dabbelt -1 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa, Marc Zyngier, mark.rutland, linux, npiggin, guoren, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: juri.lelli, mark.rutland, linux-ia64, linux-sh, peterz, bigeasy, dave.hansen, linux-mips, guoren, hpa, sparclinux, linux-riscv, linux-s390, Marc Zyngier, linux-hexagon, x86, linux, linux-csky, mingo, linux-snps-arc, linux-xtensa, paulmck, frederic, rostedt, openrisc, bp, npiggin, loongarch, tglx, linux-arm-kernel, linux-parisc, bristot, mtosatti, linux-kernel, linux-alpha, linuxppc-dev, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa, Marc Zyngier, mark.rutland, linux, npiggin, guoren, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa, Marc Zyngier, mark.rutland, linux, npiggin, guoren, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa, Marc Zyngier, mark.rutland, linux, npiggin, guoren, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ===== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ========> > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ===> > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask\x14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ==> > [1]: https://youtu.be/5gT57y4OzBM?t\x14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ====> > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [PATCH v3 0/8] Generic IPI sending tracepoint @ 2022-12-13 16:18 ` Palmer Dabbelt 0 siblings, 0 replies; 90+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:18 UTC (permalink / raw) To: vschneid Cc: linux-alpha, linux-kernel, linux-snps-arc, linux-arm-kernel, linux-csky, linux-hexagon, linux-ia64, loongarch, linux-mips, openrisc, linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux, linux-xtensa, x86, paulmck, rostedt, peterz, tglx, bigeasy, juri.lelli, bristot, mtosatti, frederic, mingo, bp, dave.hansen, hpa, Marc Zyngier, mark.rutland, linux, npiggin, guoren, davem On Fri, 02 Dec 2022 07:58:09 PST (-0800), vschneid@redhat.com wrote: > Background > ========== > > Detecting IPI *reception* is relatively easy, e.g. using > trace_irq_handler_{entry,exit} or even just function-trace > flush_smp_call_function_queue() for SMP calls. > > Figuring out their *origin*, is trickier as there is no generic tracepoint tied > to e.g. smp_call_function(): > > o AFAIA x86 has no tracepoint tied to sending IPIs, only receiving them > (cf. trace_call_function{_single}_entry()). > o arm/arm64 do have trace_ipi_raise(), which gives us the target cpus but also a > mostly useless string (smp_calls will all be "Function call interrupts"). > o Other architectures don't seem to have any IPI-sending related tracepoint. > > I believe one reason those tracepoints used by arm/arm64 ended up as they were > is because these archs used to handle IPIs differently from regular interrupts > (the IRQ driver would directly invoke an IPI-handling routine), which meant they > never showed up in trace_irq_handler_{entry, exit}. The trace_ipi_{entry,exit} > tracepoints gave a way to trace IPI reception but those have become redundant as > of: > > 56afcd3dbd19 ("ARM: Allow IPIs to be handled as normal interrupts") > d3afc7f12987 ("arm64: Allow IPIs to be handled as normal interrupts") > > which gave IPIs a "proper" handler function used through > generic_handle_domain_irq(), which makes them show up via > trace_irq_handler_{entry, exit}. > > Changing stuff up > ================= > > Per the above, it would make sense to reshuffle trace_ipi_raise() and move it > into generic code. This also came up during Daniel's talk on Osnoise at the CPU > isolation MC of LPC 2022 [1]. > > Now, to be useful, such a tracepoint needs to export: > o targeted CPU(s) > o calling context > > The only way to get the calling context with trace_ipi_raise() is to trigger a > stack dump, e.g. $(trace-cmd -e ipi* -T echo 42). > > This is instead introducing a new tracepoint which exports the relevant context > (callsite, and requested callback for when the callsite isn't helpful), and is > usable by all architectures as it sits in generic code. > > Another thing worth mentioning is that depending on the callsite, the _RET_IP_ > fed to the tracepoint is not always useful - generic_exec_single() doesn't tell > you much about the actual callback being sent via IPI, which is why the new > tracepoint also has a @callback argument. > > Patches > ======= > > o Patch 1 is included for convenience and will be merged independently. FYI I > have libtraceevent patches [2] to improve the > pretty-printing of cpumasks using the new type, which look like: > <...>-3322 [021] 560.402583: ipi_send_cpumask: cpumask=14,17,21 callsite=on_each_cpu_cond_mask+0x40 callback=flush_tlb_func+0x0 > <...>-187 [010] 562.590584: ipi_send_cpumask: cpumask=0-23 callsite=on_each_cpu_cond_mask+0x40 callback=do_sync_core+0x0 > > o Patches 2-6 spread out the tracepoint across relevant sites. > Patch 6 ends up sprinkling lots of #include <trace/events/ipi.h> which I'm not > the biggest fan of, but is the least horrible solution I've been able to come > up with so far. > > o Patch 8 is trying to be smart about tracing the callback associated with the > IPI. > > This results in having IPI trace events for: > > o smp_call_function*() > o smp_send_reschedule() > o irq_work_queue*() > o standalone uses of __smp_call_single_queue() > > This is incomplete, just looking at arm64 there's more IPI types that aren't > covered: > > IPI_CPU_STOP, > IPI_CPU_CRASH_STOP, > IPI_TIMER, > IPI_WAKEUP, > > ... But it feels like a good starting point. > > Links > ===== > > [1]: https://youtu.be/5gT57y4OzBM?t=14234 > [2]: https://lore.kernel.org/all/20221116144154.3662923-1-vschneid@redhat.com/ > > Revisions > ========= > > v2 -> v3 > ++++++++ > > o Dropped the generic export of smp_send_reschedule(), turned it into a macro > and a bunch of imports > o Dropped the send_call_function_single_ipi() macro madness, split it into sched > and smp bits using some of Peter's suggestions > > v1 -> v2 > ++++++++ > > o Ditched single-CPU tracepoint > o Changed tracepoint signature to include callback > o Changed tracepoint callsite field to void *; the parameter is still UL to save > up on casts due to using _RET_IP_. > o Fixed linking failures due to not exporting smp_send_reschedule() > > Steven Rostedt (Google) (1): > tracing: Add __cpumask to denote a trace event field that is a > cpumask_t > > Valentin Schneider (7): > trace: Add trace_ipi_send_cpumask() > sched, smp: Trace IPIs sent via send_call_function_single_ipi() > smp: Trace IPIs sent via arch_send_call_function_ipi_mask() > irq_work: Trace self-IPIs sent via arch_irq_work_raise() > treewide: Trace IPIs sent via smp_send_reschedule() > smp: reword smp call IPI comment > sched, smp: Trace smp callback causing an IPI > > arch/alpha/kernel/smp.c | 2 +- > arch/arc/kernel/smp.c | 2 +- > arch/arm/kernel/smp.c | 5 +- > arch/arm/mach-actions/platsmp.c | 2 + > arch/arm64/kernel/smp.c | 3 +- > arch/csky/kernel/smp.c | 2 +- > arch/hexagon/kernel/smp.c | 2 +- > arch/ia64/kernel/smp.c | 4 +- > arch/loongarch/include/asm/smp.h | 2 +- > arch/mips/include/asm/smp.h | 2 +- > arch/mips/kernel/rtlx-cmp.c | 2 + > arch/openrisc/kernel/smp.c | 2 +- > arch/parisc/kernel/smp.c | 4 +- > arch/powerpc/kernel/smp.c | 6 +- > arch/powerpc/kvm/book3s_hv.c | 3 + > arch/powerpc/platforms/powernv/subcore.c | 2 + > arch/riscv/kernel/smp.c | 4 +- > arch/s390/kernel/smp.c | 2 +- > arch/sh/kernel/smp.c | 2 +- > arch/sparc/kernel/smp_32.c | 2 +- > arch/sparc/kernel/smp_64.c | 2 +- > arch/x86/include/asm/smp.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 + > arch/x86/kvm/x86.c | 2 + > arch/xtensa/kernel/smp.c | 2 +- > include/linux/smp.h | 8 +- > include/trace/bpf_probe.h | 6 ++ > include/trace/events/ipi.h | 22 ++++++ > include/trace/perf.h | 6 ++ > include/trace/stages/stage1_struct_define.h | 6 ++ > include/trace/stages/stage2_data_offsets.h | 6 ++ > include/trace/stages/stage3_trace_output.h | 6 ++ > include/trace/stages/stage4_event_fields.h | 6 ++ > include/trace/stages/stage5_get_offsets.h | 6 ++ > include/trace/stages/stage6_event_callback.h | 20 +++++ > include/trace/stages/stage7_class_define.h | 2 + > kernel/irq_work.c | 14 +++- > kernel/sched/core.c | 19 +++-- > kernel/sched/smp.h | 2 +- > kernel/smp.c | 78 ++++++++++++++++---- > samples/trace_events/trace-events-sample.c | 2 +- > samples/trace_events/trace-events-sample.h | 34 +++++++-- > virt/kvm/kvm_main.c | 1 + > 43 files changed, 250 insertions(+), 61 deletions(-) Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # riscv ^ permalink raw reply [flat|nested] 90+ messages in thread
end of thread, other threads:[~2023-01-09 19:03 UTC | newest] Thread overview: 90+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-12-02 15:58 [PATCH v3 0/8] Generic IPI sending tracepoint Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_t Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 1/8] DO-NOT-MERGE: tracing: Add __cpumask to denote a trace event field that is a cpumask_ Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 2/8] trace: Add trace_ipi_send_cpumask() Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 3/8] sched, smp: Trace IPIs sent via send_call_function_single_ipi() Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-07 11:04 ` Ingo Molnar 2023-01-09 19:02 ` Valentin Schneider 2023-01-09 19:02 ` Valentin Schneider 2023-01-09 19:02 ` Valentin Schneider 2023-01-09 19:02 ` Valentin Schneider 2023-01-09 19:02 ` Valentin Schneider 2023-01-09 19:02 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 4/8] smp: Trace IPIs sent via arch_send_call_function_ipi_mask() Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 5/8] irq_work: Trace self-IPIs sent via arch_irq_work_raise() Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 6/8] treewide: Trace IPIs sent via smp_send_reschedule() Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-08 12:17 ` Huacai Chen 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2023-01-09 19:01 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 7/8] smp: reword smp call IPI comment Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` [PATCH v3 8/8] sched, smp: Trace smp callback causing an IPI Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-02 15:58 ` Valentin Schneider 2022-12-13 16:18 ` [PATCH v3 0/8] Generic IPI sending tracepoint Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt 2022-12-13 16:18 ` Palmer Dabbelt
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.