]> git.hungrycats.org Git - linux/commitdiff
[PATCH] simple preemption debug check
authorRobert Love <rml@tech9.net>
Wed, 3 Apr 2002 08:45:42 +0000 (00:45 -0800)
committerDave Jones <davej@suse.de>
Wed, 3 Apr 2002 08:45:42 +0000 (00:45 -0800)
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
kernel/exit.c

index cd7428798399f408e0c7160fd8426ed91afa6361..a78cd80f4ab638bb7f839ee74d8731b92fc51e67 100644 (file)
@@ -204,7 +204,7 @@ do { \
 
 #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)
index d1a6b145161907472fc11bd46b09d4ddee7a225e..96472474ada781fb43f49d8fa5e066ae7ad5fe1f 100644 (file)
@@ -490,6 +490,11 @@ NORET_TYPE void do_exit(long code)
        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:
        acct_process(code);
        __exit_mm(tsk);