From: Ingo Molnar Subject: detect atomic counter underflows 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 --- arch/x86/include/asm/atomic_32.h | 5 +++++ 1 file changed, 5 insertions(+) --- a/arch/x86/include/asm/atomic_32.h +++ b/arch/x86/include/asm/atomic_32.h @@ -113,6 +113,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");