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-x86/atomic_32.h | 5 +++++ 1 file changed, 5 insertions(+) diff -puN include/asm-x86/atomic_32.h~detect-atomic-counter-underflows include/asm-x86/atomic_32.h --- a/include/asm-x86/atomic_32.h~detect-atomic-counter-underflows +++ a/include/asm-x86/atomic_32.h @@ -121,6 +121,11 @@ static inline int atomic_dec_and_test(at { 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) : : "memory"); _