git pull request for tip/tracing/core
Subsystems (4)
Steven Rostedt
maintainercover git pull request for tip/tracing/core
Ingo,
I rebased the previous changes onto tip/tracing/core. The first patch is new, which is the elimination of the entry->cpu.
I did not remove it when it became obsolete, and thus we had other developers using it, thinking that it was the way to get the current cpu number. Unfortunately, the entry->cpu was just taking up space, and never was initialized.
The rest of the patches, I've posted before, but this time I ported them over to tip/tracing/core.
The following patches are in:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
branch: tip/tracing/core/devel
Steven Rostedt (7):
trace: remove deprecated entry->cpu
ring-buffer: add NMI protection for spinlocks
ring-buffer: allow tracing_off to be used in core kernel code ftrace, x86: rename in_nmi variable
nmi: add generic nmi tracking state
ftrace: change function graph tracer to use new in_nmi
ring-buffer: use generic version of in_nmi
Wenji Huang (1):
trace: trivial fixes in comment typos.
----
arch/x86/Kconfig | 1 + arch/x86/kernel/ftrace.c | 35 ++++++++--------------------------- include/linux/ftrace.h | 2 +- include/linux/ftrace_irq.h | 2 +- include/linux/hardirq.h | 15 +++++++++++++++ include/linux/ring_buffer.h | 9 +++++++++ kernel/trace/Kconfig | 8 ++++++++ kernel/trace/ftrace.c | 6 +++--- kernel/trace/ring_buffer.c | 31 +++++++++++++++++++++++++++++-- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 7 +++---- kernel/trace/trace_hw_branches.c | 3 +-- kernel/trace/trace_output.c | 6 +++--- 13 files changed, 83 insertions(+), 44 deletions(-)
Steven Rostedt
maintainerPATCH 1/8 trace: remove deprecated entry->cpu
From: Steven Rostedt <[email protected]>
Impact: fix to prevent developers from using entry->cpu
With the new ring buffer infrastructure, the cpu for the entry is implicit with which CPU buffer it is on.
The original code use to record the current cpu into the generic entry header, which can be retrieved by entry->cpu. When the ring buffer was introduced, the users were convert to use the the cpu number of which cpu ring buffer was in use (this was passed to the tracers by the iterator: iter->cpu).
Unfortunately, the cpu item in the entry structure was never removed. This allowed for developers to use it instead of the proper iter->cpu, unknowingly, using an uninitialized variable. This was not the fault of the developers, since it would seem like the logical place to retrieve the cpu identifier.
This patch removes the cpu item from the entry structure and fixes all the users that should have been using iter->cpu.
--- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 1 - kernel/trace/trace_hw_branches.c | 3 +-- kernel/trace/trace_output.c | 6 +++--- 4 files changed, 5 insertions(+), 7 deletions(-)
kernel/trace/trace.c +1 -1
@@ -1531,7 +1531,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)if (trace_flags &TRACE_ITER_CONTEXT_INFO ) {SEQ_PUT_FIELD_RET (s, entry->pid); -SEQ_PUT_FIELD_RET (s, entry->cpu); +SEQ_PUT_FIELD_RET (s, iter->cpu);SEQ_PUT_FIELD_RET (s, iter->ts); }
kernel/trace/trace.h +0 -1
@@ -45,7 +45,6 @@ enum trace_type {*/ struct trace_entry {unsigned char type; -unsigned char cpu;unsigned char flags;unsigned char preempt_count;int pid;
kernel/trace/trace_hw_branches.c +1 -2
@@ -159,7 +159,7 @@ static enum print_line_t bts_trace_print_line(struct trace_iterator *iter)trace_assign_type (it, entry);if (entry->type ==TRACE_HW_BRANCHES ) { - if (trace_seq_printf(seq, "%4d ", entry->cpu) && + if (trace_seq_printf(seq, "%4d ", iter->cpu) && seq_print_ip_sym(seq, it->to, symflags) && trace_seq_printf(seq, "\t <- ") && seq_print_ip_sym(seq, it->from, symflags) &&
@@ -195,7 +195,6 @@ void trace_hw_branch(u64 from, u64 to) entry =ring_buffer_event_data (event);tracing_generic_entry_update (&entry->ent,0 , from); entry->ent.type =TRACE_HW_BRANCHES ; - entry->ent.cpu = cpu; entry->from = from; entry->to = to;ring_buffer_unlock_commit (tr->buffer, event, irq2);
kernel/trace/trace_output.c +3 -3
@@ -333,7 +333,7 @@ int trace_print_context(struct trace_iterator *iter)unsigned long secs = (unsigned long )t;return trace_seq_printf (s,"%16s-%-5d [%03d] %5lu.%06lu: " , - comm, entry->pid, entry->cpu, secs, usec_rem); + comm, entry->pid, iter->cpu, secs, usec_rem); }int trace_print_lat_context (struct trace_iterator *iter)
@@ -356,7 +356,7 @@ int trace_print_lat_context(struct trace_iterator *iter)char *comm =trace_find_cmdline (entry->pid); ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08lx]" " %ld.%03ldms (+%ld.%03ldms): ", comm, - entry->pid, entry->cpu, entry->flags, + entry->pid, iter->cpu, entry->flags, entry->preempt_count, iter->idx, ns2usecs(iter->ts), abs_usecs / USEC_PER_MSEC,
@@ -364,7 +364,7 @@ int trace_print_lat_context(struct trace_iterator *iter) rel_usecs /USEC_PER_MSEC , rel_usecs % USEC_PER_MSEC); }else { - ret =lat_print_generic (s, entry, entry->cpu); + ret =lat_print_generic (s, entry, iter->cpu);if (ret) ret =lat_print_timestamp (s, abs_usecs, rel_usecs); }
Signature · 3 lines
1.5.6.5 --
Re: [PATCH 1/8] trace: remove deprecated entry->cpu
Quoted 19 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Impact: fix to prevent developers from using
entry->cpuWith the new ring buffer infrastructure, the cpu for the entry is implicit with which CPU buffer it is on.
The original code use to record the current cpu into the generic entry header, which can be retrieved by
entry->cpu. When the ring buffer was introduced, the users were convert to use the the cpu number of which cpu ring buffer was in use (this was passed to the tracers by the iterator:iter->cpu).Unfortunately, the cpu item in the entry structure was never removed. This allowed for developers to use it instead of the proper
iter->cpu, unknowingly, using an uninitialized variable. This was not the fault of the developers, since it would seem like the logical place to retrieve the cpu identifier.
Quoted 4 lines
This patch removes the cpu item from the entry structure and fixes all the users that should have been using
iter->cpu.Signed-off-by Steven Rostedt <[email protected]>
Heh, we have sent the same patch at very few different hours... Funny :-)
Quoted 88 lines
--- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 1 - kernel/trace/trace_hw_branches.c | 3 +-- kernel/trace/trace_output.c | 6 +++--- 4 files changed, 5 insertions(+), 7 deletions(-)kernel/trace/trace.c +1
-1@@ -1531,7 +1531,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)if (trace_flags &TRACE_ITER_CONTEXT_INFO ) {SEQ_PUT_FIELD_RET (s, entry->pid); -SEQ_PUT_FIELD_RET (s, entry->cpu); +SEQ_PUT_FIELD_RET (s, iter->cpu);SEQ_PUT_FIELD_RET (s, iter->ts); }kernel/trace/trace.h +0
-1@@ -45,7 +45,6 @@ enum trace_type {*/ struct trace_entry {unsigned char type; -unsigned char cpu;unsigned char flags;unsigned char preempt_count;int pid;kernel/trace/trace_hw_branches.c +1
-2@@ -159,7 +159,7 @@ static enum print_line_t bts_trace_print_line(struct trace_iterator *iter)trace_assign_type (it, entry);if (entry->type ==TRACE_HW_BRANCHES ) { - if (trace_seq_printf(seq, "%4d ", entry->cpu) && + if (trace_seq_printf(seq, "%4d ", iter->cpu) && seq_print_ip_sym(seq, it->to, symflags) && trace_seq_printf(seq, "\t <- ") && seq_print_ip_sym(seq, it->from, symflags) &&@@ -195,7 +195,6 @@ void trace_hw_branch(u64 from, u64 to) entry =ring_buffer_event_data (event);tracing_generic_entry_update (&entry->ent,0 , from); entry->ent.type =TRACE_HW_BRANCHES ; - entry->ent.cpu = cpu; entry->from = from; entry->to = to;ring_buffer_unlock_commit (tr->buffer, event, irq2);kernel/trace/trace_output.c +3
-3@@ -333,7 +333,7 @@ int trace_print_context(struct trace_iterator *iter)unsigned long secs = (unsigned long )t;return trace_seq_printf (s,"%16s-%-5d [%03d] %5lu.%06lu: " , - comm, entry->pid, entry->cpu, secs, usec_rem); + comm, entry->pid, iter->cpu, secs, usec_rem); }int trace_print_lat_context (struct trace_iterator *iter)@@ -356,7 +356,7 @@ int trace_print_lat_context(struct trace_iterator *iter)char *comm =trace_find_cmdline (entry->pid); ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08lx]" " %ld.%03ldms (+%ld.%03ldms): ", comm, - entry->pid, entry->cpu, entry->flags, + entry->pid, iter->cpu, entry->flags, entry->preempt_count, iter->idx, ns2usecs(iter->ts), abs_usecs / USEC_PER_MSEC,@@ -364,7 +364,7 @@ int trace_print_lat_context(struct trace_iterator *iter) rel_usecs /USEC_PER_MSEC , rel_usecs % USEC_PER_MSEC); }else { - ret =lat_print_generic (s, entry, entry->cpu); + ret =lat_print_generic (s, entry, iter->cpu);if (ret) ret =lat_print_timestamp (s, abs_usecs, rel_usecs); }Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 2/8 ring-buffer: add NMI protection for spinlocks
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: prevent deadlock in NMI
The ring buffers are not yet totally lockless with writing to the buffer. When a writer crosses a page, it grabs a per cpu spinlock to protect against a reader. The spinlocks taken by a writer are not to protect against other writers, since a writer can only write to its own per cpu buffer. The spinlocks protect against readers that can touch any cpu buffer. The writers are made to be reentrant with the spinlocks disabling interrupts.
The problem arises when an NMI writes to the buffer, and that write crosses a page boundary. If it grabs a spinlock, it can be racing with another writer (since disabling interrupts does not protect against NMIs) or with a reader on the same CPU. Luckily, most of the users are not reentrant and protects against this issue. But if a user of the ring buffer becomes reentrant (which is what the ring buffers do allow), if the NMI also writes to the ring buffer then we risk the chance of a deadlock.
This patch moves the ftrace_nmi_enter called by nmi_enter() to the ring buffer code. It replaces the current ftrace_nmi_enter that is used by arch specific code to arch_ftrace_nmi_enter and updates the Kconfig to handle it.
When an NMI is called, it will set a per cpu variable in the ring buffer code and will clear it when the NMI exits. If a write to the ring buffer crosses page boundaries inside an NMI, a trylock is used on the spin lock instead. If the spinlock fails to be acquired, then the entry is discarded.
This bug appeared in the ftrace work in the RT tree, where event tracing is reentrant. This workaround solved the deadlocks that appeared there.
--- arch/x86/Kconfig | 1 + arch/x86/kernel/ftrace.c | 8 +++--- include/linux/ftrace_irq.h | 10 ++++++++- kernel/trace/Kconfig | 8 +++++++ kernel/trace/ring_buffer.c | 48 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 68 insertions(+), 7 deletions(-)
arch/x86/Kconfig +1 -0
@@ -34,6 +34,7 @@ config X86 select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACE_MCOUNT_TEST + select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE || FUNCTION_GRAPH_TRACER select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) select HAVE_ARCH_KGDB if !X86_VOYAGER select HAVE_ARCH_TRACEHOOK
arch/x86/kernel/ftrace.c +4 -4
@@ -113,7 +113,7 @@ static void ftrace_mod_code(void) MCOUNT_INSN_SIZE); } -void ftrace_nmi_enter (void ) +void arch_ftrace_nmi_enter (void ) {atomic_inc (&in_nmi);/* Must have in_nmi seen before reading write flag */
@@ -124,7 +124,7 @@ void ftrace_nmi_enter(void) } } -void ftrace_nmi_exit (void ) +void arch_ftrace_nmi_exit (void ) {/* Finish all executions before clearing in_nmi */ smp_wmb ();
@@ -376,12 +376,12 @@ int ftrace_disable_ftrace_graph_caller(void)*/ static atomic_t in_nmi; -void ftrace_nmi_enter (void ) +void arch_ftrace_nmi_enter (void ) {atomic_inc (&in_nmi); } -void ftrace_nmi_exit (void ) +void arch_ftrace_nmi_exit (void ) {atomic_dec (&in_nmi); }
include/linux/ftrace_irq.h +9 -1
@@ -2,7 +2,15 @@#define _LINUX_FTRACE_IRQ_H -#if defined(CONFIG_DYNAMIC_FTRACE ) || defined(CONFIG_FUNCTION_GRAPH_TRACER ) +#ifdef CONFIG_FTRACE_NMI_ENTER +extern void arch_ftrace_nmi_enter (void ); +extern void arch_ftrace_nmi_exit (void ); +#else +static inline void arch_ftrace_nmi_enter (void ) { } +static inline void arch_ftrace_nmi_exit (void ) { } +#endif + +#ifdef CONFIG_RING_BUFFER extern void ftrace_nmi_enter (void );extern void ftrace_nmi_exit (void );#else
kernel/trace/Kconfig +8 -0
@@ -9,6 +9,9 @@ config USER_STACKTRACE_SUPPORT config NOP_TRACER bool +config HAVE_FTRACE_NMI_ENTER + bool + config HAVE_FUNCTION_TRACER bool
@@ -37,6 +40,11 @@ config TRACER_MAX_TRACE config RING_BUFFER bool +config FTRACE_NMI_ENTER + bool + depends on HAVE_FTRACE_NMI_ENTER + default y + config TRACING bool select DEBUG_FS
kernel/trace/ring_buffer.c +46 -2
78 lines not on this page · raw message
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 3/8 ring-buffer: allow tracing_off to be used in core kernel code
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
tracing_off() is the fastest way to stop recording to the ring buffers. This may be used in places like panic and die, just before the ftrace_dump is called.
This patch adds the appropriate CPP conditionals to make it a stub function when the ring buffer is not configured it.
--- include/linux/ring_buffer.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
include/linux/ring_buffer.h +9 -0
@@ -124,9 +124,18 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);u64 ring_buffer_time_stamp (int cpu);void ring_buffer_normalize_time_stamp (int cpu,u64 *ts); +/* +* The below functions are fine to use outside the tracing facility. +*/ +#ifdef CONFIG_RING_BUFFER void tracing_on (void );void tracing_off (void );void tracing_off_permanent (void ); +#else +static inline void tracing_on (void ) { } +static inline void tracing_off (void ) { } +static inline void tracing_off_permanent (void ) { } +#endif void *ring_buffer_alloc_read_page (struct ring_buffer *buffer);void ring_buffer_free_read_page (struct ring_buffer *buffer,void *data);
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 4/8 ftrace, x86: rename in_nmi variable
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: clean up
The in_nmi variable in x86 arch ftrace.c is a misnomer. Andrew Morton pointed out that the in_nmi variable is incremented by all CPUS. It can be set when another CPU is running an NMI.
Since this is actually intentional, the fix is to rename it to what it really is: "nmi_running"
--- arch/x86/kernel/ftrace.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/kernel/ftrace.c +11 -11
@@ -82,7 +82,7 @@ static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)* are the same as what exists. */ -static atomic_t in_nmi =ATOMIC_INIT (0 ); +static atomic_t nmi_running =ATOMIC_INIT (0 );static int mod_code_status;/* holds return value of text write */ static int mod_code_write;/* set when NMI should do the write */ static void *mod_code_ip;/* holds the IP to write to */
@@ -115,8 +115,8 @@ static void ftrace_mod_code(void)void arch_ftrace_nmi_enter (void ) { -atomic_inc (&in_nmi); -/* Must have in_nmi seen before reading write flag */ +atomic_inc (&nmi_running); +/* Must have nmi_running seen before reading write flag */ smp_mb ();if (mod_code_write) {ftrace_mod_code ();
@@ -126,19 +126,19 @@ void arch_ftrace_nmi_enter(void)void arch_ftrace_nmi_exit (void ) { -/* Finish all executions before clearing in_nmi */ +/* Finish all executions before clearing nmi_running */ smp_wmb (); -atomic_dec (&in_nmi); +atomic_dec (&nmi_running); }static void wait_for_nmi (void ) { -if (!atomic_read (&in_nmi)) +if (!atomic_read (&nmi_running))return ;do {cpu_relax (); - }while (atomic_read (&in_nmi)); + }while (atomic_read (&nmi_running)); nmi_wait_count++; }
@@ -374,16 +374,16 @@ int ftrace_disable_ftrace_graph_caller(void)* this page for dynamic ftrace. They have been * simplified to ignore all traces in NMI context. */ -static atomic_t in_nmi; +static atomic_t nmi_running;void arch_ftrace_nmi_enter (void ) { -atomic_inc (&in_nmi); +atomic_inc (&nmi_running); }void arch_ftrace_nmi_exit (void ) { -atomic_dec (&in_nmi); +atomic_dec (&nmi_running); }#endif /* !CONFIG_DYNAMIC_FTRACE */
@@ -475,7 +475,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) &return_to_handler;/* Nmi's are currently unsupported */ -if (unlikely (atomic_read (&in_nmi))) +if (unlikely (atomic_read (&nmi_running)))return ;if (unlikely (atomic_read (¤t->tracing_graph_pause)))
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 5/8 nmi: add generic nmi tracking state
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
This code adds an in_nmi() macro that uses the current tasks preempt count to track when it is in NMI context. Other parts of the kernel can use this to determine if the context is in NMI context or not.
This code was inspired by the -rt patch in_nmi version that was written by Peter Zijlstra, who borrowed that code from Mathieu Desnoyers.
--- include/linux/hardirq.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
include/linux/hardirq.h +15 -0
@@ -61,6 +61,12 @@#error PREEMPT_ACTIVE is too low!#endif +#define NMI_OFFSET (PREEMPT_ACTIVE << 1) + +#if NMI_OFFSET >=0x80000000 +#error PREEMPT_ACTIVE too high! +#endif +#define hardirq_count () (preempt_count() & HARDIRQ_MASK)#define softirq_count () (preempt_count() & SOFTIRQ_MASK)#define irq_count () (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
@@ -73,6 +79,11 @@#define in_softirq () (softirq_count())#define in_interrupt () (irq_count()) +/* +* Are we in NMI context? +*/ +#define in_nmi () (preempt_count() & NMI_OFFSET) +#if defined(CONFIG_PREEMPT )# define PREEMPT_INATOMIC_BASE kernel_locked()# define PREEMPT_CHECK_OFFSET 1
@@ -167,6 +178,8 @@ extern void irq_exit(void);#define nmi_enter () \ do { \ ftrace_nmi_enter(); \ + BUG_ON(in_nmi()); \ + add_preempt_count(NMI_OFFSET); \ lockdep_off(); \ rcu_nmi_enter(); \ __irq_enter(); \
@@ -177,6 +190,8 @@ extern void irq_exit(void);__irq_exit (); \rcu_nmi_exit (); \lockdep_on (); \ +BUG_ON (!in_nmi ()); \ +sub_preempt_count (NMI_OFFSET ); \ftrace_nmi_exit (); \ }while (0 )
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 6/8 ftrace: change function graph tracer to use new in_nmi
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
The function graph tracer piggy backed onto the dynamic ftracer to use the in_nmi custom code for dynamic tracing. The problem was (as Andrew Morton pointed out) it really only wanted to bail out if the context of the current CPU was in NMI context. But the dynamic ftrace in_nmi custom code was true if _any_ CPU happened to be in NMI context.
Now that we have a generic in_nmi interface, this patch changes the function graph code to use it instead of the dynamic ftarce custom code.
--- arch/x86/Kconfig | 2 +- arch/x86/kernel/ftrace.c | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-)
arch/x86/Kconfig +1 -1
@@ -34,7 +34,7 @@ config X86 select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACE_MCOUNT_TEST - select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE || FUNCTION_GRAPH_TRACER + select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) select HAVE_ARCH_KGDB if !X86_VOYAGER select HAVE_ARCH_TRACEHOOK
arch/x86/kernel/ftrace.c +1 -20
@@ -367,25 +367,6 @@ int ftrace_disable_ftrace_graph_caller(void) return ftrace_mod_jmp(ip, old_offset, new_offset); } -#else /* CONFIG_DYNAMIC_FTRACE */ - -/* -* These functions are picked from those used on -* this page for dynamic ftrace. They have been -* simplified to ignore all traces in NMI context. -*/ -static atomic_t nmi_running; - -void arch_ftrace_nmi_enter (void ) -{ -atomic_inc (&nmi_running); -} - -void arch_ftrace_nmi_exit (void ) -{ -atomic_dec (&nmi_running); -} -#endif /* !CONFIG_DYNAMIC_FTRACE */ /* Add a function return address to the trace stack on thread info.*/
@@ -475,7 +456,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) &return_to_handler;/* Nmi's are currently unsupported */ -if (unlikely (atomic_read (&nmi_running))) +if (unlikely (in_nmi ()))return ;if (unlikely (atomic_read (¤t->tracing_graph_pause)))
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 7/8 ring-buffer: use generic version of in_nmi
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: clean up
Now that a generic in_nmi is available, this patch removes the special code in the ring_buffer and implements the in_nmi generic version instead.
With this change, I was also able to rename the "arch_ftrace_nmi_enter" back to "ftrace_nmi_enter" and remove the code from the ring buffer.
--- arch/x86/kernel/ftrace.c | 4 ++-- include/linux/ftrace_irq.h | 8 -------- kernel/trace/ring_buffer.c | 43 +++++++++++++------------------------------ 3 files changed, 15 insertions(+), 40 deletions(-)
arch/x86/kernel/ftrace.c +2 -2
@@ -113,7 +113,7 @@ static void ftrace_mod_code(void) MCOUNT_INSN_SIZE); } -void arch_ftrace_nmi_enter (void ) +void ftrace_nmi_enter (void ) {atomic_inc (&nmi_running);/* Must have nmi_running seen before reading write flag */
@@ -124,7 +124,7 @@ void arch_ftrace_nmi_enter(void) } } -void arch_ftrace_nmi_exit (void ) +void ftrace_nmi_exit (void ) {/* Finish all executions before clearing nmi_running */ smp_wmb ();
include/linux/ftrace_irq.h +0 -8
@@ -3,14 +3,6 @@#ifdef CONFIG_FTRACE_NMI_ENTER -extern void arch_ftrace_nmi_enter (void ); -extern void arch_ftrace_nmi_exit (void ); -#else -static inline void arch_ftrace_nmi_enter (void ) { } -static inline void arch_ftrace_nmi_exit (void ) { } -#endif - -#ifdef CONFIG_RING_BUFFER extern void ftrace_nmi_enter (void );extern void ftrace_nmi_exit (void );#else
kernel/trace/ring_buffer.c +13 -30
66 lines not on this page · raw message
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 8/8 trace: trivial fixes in comment typos.
In reply to Steven RostedtFrom: Wenji Huang <[email protected]>
Impact: clean up
Fixed several typos in the comments.
--- include/linux/ftrace.h | 2 +- kernel/trace/ftrace.c | 6 +++--- kernel/trace/trace.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
include/linux/ftrace.h +1 -1
@@ -140,7 +140,7 @@ static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }#endif /** -* ftrace_make_nop - convert code into top +* ftrace_make_nop - convert code into nop * @mod: module structure if called by module load initialization * @rec: the mcount call site record * @addr: the address that the call site should be calling
kernel/trace/ftrace.c +3 -3
@@ -465,7 +465,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)* it is not enabled then do nothing. * * If this record is not to be traced and -* it is enabled then disabled it. +* it is enabled then disable it. * */ if (rec->flags &FTRACE_FL_NOTRACE ) {
@@ -485,7 +485,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)if (fl == (FTRACE_FL_FILTER |FTRACE_FL_ENABLED ))return 0 ; -/* Record is not filtered and is not enabled do nothing */ +/* Record is not filtered or enabled, do nothing */ if (!fl)return 0 ;
@@ -507,7 +507,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable) }else { -/* if record is not enabled do nothing */ +/* if record is not enabled, do nothing */ if (!(rec->flags &FTRACE_FL_ENABLED ))return 0 ;
kernel/trace/trace.h +3 -3
@@ -616,12 +616,12 @@ extern struct tracer nop_trace;* preempt_enable (after a disable), a schedule might take place * causing an infinite recursion. * -* To prevent this, we read the need_recshed flag before +* To prevent this, we read the need_resched flag before * disabling preemption. When we want to enable preemption we * check the flag, if it is set, then we call preempt_enable_no_resched. * Otherwise, we call preempt_enable. * -* The rational for doing the above is that if need resched is set +* The rational for doing the above is that if need_resched is set * and we have yet to reschedule, we are either in an atomic location * (where we do not need to check for scheduling) or we are inside * the scheduler and do not want to resched.
@@ -642,7 +642,7 @@ static inline int ftrace_preempt_disable(void)* * This is a scheduler safe way to enable preemption and not miss * any preemption checks. The disabled saved the state of preemption. -* If resched is set, then we were either inside an atomic or +* If resched is set, then we are either inside an atomic or * are inside the scheduler (we would have already scheduled * otherwise). In this case, we do not want to call normal * preempt_enable, but preempt_enable_no_resched instead.
Signature · 3 lines
1.5.6.5 --
Quoted 34 lines · Steven Rostedt
Ingo,
I rebased the previous changes onto tip/tracing/core. The first patch is new, which is the elimination of the
entry->cpu.I did not remove it when it became obsolete, and thus we had other developers using it, thinking that it was the way to get the current cpu number. Unfortunately, the
entry->cpuwas just taking up space, and never was initialized.The rest of the patches, I've posted before, but this time I ported them over to tip/tracing/core.
The following patches are in:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.gitbranch: tip/tracing/core/devel
Steven Rostedt (7):
trace: remove deprecatedentry->cpu
ring-buffer: add NMI protection for spinlocks
ring-buffer: allowtracing_offto be used in core kernel code ftrace, x86: renamein_nmivariable
nmi: add generic nmi tracking state
ftrace: change function graph tracer to use newin_nmi
ring-buffer: use generic version ofin_nmiWenji Huang (1):
trace: trivial fixes in comment typos.----
Quoted 14 lines
arch/x86/Kconfig | 1 + arch/x86/kernel/ftrace.c | 35 ++++++++--------------------------- include/linux/ftrace.h | 2 +- include/linux/ftrace_irq.h | 2 +- include/linux/hardirq.h | 15 +++++++++++++++ include/linux/ring_buffer.h | 9 +++++++++ kernel/trace/Kconfig | 8 ++++++++ kernel/trace/ftrace.c | 6 +++--- kernel/trace/ring_buffer.c | 31 +++++++++++++++++++++++++++++-- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 7 +++---- kernel/trace/trace_hw_branches.c | 3 +-- kernel/trace/trace_output.c | 6 +++--- 13 files changed, 83 insertions(+), 44 deletions(-)
Pulled into tip/tracing/ftrace, thanks Steve!
There was a conflict in kernel/trace/trace_hw_branches.c - i resolved it, please double-check the end result.
One small detail, for future pull requests to me, could you please use the customary "tracing: " tags for generic commits, instead the "trace: " tag you started using recently? Thanks,
Ingo
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking state
hm, this commit breaks a number of non-x86 architectures the following way:
In file included from /home/mingo/tip/include/linux/interrupt.h:12,
from /home/mingo/tip/arch/ia64/include/asm/mca.h:16,
from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:/home/mingo/tip/include/linux/hardirq.h:67:2: #error PREEMPT_ACTIVE too high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1
Alpha and ARM are broken too. (and possibly others)
Ingo
Steven Rostedt
maintainerQuoted 7 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking statehm, this commit breaks a number of non-x86 architectures the following way:
Quoted 7 lines
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1Alpha and ARM are broken too. (and possibly others)
I'm glad we had that check.
OK, revert it and I'll take a look to see what other options we have.
Thanks,
-- Steve
Quoted 16 lines · Steven Rostedt
Quoted 13 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking statehm, this commit breaks a number of non-x86 architectures the following way:
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1
Quoted 5 lines
Quoted 1 line
Alpha and ARM are broken too. (and possibly others)
I'm glad we had that check.
OK, revert it and I'll take a look to see what other options we have.
Reverting it is neither simple nor desired: 1) it's now embedded in other tracing commits 2) my test-boxes stopped doing those rare lockups with the NMI fix in place ...
Any better approach to fix those platforms? I reported this ftrace NMI problem to you about a year ago ...
Ingo
Steven Rostedt
maintainerQuoted 21 lines · Ingo Molnar
Quoted 18 lines · Steven Rostedt
Quoted 14 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking statehm, this commit breaks a number of non-x86 architectures the following way:
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1Alpha and ARM are broken too. (and possibly others)
Quoted 7 lines
Quoted 3 lines
I'm glad we had that check.
OK, revert it and I'll take a look to see what other options we have.
Reverting it is neither simple nor desired: 1) it's now embedded in other tracing commits 2) my test-boxes stopped doing those rare lockups with the NMI fix in place ...
OK, I was thinking about coming up with another fix.
I'll have to look at the other archs and see what we can do to make this work for all.
Quoted 3 lines
Any better approach to fix those platforms? I reported this ftrace NMI problem to you about a year ago ...
Yeah, and I just found the bug ;-)
-- Steve
Steven Rostedt
maintainerQuoted 7 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking statehm, this commit breaks a number of non-x86 architectures the following way:
Quoted 7 lines
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1Alpha and ARM are broken too. (and possibly others)
Looking at this, it doesn't seem like it should be a problem. Perhaps the CPP is treating the number as signed. Does this patch fix the compile?
-- Steve
include/linux/hardirq.h +1 -1
@@ -63,7 +63,7 @@#define NMI_OFFSET (PREEMPT_ACTIVE << 1) -#if NMI_OFFSET >=0x80000000 +#if NMI_OFFSET >=0x80000000UL #error PREEMPT_ACTIVE too high!#endif
Steven Rostedt
maintainerQuoted 8 lines · Steven Rostedt
Quoted 5 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking state
Quoted 7 lines
Quoted 7 lines
hm, this commit breaks a number of non-x86 architectures the following way:
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1
I just looked at alpha and arm, I'm now looking at ia64. And this could be an issue, since it has 14 bits for hard irqs.
What would be the impact to make the preempt count a long?
-- Steve
Quoted 24 lines
Quoted 2 lines
Alpha and ARM are broken too. (and possibly others)
Looking at this, it doesn't seem like it should be a problem. Perhaps the CPP is treating the number as signed. Does this patch fix the compile?
-- Steve
Signed-off-by Steven Rostedt <[email protected]>include/linux/hardirq.h +1
-1@@ -63,7 +63,7 @@#define NMI_OFFSET (PREEMPT_ACTIVE << 1) -#if NMI_OFFSET >=0x80000000 +#if NMI_OFFSET >=0x80000000UL #error PREEMPT_ACTIVE too high!#endif
Quoted 19 lines · Steven Rostedt
Quoted 8 lines · Steven Rostedt
Quoted 5 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
Steven Rostedt (7):
ring-buffer: add NMI protection for spinlocks
nmi: add generic nmi tracking stateQuoted 7 lines
Quoted 7 lines
hm, this commit breaks a number of non-x86 architectures the following way:
In file included from
/home/mingo/tip/include/linux/interrupt.h:12,from /home/mingo/tip/arch/ia64/include/asm/mca.h:16, from /home/mingo/tip/arch/ia64/kernel/asm-offsets.c:17:
/home/mingo/tip/include/linux/hardirq.h:67:2: #errorPREEMPT_ACTIVEtoo high! make[2]: *** [arch/ia64/kernel/asm-offsets.s] Error 1
Quoted 4 lines
I just looked at alpha and arm, I'm now looking at ia64. And this could be an issue, since it has 14 bits for hard irqs.
What would be the impact to make the preempt count a long?
Assembly code has to be audited i guess, whether it's treated as an int anywhere. Should work i guess.
Ingo
Steven Rostedt
maintainerQuoted 8 lines · Ingo Molnar
Quoted 5 lines
I just looked at alpha and arm, I'm now looking at ia64. And this could be an issue, since it has 14 bits for hard irqs.
What would be the impact to make the preempt count a long?
Assembly code has to be audited i guess, whether it's treated as an int anywhere. Should work i guess.
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
-- Steve
Quoted 7 lines · Steven Rostedt
Quoted 6 lines · Ingo Molnar
Quoted 5 lines
I just looked at alpha and arm, I'm now looking at ia64. And this could be an issue, since it has 14 bits for hard irqs.
What would be the impact to make the preempt count a long?
Quoted 8 lines
Quoted 2 lines
Assembly code has to be audited i guess, whether it's treated as an int anywhere. Should work i guess.
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
Ingo
Quoted 7 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
Fujitsu added the vector domain support for ia64 to get around the shortage of IRQs for large machines. Added them to the Cc: list to see if they have comments on how many IRQs are needed.
-Tony
Steven Rostedt
maintainerQuoted 8 lines · Tony
Quoted 7 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
Quoted 7 lines
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
Fujitsu added the vector domain support for ia64 to get around the shortage of IRQs for large machines. Added them to the Cc: list to see if they have comments on how many IRQs are needed.
The bits in question is really the number of possible nested interrupts that can happen. We take the paranoid approach that we can have a max nesting of NR_IRQS. Perhaps this can be changed, and just do a max of 1<<10 nesting? And have a big warn on if it happens to be bigger, or fall to another counter if it is bigger.
1000 nested IRQs seems a bit extreme :-/
Just throwing out some ideas.
-- Steve
Quoted 7 lines
The bits in question is really the number of possible nested interrupts that can happen. We take the paranoid approach that we can have a max nesting of
NR_IRQS. Perhaps this can be changed, and just do a max of 1<<10 nesting? And have a big warn on if it happens to be bigger, or fall to another counter if it is bigger.1000 nested IRQs seems a bit extreme :-/
Ah, I see. Then the answer is very different. The number of nested interrupts possible on a cpu is limited by the number of priority classes for interrupts (See Table 5-8 on page 2:112 of the Itanium software developers manual). Effectively the max nesting depth is 16.
1000 nested interrupts would be certain to run us out of stack.
-Tony
Steven Rostedt
maintainerQuoted 8 lines · Tony
Quoted 7 lines
The bits in question is really the number of possible nested interrupts that can happen. We take the paranoid approach that we can have a max nesting of
NR_IRQS. Perhaps this can be changed, and just do a max of 1<<10 nesting? And have a big warn on if it happens to be bigger, or fall to another counter if it is bigger.1000 nested IRQs seems a bit extreme :-/
Quoted 7 lines
Ah, I see. Then the answer is very different. The number of nested interrupts possible on a cpu is limited by the number of priority classes for interrupts (See Table 5-8 on page 2:112 of the Itanium software developers manual). Effectively the max nesting depth is 16.
1000 nested interrupts would be certain to run us out of stack.
Ingo,
Do you think this is a good assumption to make, that no arch will have over 1<<10 nested interrupts. We can add a WARN_ON if it happens. Then we can make all archs have a 10 bit offset. Smaller may also be sufficient.
-- Steve
Quoted 17 lines · Steven Rostedt
Quoted 14 lines · Tony
Quoted 7 lines
The bits in question is really the number of possible nested interrupts that can happen. We take the paranoid approach that we can have a max nesting of
NR_IRQS. Perhaps this can be changed, and just do a max of 1<<10 nesting? And have a big warn on if it happens to be bigger, or fall to another counter if it is bigger.1000 nested IRQs seems a bit extreme :-/
Ah, I see. Then the answer is very different. The number of nested interrupts possible on a cpu is limited by the number of priority classes for interrupts (See Table 5-8 on page 2:112 of the Itanium software developers manual). Effectively the max nesting depth is 16.
Quoted 7 lines
Quoted 1 line
1000 nested interrupts would be certain to run us out of stack.
Ingo,
Do you think this is a good assumption to make, that no arch will have over 1<<10 nested interrupts. We can add a
WARN_ONif it happens. Then we can make all archs have a 10 bit offset. Smaller may also be sufficient.
That's a fair assumption, yes. No need for a WARN_ON() (it slows down a critical path) - things will get very colorful much sooner than that, due to kernel stack overflow.
Ingo
Quoted 11 lines · Tony
Quoted 7 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
As long as per-cpu interrupts (ex., timer, cpe_hndlr, cmc_hndlr, etc) are not counted in the IRQ count, SGI is ok with 256 IRQs. We had problems overflowing the old limit of 256 but have worked around it.
If per-cpu interrupts ARE counted in the total IRQs, then we currently use 5 per-cpu interrupts for each cpu. A 4k cpu config will need 20k IRQs + additional IRQs for real devices.
I know the IRQ infrastructure has changed recently so this may no longer apply.
--- jack
Quoted 7 lines · Tony
Quoted 6 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
Quoted 8 lines
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
Fujitsu added the vector domain support for ia64 to get around the shortage of IRQs for large machines. Added them to the Cc: list to see if they have comments on how many IRQs are needed.
The 1024 IRQs are enough for GSIs on our maximum configuration. But if the devices are MSI/MSI-X capable, it could be more than 1024.
Thanks,
Kenji Kaneshige
Steven Rostedt
maintainerQuoted 12 lines · Kenji Kaneshige
Quoted 11 lines · Tony
Quoted 6 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
Quoted 7 lines
Quoted 4 lines
Fujitsu added the vector domain support for ia64 to get around the shortage of IRQs for large machines. Added them to the Cc: list to see if they have comments on how many IRQs are needed.
The 1024 IRQs are enough for GSIs on our maximum configuration. But if the devices are MSI/MSI-X capable, it could be more than 1024.
But you would never expect more than 1024 nested interrupts all on the same CPU? That is, to have over 1024 interrupts interrupting each other?
-- Steve
Quoted 16 lines · Steven Rostedt
Quoted 15 lines · Kenji Kaneshige
Quoted 14 lines · Tony
Quoted 6 lines
Quoted 5 lines
Before we go and make the change, Peter brought up a good point on IRC. Is there any reason that ia64 needs 1 << 14 IRQs? That's 16384!
Perhaps the better solution wolud be (if possible), to simply lower the number of bits.
i'm the wrong person to be asked about that. (Cc:-ed the right people)
People build some pretty big systems on ia64. SGI's largest has 4096 cpus ... so 16384 IRQs is only 4 per cpu. That doesn't sound like very many to me.
Fujitsu added the vector domain support for ia64 to get around the shortage of IRQs for large machines. Added them to the Cc: list to see if they have comments on how many IRQs are needed.
Quoted 6 lines
Quoted 2 lines
The 1024 IRQs are enough for GSIs on our maximum configuration. But if the devices are MSI/MSI-X capable, it could be more than 1024.
But you would never expect more than 1024 nested interrupts all on the same CPU? That is, to have over 1024 interrupts interrupting each other?
Itanium processor has 240 vectors for external interrupts and has a mechanism to classifies them to 16 priority classes. The ia64 linux limits maximum nested interrupts depth to 16 using this mechanism.
Thanks,
Kenji Kaneshige
Steven Rostedt
maintainerQuoted 5 lines · Kenji Kaneshige
Itanium processor has 240 vectors for external interrupts and has a mechanism to classifies them to 16 priority classes. The ia64 linux limits maximum nested interrupts depth to 16 using this mechanism.
Then 1000, should be more than enough ;-)
Thanks for the info,
-- Steve