latency -t 1 crashes on SMP.
I tried latency -t 1 on an SMP machines, and observed a very reproducible crash. Most of the time, the machine locks up completely. The rest of the time, I get :
Xenomai: suspending kernel thread e7559044 ('timerbench') at 0xb01051f2 after ex ception #14
And the system remains runnable, but 0xb01051f2 is not a valid kernel module text address.
The lock up does not seem to be detected by any Xenomai or Linux debug or watchdog. Only enabling the NMI watchdog seems to systematically produce the exception 14 instead of the lockup.
I ve tried to put a printk at the beginning of timer_task_proc outer loop. It get printed once when getting the exception 14, and twice when getting the lock up.
Any idea where to look ?
Signature · 1 line
Gilles Chanteperdrix.
Quoted 14 lines · Gilles Chanteperdrix
I tried latency -t 1 on an SMP machines, and observed a very reproducible crash. Most of the time, the machine locks up completely. The rest of the time, I get :
Xenomai: suspending kernel thread
e7559044('timerbench') at0xb01051f2after ex ception #14And the system remains runnable, but
0xb01051f2is not a valid kernel module text address.The lock up does not seem to be detected by any Xenomai or Linux debug or watchdog. Only enabling the NMI watchdog seems to systematically produce the exception 14 instead of the lockup.
Quoted 6 lines
I ve tried to put a printk at the beginning of
timer_task_procouter loop. It get printed once when getting the exception 14, and twice when getting the lock up.Any idea where to look ?
Two proposals to collect information:
o give KGDB a try
o instrument the xenomai exception handler with an ipipe_trace_freeze() (something which should be merged into SVN later)
Jan
Quoted 2 lines · Jan Kiszka
o instrument the xenomai exception handler with an
ipipe_trace_freeze()(something which should be merged into SVN later)
The I-pipe tracer as well as Linux NMI handling have the same issue which is the cause for the exceptions 14: they rely on a correct "current" to read the processor id. The first attached patch, to be applied after the ipipe patch, add an ipipe_processor_id_notrace function, which is called instead of raw_smp_processor_id() in the second, I-pipe tracer, attached patch.
Signature · 1 line
Gilles Chanteperdrix.
arch/i386/kernel/ipipe-root.c renamed from arch/i386/kernel/ipipe-root.c~ +28 -0
@@ -107,6 +107,30 @@ int (*__ipipe_logical_cpuid)(void) = &__EXPORT_SYMBOL (__ipipe_logical_cpuid); +#ifdef CONFIG_IPIPE_TRACE + +static notrace int __ipipe_boot_cpuid_notrace(void) +{ +return 0 ; +} + +static notrace int __ipipe_hard_cpuid_notrace(void) +{ +unsigned long flags; +int cpu; + +local_irq_save_hw_notrace (flags); + cpu = __ipipe_apicid_2_cpu[GET_APIC_ID (apic_read (APIC_ID ))]; +local_irq_restore_hw_notrace (flags); +return cpu; +} + +int (*__ipipe_logical_cpuid_notrace)(void ) = &__ipipe_boot_cpuid_notrace; + +EXPORT_SYMBOL (__ipipe_logical_cpuid_notrace); + +#endif +#endif /* CONFIG_SMP */ #endif /* CONFIG_X86_LOCAL_APIC */
@@ -223,6 +247,10 @@ void __init __ipipe_enable_pipeline(void* trap_init(), so it's safe to use it. */ __ipipe_logical_cpuid = &__ipipe_hard_cpuid; +#ifdef CONFIG_IPIPE_TRACE + __ipipe_logical_cpuid_notrace = &__ipipe_hard_cpuid_notrace; +#endif +#endif /* CONFIG_SMP */
include/asm-i386/ipipe.h renamed from include/asm-i386/ipipe.h~ +9 -0
@@ -103,6 +103,15 @@ static inline int ipipe_processor_id(voireturn __ipipe_logical_cpuid (); } +#ifdef CONFIG_IPIPE_TRACE +static notrace inline int ipipe_processor_id_notrace(void) +{ +extern int (*__ipipe_logical_cpuid_notrace)(void ); +return __ipipe_logical_cpuid_notrace (); +} + +#endif +extern u8 __ipipe_apicid_2_cpu[];#define ipipe_note_apicid (apicid,cpu) \
home/rpm/gna/adeos/ipipe/v2.6/common/kernel/ipipe/Kconfig.trace renamed from kernel/ipipe/Kconfig +21 -0
@@ -13,3 +13,24 @@ config IPIPE_STATS Activate this option if you want runtime statistics to be collected while the I-pipe is operating. This option adds a small overhead, but is useful to detect unexpected latency spots. + +config IPIPE_TRACE + bool "Latency Tracing" + depends on IPIPE && PROC_FS + select FRAME_POINTER + default n + ---help--- + Activate this option if you want to use per-function tracing of + the kernel. The tracer will collect data via instrumentation + features like the one below or with the help of explicite calls + of ipipe_trace_xxx(). See include/linux/ipipe_trace.h for the + in-kernel tracing API. The collected data and runtime control + is available via /proc/ipipe/trace/*. + +config IPIPE_TRACE_IRQSOFF + bool "Trace IRQs-off times" + depends on IPIPE_TRACE + default y + ---help--- + Activate this option if I-pipe shall trace the longest path + with hard-IRQs switched off.
Makefile +4 -0
@@ -511,11 +511,15 @@ CFLAGS += $(call add-align,CONFIG_CC_AL CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops) CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps) +ifdef CONFIG_IPIPE_TRACE +CFLAGS += -pg -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) +else ifdef CONFIG_FRAME_POINTER CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) else CFLAGS += -fomit-frame-pointer endif +endif ifdef CONFIG_DEBUG_INFO CFLAGS += -g
include/linux/ipipe_trace.h +37 -0
@@ -0,0 +1,37 @@ +/* -*- linux-c -*- +* include/linux/ipipe_trace.h +* +* Copyright (C) 2005 Luotao Fu. +* 2005 Jan Kiszka. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, +* USA; either version 2 of the License, or (at your option) any later +* version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef _LINUX_IPIPE_TRACE_H +#define _LINUX_IPIPE_TRACE_H + +void ipipe_trace_begin (unsigned long v); +void ipipe_trace_end (unsigned long v); +void ipipe_trace_freeze (unsigned long v); +void ipipe_trace_special (unsigned char special_id,unsigned long v); + +int ipipe_trace_max_reset (void ); +int ipipe_trace_frozen_reset (void ); + +void ipipe_trace_panic_freeze (void ); +void ipipe_trace_panic_dump (void ); + +#endif /* !__LINUX_IPIPE_H */
include/linux/linkage.h +4 -0
@@ -51,4 +51,8 @@#define fastcall#endif +#ifndef notrace +#define notrace __attribute__((no_instrument_function)) +#endif +#endif
kernel/ipipe/tracer.c +1048 -0
1,048 lines not on this page · raw message
arch/i386/boot/compressed/misc.c +7 -1
@@ -15,6 +15,12 @@#include <asm/io.h> #include <asm/page.h> +#ifdef CONFIG_IPIPE_TRACE +void __attribute__ ((no_instrument_function))mcount (void ) +{ +} +#endif +/* * gzip declarations */
@@ -112,7 +118,7 @@ static long free_mem_end_ptr;#define INPLACE_MOVE_ROUTINE 0x1000#define LOW_BUFFER_START 0x2000#define LOW_BUFFER_MAX 0x90000 -#define HEAP_SIZE 0x3000 +#define HEAP_SIZE 0x4000static unsigned int low_buffer_end, low_buffer_size;static int high_loaded =0 ;static uch *high_buffer_start/* = (uch *)(((ulg)&end) + HEAP_SIZE)*/ ;
arch/i386/kernel/ipipe-mcount.S +45 -0
45 lines not on this page · raw message
Quoted 11 lines · Gilles Chanteperdrix
Quoted 2 lines · Jan Kiszka
o instrument the xenomai exception handler with an
ipipe_trace_freeze()(something which should be merged into SVN later)The I-pipe tracer as well as Linux NMI handling have the same issue which is the cause for the exceptions 14: they rely on a correct "current" to read the processor id. The first attached patch, to be applied after the ipipe patch, add an
ipipe_processor_id_notracefunction, which is called instead ofraw_smp_processor_id()in the second, I-pipe tracer, attached patch.
Ah, good point! But why not make the original __ipipe_*_cpuid functions non-traced? I don't think we would loose significant information.
Jan
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Gilles Chanteperdrix
Quoted 2 lines · Jan Kiszka
o instrument the xenomai exception handler with an
ipipe_trace_freeze()(something which should be merged into SVN later)The I-pipe tracer as well as Linux NMI handling have the same issue which is the cause for the exceptions 14: they rely on a correct "current" to read the processor id. The first attached patch, to be applied after the ipipe patch, add an
ipipe_processor_id_notracefunction, which is called instead ofraw_smp_processor_id()in the second, I-pipe tracer, attached patch.
Quoted 2 lines
Ah, good point! But why not make the original __ipipe_*_cpuid functions non-traced? I don't think we would loose significant information.
The attached patches do that.
Signature · 1 line
Gilles Chanteperdrix.
arch/i386/kernel/ipipe-root.c renamed from arch/i386/kernel/ipipe-root.c~ +14 -1
@@ -85,13 +85,14 @@ static void __ipipe_null_handler(unsigne #ifdef CONFIG_SMP -static int __ipipe_boot_cpuid (void ) +static __attribute__((no_instrument_function)) int __ipipe_boot_cpuid(void) { return 0; } u8 __ipipe_apicid_2_cpu[IPIPE_NR_CPUS]; +#ifndef CONFIG_IPIPE_TRACE static int __ipipe_hard_cpuid(void) { unsigned long flags;
@@ -102,6 +103,18 @@ static int __ipipe_hard_cpuid(void)local_irq_restore_hw (flags);return cpu; } +#else /* CONFIG_IPIPE_TRACE */ +static notrace int __ipipe_hard_cpuid(void) +{ +unsigned long flags; +int cpu; + +local_irq_save_hw_notrace (flags); + cpu = __ipipe_apicid_2_cpu[GET_APIC_ID (apic_read (APIC_ID ))]; +local_irq_restore_hw_notrace (flags); +return cpu; +} +#endif /* CONFIG_IPIPE_TRACE */ int (*__ipipe_logical_cpuid)(void ) = &__ipipe_boot_cpuid;
include/asm-i386/ipipe.h renamed from include/asm-i386/ipipe.h~ +1 -1
@@ -97,7 +97,7 @@#define IPIPE_CRITICAL_VECTOR 0xf9/* Used by ipipe_critical_enter/exit() */ #define IPIPE_CRITICAL_IPI (IPIPE_CRITICAL_VECTOR - FIRST_EXTERNAL_VECTOR) -static inline int ipipe_processor_id (void ) +static inline __attribute__((no_instrument_function))int ipipe_processor_id (void ) {extern int (*__ipipe_logical_cpuid)(void );return __ipipe_logical_cpuid ();
home/rpm/gna/adeos/ipipe/v2.6/common/kernel/ipipe/Kconfig.trace renamed from kernel/ipipe/Kconfig +21 -0
@@ -13,3 +13,24 @@ config IPIPE_STATS Activate this option if you want runtime statistics to be collected while the I-pipe is operating. This option adds a small overhead, but is useful to detect unexpected latency spots. + +config IPIPE_TRACE + bool "Latency Tracing" + depends on IPIPE && PROC_FS + select FRAME_POINTER + default n + ---help--- + Activate this option if you want to use per-function tracing of + the kernel. The tracer will collect data via instrumentation + features like the one below or with the help of explicite calls + of ipipe_trace_xxx(). See include/linux/ipipe_trace.h for the + in-kernel tracing API. The collected data and runtime control + is available via /proc/ipipe/trace/*. + +config IPIPE_TRACE_IRQSOFF + bool "Trace IRQs-off times" + depends on IPIPE_TRACE + default y + ---help--- + Activate this option if I-pipe shall trace the longest path + with hard-IRQs switched off.
Makefile +4 -0
@@ -511,11 +511,15 @@ CFLAGS += $(call add-align,CONFIG_CC_AL CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops) CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps) +ifdef CONFIG_IPIPE_TRACE +CFLAGS += -pg -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) +else ifdef CONFIG_FRAME_POINTER CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) else CFLAGS += -fomit-frame-pointer endif +endif ifdef CONFIG_DEBUG_INFO CFLAGS += -g
include/linux/ipipe_trace.h +37 -0
@@ -0,0 +1,37 @@ +/* -*- linux-c -*- +* include/linux/ipipe_trace.h +* +* Copyright (C) 2005 Luotao Fu. +* 2005 Jan Kiszka. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, +* USA; either version 2 of the License, or (at your option) any later +* version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef _LINUX_IPIPE_TRACE_H +#define _LINUX_IPIPE_TRACE_H + +void ipipe_trace_begin (unsigned long v); +void ipipe_trace_end (unsigned long v); +void ipipe_trace_freeze (unsigned long v); +void ipipe_trace_special (unsigned char special_id,unsigned long v); + +int ipipe_trace_max_reset (void ); +int ipipe_trace_frozen_reset (void ); + +void ipipe_trace_panic_freeze (void ); +void ipipe_trace_panic_dump (void ); + +#endif /* !__LINUX_IPIPE_H */
include/linux/linkage.h +4 -0
@@ -51,4 +51,8 @@#define fastcall#endif +#ifndef notrace +#define notrace __attribute__((no_instrument_function)) +#endif +#endif
kernel/ipipe/tracer.c +1048 -0
1,048 lines not on this page · raw message
arch/i386/boot/compressed/misc.c +7 -1
@@ -15,6 +15,12 @@#include <asm/io.h> #include <asm/page.h> +#ifdef CONFIG_IPIPE_TRACE +void __attribute__ ((no_instrument_function))mcount (void ) +{ +} +#endif +/* * gzip declarations */
@@ -112,7 +118,7 @@ static long free_mem_end_ptr;#define INPLACE_MOVE_ROUTINE 0x1000#define LOW_BUFFER_START 0x2000#define LOW_BUFFER_MAX 0x90000 -#define HEAP_SIZE 0x3000 +#define HEAP_SIZE 0x4000static unsigned int low_buffer_end, low_buffer_size;static int high_loaded =0 ;static uch *high_buffer_start/* = (uch *)(((ulg)&end) + HEAP_SIZE)*/ ;
arch/i386/kernel/ipipe-mcount.S +45 -0
45 lines not on this page · raw message
Quoted 9 lines · Gilles Chanteperdrix
I tried latency -t 1 on an SMP machines, and observed a very reproducible crash. Most of the time, the machine locks up completely. The rest of the time, I get :
Xenomai: suspending kernel thread
e7559044('timerbench') at0xb01051f2after ex ception #14And the system remains runnable, but
0xb01051f2is not a valid kernel module text address.
Looks like a kernel-based task stack address on x86.
Signature · 1 line
Philippe.
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Gilles Chanteperdrix
I tried latency -t 1 on an SMP machines, and observed a very reproducible crash. Most of the time, the machine locks up completely. The rest of the time, I get :
Quoted 7 lines
Quoted 5 lines
Xenomai: suspending kernel thread
e7559044('timerbench') at0xb01051f2after ex ception #14And the system remains runnable, but
0xb01051f2is not a valid kernel module text address.Looks like a kernel-based task stack address on x86.
Actually, this address really is a kernel text address, because I use the CONFIG_VMSPLIT_3G_OPT, which seems a way to configure a machine with 1GB RAM. The crash also happens with CONFIG_VMSPLIT_3G, but the text address is 0xc01051f2.
I tried adding a call to show_stack() in xnpod_fault_handler, and it shows that the crash happens right after the call to rthal_nmi_arm in xnarch_program_timer_shot:
Xenomai: suspending kernel thread eeed5044 ('timerbench') at 0xc01051f2 after ex ception #14ee8c1768 c02d24c1 ee8c1798 f8ff868c 00000000 00000000 eeed53b0 c01051f2
0000000e bfa49f69 58454e4f 0000000e ee8c17a4 f900aca1 ee8c17b0 ee8c17c0
f8ff57b3 ee8c17b0 0000000e ffffffff ee8c183c 00000082 ee8c17dc c0259df0
Call Trace:
[<c0103f6a>] show_stack_log_lvl+0xaa/0xe0
[<c0103fc1>] show_stack+0x21/0x30
[<f8ff868c>] xnpod_fault_handler+0x8c/0x220 [xeno_nucleus]
[<f900aca1>] xnpod_trap_fault+0x61/0x70 [xeno_nucleus]
[<f8ff57b3>] xnarch_trap_fault+0x23/0x30 [xeno_nucleus]
[<c0259df0>] exception_event+0x70/0x80
[<c0142103>] __ipipe_dispatch_event+0x103/0x130
[<c01140ea>] __ipipe_handle_exception+0x2a/0xf0
[<c0103b7c>] error_code+0x54/0x64
[<c0103c42>] nmi_stack_correct+0x1d/0x22
[<f9015141>] xntimer_do_start_aperiodic+0x441/0x560 [xeno_nucleus]
[<f901a380>] xntimer_start+0x130/0x350 [xeno_nucleus]
[<f8ffe4ed>] xnpod_suspend_thread+0x7ad/0xd40 [xeno_nucleus]
[<f8f82749>] rtdm_task_sleep_until+0x179/0x3d0 [xeno_rtdm]
[<f8e83456>] timer_task_proc+0x1c6/0x450 [xeno_timerbench]
[<f8ff7f5d>] xnarch_thread_redirect+0x5d/0x80 [xeno_nucleus]
[<00000000>] _stext+0x3feffd68/0x8And now the most interesting: when compiling Xenomai in the kernel, (which moves Xenomai code out of vmalloc'ed memory) the bug disappears.
Signature · 1 line
Gilles Chanteperdrix.