[PATCH] BUG(): sched.c: Line 944

Robert Love
2002-09-16T18:44:06Z

Linus,

The current in_atomic() check fails with kernel preemption enabled since
we set preempt_count to PREEMPT_ACTIVE in preempt_schedule().

We need to additionally check whether PREEMPT_ACTIVE is set.

There is also still the issue that bugging out is a bit drastic and a
hindrance to debugging; but I will tackle that later. For now, please
apply this so we can at least boot with preemption enabled.

Patch is against 2.5.35-bk.

Robert Love

diff -urN linux-2.5.35/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.35/kernel/sched.c Sun Sep 15 22:18:24 2002
+++ linux/kernel/sched.c Mon Sep 16 14:43:54 2002
@@ -940,8 +940,7 @@
struct list_head *queue;
int idx;

- if (unlikely(in_atomic()))
- BUG();
+ BUG_ON(in_atomic() && preempt_count() != PREEMPT_ACTIVE);

#if CONFIG_DEBUG_HIGHMEM
check_highmem_ptes();
@@ -959,7 +958,7 @@
* if entering off of a kernel preemption go straight
* to picking the next task.
*/
- if (unlikely(preempt_count() & PREEMPT_ACTIVE))
+ if (unlikely(preempt_count() == PREEMPT_ACTIVE))
goto pick_next_task;

switch (prev->state) {