aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2013-01-14 16:47:22 +0000
committerKeir Fraser <keir@xen.org>2013-01-14 16:47:22 +0000
commit836f8188f26db0148e6844d11c15edb66bec7b8f (patch)
treef584a68544af1198d58a7320fdcf75a38c598ea9
parentbc9ae8b5d1e96ccdcf8d9bc9ed7907e7fafc9fe3 (diff)
downloadxen-836f8188f26db0148e6844d11c15edb66bec7b8f.tar.gz
xen-836f8188f26db0148e6844d11c15edb66bec7b8f.tar.bz2
xen-836f8188f26db0148e6844d11c15edb66bec7b8f.zip
xen: Introduce ASSERT_NOT_IN_ATOMIC() to give more info on in_atomic() crash.
Signed-off-by: Keir Fraser <keir@xen.org>
-rw-r--r--xen/common/preempt.c9
-rw-r--r--xen/common/schedule.c2
-rw-r--r--xen/common/softirq.c2
-rw-r--r--xen/common/wait.c2
-rw-r--r--xen/include/asm-x86/asm_defns.h2
-rw-r--r--xen/include/xen/preempt.h6
6 files changed, 16 insertions, 7 deletions
diff --git a/xen/common/preempt.c b/xen/common/preempt.c
index 38f73b023e..ec50dae224 100644
--- a/xen/common/preempt.c
+++ b/xen/common/preempt.c
@@ -31,8 +31,11 @@ bool_t in_atomic(void)
return preempt_count() || in_irq() || !local_irq_is_enabled();
}
-/* asm helper */
-void bug_if_in_atomic(void)
+#ifndef NDEBUG
+void ASSERT_NOT_IN_ATOMIC(void)
{
- BUG_ON(in_atomic());
+ ASSERT(!preempt_count());
+ ASSERT(!in_irq());
+ ASSERT(local_irq_is_enabled());
}
+#endif
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index f3fc6bcc3e..e6a90d85fe 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1086,7 +1086,7 @@ static void schedule(void)
struct task_slice next_slice;
int cpu = smp_processor_id();
- ASSERT(!in_atomic());
+ ASSERT_NOT_IN_ATOMIC();
SCHED_STAT_CRANK(sched_run);
diff --git a/xen/common/softirq.c b/xen/common/softirq.c
index 3f1b302989..ea26825723 100644
--- a/xen/common/softirq.c
+++ b/xen/common/softirq.c
@@ -58,7 +58,7 @@ void process_pending_softirqs(void)
asmlinkage void do_softirq(void)
{
- ASSERT(!in_atomic());
+ ASSERT_NOT_IN_ATOMIC();
__do_softirq(0);
}
diff --git a/xen/common/wait.c b/xen/common/wait.c
index aafeb74510..4d6924fd27 100644
--- a/xen/common/wait.c
+++ b/xen/common/wait.c
@@ -211,7 +211,7 @@ void prepare_to_wait(struct waitqueue_head *wq)
struct vcpu *curr = current;
struct waitqueue_vcpu *wqv = curr->waitqueue_vcpu;
- ASSERT(!in_atomic());
+ ASSERT_NOT_IN_ATOMIC();
__prepare_to_wait(wqv);
ASSERT(list_empty(&wqv->list));
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index d167e33593..81d490559c 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -62,7 +62,7 @@ void ret_from_intr(void);
#ifndef NDEBUG
#define ASSERT_NOT_IN_ATOMIC \
sti; /* sometimes called with interrupts disabled: safe to enable */ \
- call bug_if_in_atomic
+ call ASSERT_NOT_IN_ATOMIC
#else
#define ASSERT_NOT_IN_ATOMIC
#endif
diff --git a/xen/include/xen/preempt.h b/xen/include/xen/preempt.h
index fd02ada12b..bef83135a1 100644
--- a/xen/include/xen/preempt.h
+++ b/xen/include/xen/preempt.h
@@ -28,4 +28,10 @@ DECLARE_PER_CPU(unsigned int, __preempt_count);
bool_t in_atomic(void);
+#ifndef NDEBUG
+void ASSERT_NOT_IN_ATOMIC(void);
+#else
+#define ASSERT_NOT_IN_ATOMIC() ((void)0)
+#endif
+
#endif /* __XEN_PREEMPT_H__ */