mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] schedule() in_atomic() fix
@ 2002-09-18  4:46 Robert Love
       [not found] ` <3D88099C.9B5F044D@digeo.com>
  2002-09-18 15:06 ` Robert Love
  0 siblings, 2 replies; 3+ messages in thread
From: Robert Love @ 2002-09-18  4:46 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus,

Attached patch fixes the scheduler in_atomic() problem with kernel
preemption enabled (and is also working - when kernel preemption is on,
it finds a couple issues during boot).

I hope this approach is to your liking.

Patch is against current BK, please apply.

	Robert Love

diff -urN linux-2.5.36/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.36/kernel/sched.c	Tue Sep 17 20:58:48 2002
+++ linux/kernel/sched.c	Wed Sep 18 00:41:09 2002
@@ -940,9 +940,6 @@
 	struct list_head *queue;
 	int idx;
 
-	if (unlikely(in_atomic()))
-		BUG();
-
 #if CONFIG_DEBUG_HIGHMEM
 	check_highmem_ptes();
 #endif
@@ -950,8 +947,20 @@
 	preempt_disable();
 	prev = current;
 	rq = this_rq();
-
 	release_kernel_lock(prev);
+
+	/*
+	 * Test if we are atomic.  Since do_exit() needs to call into
+	 * schedule() atomically, we ignore that for now.  Otherwise,
+	 * whine if we are scheduling when we should not be.
+	 */
+	if (likely(current->state != TASK_ZOMBIE)) {
+		if (unlikely((preempt_count() & ~PREEMPT_ACTIVE) != 1)) {
+			printk(KERN_ERR "scheduling while non-atomic!\n");
+			dump_stack();
+		}
+	}
+
 	prev->sleep_timestamp = jiffies;
 	spin_lock_irq(&rq->lock);
 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] schedule() in_atomic() fix
       [not found] ` <3D88099C.9B5F044D@digeo.com>
@ 2002-09-18  5:09   ` Robert Love
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Love @ 2002-09-18  5:09 UTC (permalink / raw)
  To: linux-kernel, torvalds; +Cc: Andrew Morton

On Wed, 2002-09-18 at 01:05, Andrew Morton wrote:

> Robert Love wrote:
> > 
> > +    printk(KERN_ERR "scheduling while non-atomic!\n");
> 
> When did this become illegal?  :-)

Ugh, reality is blurred... thanks.

Linus, this patch reduces the kernel by 4 bytes over the previous. 
Please, apply.

	Robert Love

diff -urN linux-2.5.36/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.36/kernel/sched.c	Tue Sep 17 20:58:48 2002
+++ linux/kernel/sched.c	Wed Sep 18 00:41:09 2002
@@ -940,9 +940,6 @@
 	struct list_head *queue;
 	int idx;
 
-	if (unlikely(in_atomic()))
-		BUG();
-
 #if CONFIG_DEBUG_HIGHMEM
 	check_highmem_ptes();
 #endif
@@ -950,8 +947,20 @@
 	preempt_disable();
 	prev = current;
 	rq = this_rq();
-
 	release_kernel_lock(prev);
+
+	/*
+	 * Test if we are atomic.  Since do_exit() needs to call into
+	 * schedule() atomically, we ignore that for now.  Otherwise,
+	 * whine if we are scheduling when we should not be.
+	 */
+	if (likely(current->state != TASK_ZOMBIE)) {
+		if (unlikely((preempt_count() & ~PREEMPT_ACTIVE) != 1)) {
+			printk(KERN_ERR "scheduling while atomic!\n");
+			dump_stack();
+		}
+	}
+
 	prev->sleep_timestamp = jiffies;
 	spin_lock_irq(&rq->lock);
 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] schedule() in_atomic() fix
  2002-09-18  4:46 [PATCH] schedule() in_atomic() fix Robert Love
       [not found] ` <3D88099C.9B5F044D@digeo.com>
@ 2002-09-18 15:06 ` Robert Love
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Love @ 2002-09-18 15:06 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

On Wed, 2002-09-18 at 00:46, Robert Love wrote:

> Attached patch fixes the scheduler in_atomic() problem with kernel
> preemption enabled (and is also working - when kernel preemption is on,
> it finds a couple issues during boot).

Attached version works with non-CONFIG_PREEMPT ...

	Robert Love

diff -urN linux-2.5.36/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.36/kernel/sched.c	Tue Sep 17 20:58:48 2002
+++ linux/kernel/sched.c	Wed Sep 18 11:03:44 2002
@@ -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 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 "scheduling while atomic!\n");
+			dump_stack();
+		}
+	}
 
 #if CONFIG_DEBUG_HIGHMEM
 	check_highmem_ptes();


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-18 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-18  4:46 [PATCH] schedule() in_atomic() fix Robert Love
     [not found] ` <3D88099C.9B5F044D@digeo.com>
2002-09-18  5:09   ` Robert Love
2002-09-18 15:06 ` Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®