Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Love <rml@tech9.net>2002-04-03 00:45:42 -0800
committerDave Jones <davej@suse.de>2002-04-03 00:45:42 -0800
commit6a1a68c8febfc71c895a05a10afe6812b7c77584 (patch)
tree3199da192742640421a049f821a3bd233d8e5599
parentda6b470391b402d49e76baf7b28dbfd390eaa7eb (diff)
[PATCH] simple preemption debug check
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
-rw-r--r--include/linux/spinlock.h2
-rw-r--r--kernel/exit.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index cd7428798399..a78cd80f4ab6 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -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)
diff --git a/kernel/exit.c b/kernel/exit.c
index d1a6b1451619..96472474ada7 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -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);