From: Ingo Molnar The patch below will detect atomic counter underflows. This has been test-driven in the -RT patchset for some time. qdisc_destroy() triggered it sometimes (in a seemingly nonfatal way, during device shutdown) - with DaveM suggesting that it is most likely a bug in the networking code. So it would be nice to have this in -mm for some time to validate all atomic counters on a broader base. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton --- include/asm-i386/atomic.h | 4 ++++ 1 files changed, 4 insertions(+) diff -puN include/asm-i386/atomic.h~detect-atomic-counter-underflows include/asm-i386/atomic.h --- devel/include/asm-i386/atomic.h~detect-atomic-counter-underflows 2006-05-11 15:19:42.000000000 -0700 +++ devel-akpm/include/asm-i386/atomic.h 2006-05-11 15:19:42.000000000 -0700 @@ -125,6 +125,10 @@ static __inline__ int atomic_dec_and_tes { unsigned char c; + if (!atomic_read(v)) { + printk("BUG: atomic counter underflow at:\n"); + dump_stack(); + } __asm__ __volatile__( LOCK_PREFIX "decl %0; sete %1" :"=m" (v->counter), "=qm" (c) _