simple preemption debug check
PATCH 1/1 simple preemption debug check
Linus,
This simple check was first suggested by Andrew Morton. Pretty basic - whines if a task exits with a nonzero preempt_count value.
I put an identical check in the 2.4 preempt-kernel patch and - sure enough - it was found that XFS essentially disables preemption as it destroys data structures containing locks without first unlocking. The SGI folks are working on that.
Anyhow, its a quick and clean solution to debugging potential problems. Patch is against 2.5.7, please apply.
Robert Love
include/linux/spinlock.h +1 -1
@@ -204,7 +204,7 @@#else -#define preempt_get_count () do { } while (0) +#define preempt_get_count () (0)#define preempt_disable () do { } while (0)#define preempt_enable_no_resched () do {} while(0)#define preempt_enable () do { } while (0)
kernel/exit.c +5 -0
@@ -492,6 +492,11 @@ tsk->flags |=PF_EXITING ;del_timer_sync (&tsk->real_timer); +if (unlikely (preempt_get_count ())) +printk (KERN_ERR "error: %s[%d] exited with preempt_count %d\n" , + current->comm, current->pid, +preempt_get_count ()); + fake_volatile: #ifdef CONFIG_BSD_PROCESS_ACCTacct_process (code );