Skip to contentSkip to conversation

schedule() in_atomic() check

PATCH New Robert Love 1 participant 1 message Sep 20, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 schedule() in_atomic() check

Linus,

Resend of patch to make the in_atomic() check in schedule() actually work. You merged the PREEMPT_ACTIVE bits, we just need to handle the exit() case correctly.

Tested with and without CONFIG_PREEMPT -- works like a charm.

Patch is against current BK.

Robert Love

kernel/sched.c +11 -2
diff -urN linux-2.5.37/kernel/sched.c linux/kernel/sched.c
@@ -940,8 +940,17 @@
 	struct list_head *queue;
 	int idx;
 
-	if (unlikely(in_atomic()))
-		BUG();
+	/*
+	 * Test if we are atomic.  Since do_exit() needs to call into
+	 * schedule() atomically, we ignore that path for now.
+	 * Otherwise, whine if we are scheduling when we should not be.
+	 */
+	if (likely(current->state != TASK_ZOMBIE)) {
+		if (unlikely(in_atomic())) {
+			printk(KERN_ERR "bad: scheduling while atomic!\n");
+			dump_stack();
+		}
+	}
 
 #if CONFIG_DEBUG_HIGHMEM
 	check_highmem_ptes();