tracing/arm/arm64: Basic IPI tracing
Subsystems (4)
Steven Rostedt
maintainerLinus,
Nicolas Pitre added generic tracepoints for tracing IPIs and updated the arm and arm64 architectures. It required some minor updates to the generic tracepoint system, so it had to wait for me to implement them.
I know this is a little late in the merge window, but Nicolas had these out for a while, and my going on vacation prevented them from getting in earlier.
I've ran them through all my tests, and uploaded them to korg to make sure they pass Wu's tests as well.
Please pull the latest trace-ipi-tracepoints tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-ipi-tracepoints
Tag SHA1: 648c6f8edfeede5fb34aa6307e0944b33aa24c43 Head SHA1: 45ed695ac10a23cb4e60a3e0b68b3f21a8670670
Nicolas Pitre (3):
tracepoint: add generic tracepoint definitions for IPI tracing
ARM: add IPI tracepoints
ARM64: add IPI tracepoints
Steven Rostedt (1):
tracing: Do not do anything special with tracepoint_string when tracing is disabled
----
arch/arm/kernel/smp.c | 70 ++++++++++++++++++++-------------- arch/arm64/kernel/smp.c | 65 +++++++++++++++++++------------- include/linux/ftrace_event.h | 34 ----------------- include/linux/tracepoint.h | 44 ++++++++++++++++++++++ include/trace/events/ipi.h | 89 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 214 insertions(+), 88 deletions(-)
Steven Rostedt
maintainerPATCH 1/4 tracing: Do not do anything special with tracepoint_string when tracing is disabled
From: Steven Rostedt <[email protected]>
When CONFIG_TRACING is not enabled, there's no reason to save the trace strings either by the linker or as a static variable that can be referenced later. Simply pass back the string that is given to tracepoint_string().
Had to move the define to include/linux/tracepoint.h so that it is still visible when CONFIG_TRACING is not set.
--- include/linux/ftrace_event.h | 34 ---------------------------------- include/linux/tracepoint.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 34 deletions(-)
include/linux/ftrace_event.h +0 -34
@@ -574,40 +574,6 @@ do { \ __trace_printk(ip, fmt, ##args); \ } while (0) -/** -* tracepoint_string - register constant persistent string to trace system -* @str - a constant persistent string that will be referenced in tracepoints -* -* If constant strings are being used in tracepoints, it is faster and -* more efficient to just save the pointer to the string and reference -* that with a printf "%s" instead of saving the string in the ring buffer -* and wasting space and time. -* -* The problem with the above approach is that userspace tools that read -* the binary output of the trace buffers do not have access to the string. -* Instead they just show the address of the string which is not very -* useful to users. -* -* With tracepoint_string(), the string will be registered to the tracing -* system and exported to userspace via the debugfs/tracing/printk_formats -* file that maps the string address to the string text. This way userspace -* tools that read the binary buffers have a way to map the pointers to -* the ASCII strings they represent. -* -* The @str used must be a constant string and persistent as it would not -* make sense to show a string that no longer exists. But it is still fine -* to be used with modules, because when modules are unloaded, if they -* had tracepoints, the ring buffers are cleared too. As long as the string -* does not change during the life of the module, it is fine to use -* tracepoint_string() within a module. -*/ -#define tracepoint_string (str) \ - ({ \ - static const char *___tp_str __tracepoint_string = str; \ - ___tp_str; \ - }) -#define __tracepoint_string __attribute__((section("__tracepoint_str"))) -#ifdef CONFIG_PERF_EVENTS struct perf_event ;
include/linux/tracepoint.h +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.0.1
Steven Rostedt
maintainerPATCH 2/4 tracepoint: add generic tracepoint definitions for IPI tracing
In reply to Steven RostedtFrom: Nicolas Pitre <[email protected]>
The Inter Processor Interrupt is used to make another processor do a specific action such as rescheduling tasks, signal a timer event or execute something in another CPU's context. IRQs are already traceable but IPIs were not. Tracing them is useful for monitoring IPI latency, or to verify when they are the source of CPU wake-ups with power management implications.
Three trace hooks are defined: ipi_raise, ipi_entry and ipi_exit. To make them portable, a string is used to identify them and correlate related events. Additionally, ipi_raise records a bitmask representing targeted CPUs.
--- include/trace/events/ipi.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 include/trace/events/ipi.h
include/trace/events/ipi.h new file +89 -0
@@ -0,0 +1,89 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ipi + +#if !defined(_TRACE_IPI_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_IPI_H + +#include <linux/tracepoint.h> + +/** +* ipi_raise - called when a smp cross call is made +* +* @mask: mask of recipient CPUs for the IPI +* @reason: string identifying the IPI purpose +* +* It is necessary for @reason to be a static string declared with +* __tracepoint_string. +*/ +TRACE_EVENT (ipi_raise, + + TP_PROTO(const struct cpumask *mask, const char *reason), + +TP_ARGS (mask, reason), + +TP_STRUCT__entry ( + __bitmask(target_cpus, nr_cpumask_bits) + __field(const char *, reason) + ), + +TP_fast_assign ( + __assign_bitmask(target_cpus, cpumask_bits(mask), nr_cpumask_bits); + __entry->reason = reason; + ), + +TP_printk ("target_mask=%s (%s)" ,__get_bitmask (target_cpus), __entry->reason) +); + +DECLARE_EVENT_CLASS (ipi_handler, + + TP_PROTO(const char *reason), + +TP_ARGS (reason), + +TP_STRUCT__entry ( + __field(const char *, reason) + ), + +TP_fast_assign ( + __entry->reason = reason; + ), + +TP_printk ("(%s)" , __entry->reason) +); + +/** +* ipi_entry - called immediately before the IPI handler +* +* @reason: string identifying the IPI purpose +* +* It is necessary for @reason to be a static string declared with +* __tracepoint_string, ideally the same as used with trace_ipi_raise +* for that IPI. +*/ +DEFINE_EVENT (ipi_handler, ipi_entry, + + TP_PROTO(const char *reason), + +TP_ARGS (reason) +); + +/** +* ipi_exit - called immediately after the IPI handler returns +* +* @reason: string identifying the IPI purpose +* +* It is necessary for @reason to be a static string declared with +* __tracepoint_string, ideally the same as used with trace_ipi_raise for +* that IPI. +*/ +DEFINE_EVENT (ipi_handler, ipi_exit, + + TP_PROTO(const char *reason), + +TP_ARGS (reason) +); + +#endif /* _TRACE_IPI_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>
Signature · 1 line
2.0.1
Steven Rostedt
maintainerPATCH 3/4 ARM: add IPI tracepoints
In reply to Steven RostedtFrom: Nicolas Pitre <[email protected]>
The strings used to list IPIs in /proc/interrupts are reused for tracing purposes.
While at it, prevent a negative ipinr from escaping the range check in handle_IPI().
--- arch/arm/kernel/smp.c | 70 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 28 deletions(-)
arch/arm/kernel/smp.c +42 -28
@@ -47,6 +47,9 @@#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
@@ -430,38 +433,15 @@ void __init smp_prepare_cpus(unsigned int max_cpus) } } -static void (*smp_cross_call)(const struct cpumask *,unsigned int ); +static void (*__smp_cross_call)(const struct cpumask *,unsigned int );void __init set_smp_cross_call (void (*fn)(const struct cpumask *,unsigned int )) { -if (!smp_cross_call) - smp_cross_call = fn; -} - -void arch_send_call_function_ipi_mask (const struct cpumask *mask) -{ -smp_cross_call (mask,IPI_CALL_FUNC ); -} - -void arch_send_wakeup_ipi_mask (const struct cpumask *mask) -{ -smp_cross_call (mask,IPI_WAKEUP ); -} - -void arch_send_call_function_single_ipi (int cpu) -{ -smp_cross_call (cpumask_of (cpu),IPI_CALL_FUNC_SINGLE ); +if (!__smp_cross_call) + __smp_cross_call = fn; } -#ifdef CONFIG_IRQ_WORK -void arch_irq_work_raise (void ) -{ -if (is_smp ()) -smp_cross_call (cpumask_of (smp_processor_id ()),IPI_IRQ_WORK ); -} -#endif - -static const char *ipi_types[NR_IPI ] = { +static const char *ipi_types[NR_IPI] __tracepoint_string = { #define S(x,s) [x] = sS (IPI_WAKEUP ,"CPU wakeup interrupts" ),S (IPI_TIMER ,"Timer broadcast interrupts" ),
@@ -473,6 +453,12 @@ static const char *ipi_types[NR_IPI] = { S(IPI_COMPLETION, "completion interrupts"), }; +static void smp_cross_call (const struct cpumask *target,unsigned int ipinr) +{ +trace_ipi_raise (target, ipi_types[ipinr]); +__smp_cross_call (target, ipinr); +} +void show_ipi_list (struct seq_file *p,int prec) {unsigned int cpu, i;
@@ -499,6 +485,29 @@ u64 smp_irq_stat_cpu(unsigned int cpu)return sum; } +void arch_send_call_function_ipi_mask (const struct cpumask *mask) +{ +smp_cross_call (mask,IPI_CALL_FUNC ); +} + +void arch_send_wakeup_ipi_mask (const struct cpumask *mask) +{ +smp_cross_call (mask,IPI_WAKEUP ); +} + +void arch_send_call_function_single_ipi (int cpu) +{ +smp_cross_call (cpumask_of (cpu),IPI_CALL_FUNC_SINGLE ); +} + +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise (void ) +{ +if (is_smp ()) +smp_cross_call (cpumask_of (smp_processor_id ()),IPI_IRQ_WORK ); +} +#endif +#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST void tick_broadcast (const struct cpumask *mask) {
@@ -556,8 +565,10 @@ void handle_IPI(int ipinr, struct pt_regs *regs)unsigned int cpu =smp_processor_id ();struct pt_regs *old_regs =set_irq_regs (regs); -if (ipinr <NR_IPI ) +if ((unsigned )ipinr <NR_IPI ) { +trace_ipi_entry (ipi_types[ipinr]);__inc_irq_stat (cpu, ipi_irqs[ipinr]); + }switch (ipinr) {case IPI_WAKEUP :
@@ -612,6 +623,9 @@ void handle_IPI(int ipinr, struct pt_regs *regs) cpu, ipinr);break ; } + +if ((unsigned )ipinr <NR_IPI ) +trace_ipi_exit (ipi_types[ipinr]);set_irq_regs (old_regs); }
Signature · 1 line
2.0.1
Steven Rostedt
maintainerPATCH 4/4 ARM64: add IPI tracepoints
In reply to Steven RostedtFrom: Nicolas Pitre <[email protected]>
The strings used to list IPIs in /proc/interrupts are reused for tracing purposes.
While at it, the code is slightly cleaned up so the ipi_types array indices are no longer offset by IPI_RESCHEDULE whose value is 0 anyway.
--- arch/arm64/kernel/smp.c | 65 +++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 26 deletions(-)
arch/arm64/kernel/smp.c +39 -26
@@ -50,6 +50,9 @@#include <asm/tlbflush.h> #include <asm/ptrace.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
@@ -307,8 +310,6 @@ void __init smp_prepare_boot_cpu(void)set_my_cpu_offset (per_cpu_offset (smp_processor_id ())); } -static void (*smp_cross_call)(const struct cpumask *,unsigned int ); -/* * Enumerate the possible CPU set from the device tree and build the * cpu logical map array containing MPIDR values related to logical
@@ -463,32 +464,15 @@ void __init smp_prepare_cpus(unsigned int max_cpus) } } +static void (*__smp_cross_call)(const struct cpumask *,unsigned int );void __init set_smp_cross_call (void (*fn)(const struct cpumask *,unsigned int )) { - smp_cross_call = fn; + __smp_cross_call = fn; } -void arch_send_call_function_ipi_mask (const struct cpumask *mask) -{ -smp_cross_call (mask,IPI_CALL_FUNC ); -} - -void arch_send_call_function_single_ipi (int cpu) -{ -smp_cross_call (cpumask_of (cpu),IPI_CALL_FUNC_SINGLE ); -} - -#ifdef CONFIG_IRQ_WORK -void arch_irq_work_raise (void ) -{ -if (smp_cross_call) -smp_cross_call (cpumask_of (smp_processor_id ()),IPI_IRQ_WORK ); -} -#endif - -static const char *ipi_types[NR_IPI ] = { -#define S(x,s) [x - IPI_RESCHEDULE] = s +static const char *ipi_types[NR_IPI] __tracepoint_string = { +#define S(x,s) [x] = sS (IPI_RESCHEDULE ,"Rescheduling interrupts" ),S (IPI_CALL_FUNC ,"Function call interrupts" ),S (IPI_CALL_FUNC_SINGLE ,"Single function call interrupts" ),
@@ -497,12 +481,18 @@ static const char *ipi_types[NR_IPI] = { S(IPI_IRQ_WORK, "IRQ work interrupts"), }; +static void smp_cross_call (const struct cpumask *target,unsigned int ipinr) +{ +trace_ipi_raise (target, ipi_types[ipinr]); +__smp_cross_call (target, ipinr); +} +void show_ipi_list (struct seq_file *p,int prec) {unsigned int cpu, i;for (i =0 ; i <NR_IPI ; i++) { -seq_printf (p,"%*s%u:%s" , prec -1 ,"IPI" , i +IPI_RESCHEDULE , +seq_printf (p,"%*s%u:%s" , prec -1 ,"IPI" , i, prec >=4 ?" " :"" );for_each_online_cpu (cpu) seq_printf(p, "%10u ",
@@ -522,6 +512,24 @@ u64 smp_irq_stat_cpu(unsigned int cpu)return sum; } +void arch_send_call_function_ipi_mask (const struct cpumask *mask) +{ +smp_cross_call (mask,IPI_CALL_FUNC ); +} + +void arch_send_call_function_single_ipi (int cpu) +{ +smp_cross_call (cpumask_of (cpu),IPI_CALL_FUNC_SINGLE ); +} + +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise (void ) +{ +if (__smp_cross_call) +smp_cross_call (cpumask_of (smp_processor_id ()),IPI_IRQ_WORK ); +} +#endif +static DEFINE_RAW_SPINLOCK (stop_lock);/*
@@ -553,8 +561,10 @@ void handle_IPI(int ipinr, struct pt_regs *regs)unsigned int cpu =smp_processor_id ();struct pt_regs *old_regs =set_irq_regs (regs); -if (ipinr >=IPI_RESCHEDULE && ipinr <IPI_RESCHEDULE +NR_IPI ) -__inc_irq_stat (cpu, ipi_irqs[ipinr -IPI_RESCHEDULE ]); +if ((unsigned )ipinr <NR_IPI ) { +trace_ipi_entry (ipi_types[ipinr]); +__inc_irq_stat (cpu, ipi_irqs[ipinr]); + }switch (ipinr) {case IPI_RESCHEDULE :
@@ -599,6 +609,9 @@ void handle_IPI(int ipinr, struct pt_regs *regs)pr_crit ("CPU%u: Unknown IPI message 0x%x\n" , cpu, ipinr);break ; } + +if ((unsigned )ipinr <NR_IPI ) +trace_ipi_exit (ipi_types[ipinr]);set_irq_regs (old_regs); }
Signature · 1 line
2.0.1