summaryrefslogtreecommitdiffstats
path: root/include/sys/mutex.h
diff options
context:
space:
mode:
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-04-11 17:03:57 +0000
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-04-11 17:03:57 +0000
commit115aed0dd8eae514d0cfaa37436a66c52926e3be (patch)
tree9088df967245d582c8ef4735989e2a9fb44b55bd /include/sys/mutex.h
parent79f92663e36969c0b6b1f8520b1171285ae3e1d3 (diff)
- Add more strict in_atomic() checking to the mutex entry
function just to be extra safety and paranoid. - Rewrite the thread shim to take full advantage of the new kernel kthread API. This greatly simplifies things. - Add a new regression test for thread_exit() to ensure it properly terminates a thread immediately without allowing futher execution of the thread. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@69 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
Diffstat (limited to 'include/sys/mutex.h')
-rw-r--r--include/sys/mutex.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/sys/mutex.h b/include/sys/mutex.h
index 2db4a7f96..ca76d6ea9 100644
--- a/include/sys/mutex.h
+++ b/include/sys/mutex.h
@@ -6,6 +6,7 @@ extern "C" {
#endif
#include <linux/module.h>
+#include <linux/hardirq.h>
#include <sys/types.h>
/* See the "Big Theory Statement" in solaris mutex.c.
@@ -65,6 +66,14 @@ static __inline__ void
mutex_enter(kmutex_t *mp)
{
BUG_ON(mp->km_magic != KM_MAGIC);
+
+ if (unlikely(in_atomic() && !current->exit_state)) {
+ dump_stack();
+ printk("Scheduling while atomic: %s/0x%08x/%d\n",
+ current->comm, preempt_count(), current->pid);
+ BUG();
+ }
+
down(&mp->km_sem); /* Will check in_atomic() for us */
BUG_ON(mp->km_owner != NULL);
mp->km_owner = current;
@@ -78,6 +87,14 @@ mutex_tryenter(kmutex_t *mp)
int result;
BUG_ON(mp->km_magic != KM_MAGIC);
+
+ if (unlikely(in_atomic() && !current->exit_state)) {
+ dump_stack();
+ printk("Scheduling while atomic: %s/0x%08x/%d\n",
+ current->comm, preempt_count(), current->pid);
+ BUG();
+ }
+
result = down_trylock(&mp->km_sem); /* returns 0 if acquired */
if (result == 0) {
BUG_ON(mp->km_owner != NULL);