Skip to contentSkip to conversation

lockups with 2.4.20 (tg3? net/core/dev.c|deliver_to_old_ones)

DISCUSSION Manfred Spraul 1 participant 1 message Feb 16, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Pete

I think the best resolution would be an instrumentation patch which records lock takers, and prints them when the thing is forcefuly oopsed. I should come with it eventually, if someone does not beat me to it (I wish they did, actually :-)

What about the attached patch?
I'm not 100% that I've catched everyone that does spin_lock();_raw_spin_unlock(), and print_events() is not yet called from the oops/nmi codepath (How should it handle bust_spinlocks?)

Not really tested - boots bochs, print_events() output looks sane when manually triggered.

--
Manfred

// $Header$
// Kernel Version:

//  VERSION = 2
//  PATCHLEVEL = 5
//  SUBLEVEL = 61
//  EXTRAVERSION =
arch/i386/Kconfig +9 -0
@@ -1623,6 +1623,15 @@
 	  best used in conjunction with the NMI watchdog so that spinlock
 	  deadlocks are also debuggable.
 
+config DEBUG_EVENTLOG
+	bool "Eventlog for deadlock analysis"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here to log spinlock and rwlock calls of all cpus. This is
+	  best used in conjunction with the NMI watchlog or a kernel debugger
+	  so that the event log is actually accessable. This option causes a
+	  noticable overhead, disable for production systems.
+
 config DEBUG_HIGHMEM
 	bool "Highmem debugging"
 	depends on DEBUG_KERNEL && HIGHMEM
include/asm-i386/processor.h +5 -1
@@ -472,7 +472,11 @@
 	__asm__ __volatile__("rep;nop": : :"memory");
 }
 
-#define cpu_relax()	rep_nop()
+#define cpu_relax()	\
+		do { \
+			save_event(EVENT_CPU_RELAX, NULL); \
+			rep_nop(); \
+		} while(0)
 
 /* Prefetch instructions for Pentium III and AMD Athlon */
 #ifdef 	CONFIG_X86_PREFETCH
kernel/exit.c +1 -0
@@ -709,6 +709,7 @@
 	 * preempt here).
 	 */
 	_raw_write_unlock(&tasklist_lock);
+	save_event(EVENT_WRITE_LOCK_RELEASE,&tasklist_lock);
 }
 
 NORET_TYPE void do_exit(long code)
kernel/sched.c +1 -0
@@ -1888,6 +1888,7 @@
 	 * no need to preempt:
 	 */
 	_raw_spin_unlock(&rq->lock);
+	save_event(EVENT_SPINLOCK_RELEASE,&rq->lock);
 	preempt_enable_no_resched();
 
 	schedule();
include/linux/brlock.h +2 -0
diff -uN --exclude autoconf.h --exclude compile.h --exclude version.h 2.5/include/linux/brlock.h build-2.5/include/linux/brlock.h
@@ -86,7 +86,9 @@
 		__br_lock_usage_bug();
 
 	preempt_disable();
+	save_event(EVENT_READ_LOCK_BEFORE,&__brlock_array[smp_processor_id()][idx]);
 	_raw_read_lock(&__brlock_array[smp_processor_id()][idx]);
+	save_event(EVENT_READ_LOCK,&__brlock_array[smp_processor_id()][idx]);
 }
 
 static inline void br_read_unlock (enum brlock_indices idx)
include/linux/eventlog.h +75 -0

75 lines not on this page · raw message

include/linux/sched.h +1 -0
diff -uN --exclude autoconf.h --exclude compile.h --exclude version.h 2.5/include/linux/sched.h build-2.5/include/linux/sched.h
@@ -775,6 +775,7 @@
 {
 	if (need_resched()) {
 		_raw_spin_unlock(lock);
+		save_event(EVENT_SPINLOCK_RELEASE,lock);
 		preempt_enable_no_resched();
 		__cond_resched();
 		spin_lock(lock);
include/linux/spinlock.h +48 -11

235 lines not on this page · raw message

lib/eventlog.c +158 -0

158 lines not on this page · raw message

lib/Makefile +1 -0
diff -uN --exclude '*.cmd' --exclude crc32table.h 2.5/lib/Makefile build-2.5/lib/Makefile
@@ -20,6 +20,7 @@
 endif
 
 obj-$(CONFIG_CRC32)	+= crc32.o
+obj-$(CONFIG_DEBUG_EVENTLOG) += eventlog.o
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/