mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] little schedule() cleanup: use cached current value
@ 2004-11-09 11:45 Oleg Nesterov
  2004-11-09 12:45 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2004-11-09 11:45 UTC (permalink / raw)
  To: linux-kernel, Ingo Molnar, Andrew Morton

Hello.

schedule() can use prev/next instead of get_current().

Oleg.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.10-rc1/kernel/sched.c~	2004-11-08 19:43:29.000000000 +0300
+++ 2.6.10-rc1/kernel/sched.c	2004-11-08 22:52:26.547195920 +0300
@@ -2508,7 +2508,7 @@ need_resched:
 	 * The idle thread is not allowed to schedule!
 	 * Remove this check after it has been exercised a bit.
 	 */
-	if (unlikely(current == rq->idle) && current->state != TASK_RUNNING) {
+	if (unlikely(prev == rq->idle) && prev->state != TASK_RUNNING) {
 		printk(KERN_ERR "bad: scheduling from the idle thread!\n");
 		dump_stack();
 	}
@@ -2531,8 +2531,8 @@ need_resched:
 
 	spin_lock_irq(&rq->lock);
 
-	if (unlikely(current->flags & PF_DEAD))
-		current->state = EXIT_DEAD;
+	if (unlikely(prev->flags & PF_DEAD))
+		prev->state = EXIT_DEAD;
 	/*
 	 * if entering off of a kernel preemption go straight
 	 * to picking the next task.
@@ -2636,7 +2636,7 @@ switch_tasks:
 	} else
 		spin_unlock_irq(&rq->lock);
 
-	reacquire_kernel_lock(current);
+	reacquire_kernel_lock(next);
 	preempt_enable_no_resched();
 	if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
 		goto need_resched;

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

* Re: [PATCH] little schedule() cleanup: use cached current value
  2004-11-09 11:45 [PATCH] little schedule() cleanup: use cached current value Oleg Nesterov
@ 2004-11-09 12:45 ` Ingo Molnar
  2004-11-09 14:27   ` Oleg Nesterov
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2004-11-09 12:45 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Andrew Morton


* Oleg Nesterov <oleg@tv-sign.ru> wrote:

> @@ -2636,7 +2636,7 @@ switch_tasks:
>  	} else
>  		spin_unlock_irq(&rq->lock);
>  
> -	reacquire_kernel_lock(current);
> +	reacquire_kernel_lock(next);
>  	preempt_enable_no_resched();
>  	if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
>  		goto need_resched;

nack. We switch the kernel stack in switch_to() so 'next' here is the
old task we switched to before we went off the CPU. The value of 'next'
doesnt get carried over a context-switch. (we do carry 'prev' over via
assembly trickery because we need it, but not 'next'.) This change would
most likely result in rare, hard-to-track-down BKL-related crashes all
around the place.

the other bits are OK, please resend them.

	Ingo

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

* Re: [PATCH] little schedule() cleanup: use cached current value
  2004-11-09 12:45 ` Ingo Molnar
@ 2004-11-09 14:27   ` Oleg Nesterov
  2004-11-09 15:32     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2004-11-09 14:27 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Andrew Morton

Ingo Molnar wrote:

> nack. We switch the kernel stack in switch_to() so 'next' here
> is the old task we switched to before we went off the CPU.

yes, sorry. here is corrected patch.

schedule() can use prev instead of get_current().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.10-rc1/kernel/sched.c~	2004-11-09 18:57:45.000000000 +0300
+++ 2.6.10-rc1/kernel/sched.c	2004-11-09 19:16:22.798486040 +0300
@@ -2508,7 +2508,7 @@ need_resched:
 	 * The idle thread is not allowed to schedule!
 	 * Remove this check after it has been exercised a bit.
 	 */
-	if (unlikely(current == rq->idle) && current->state != TASK_RUNNING) {
+	if (unlikely(prev == rq->idle) && prev->state != TASK_RUNNING) {
 		printk(KERN_ERR "bad: scheduling from the idle thread!\n");
 		dump_stack();
 	}
@@ -2531,8 +2531,8 @@ need_resched:
 
 	spin_lock_irq(&rq->lock);
 
-	if (unlikely(current->flags & PF_DEAD))
-		current->state = EXIT_DEAD;
+	if (unlikely(prev->flags & PF_DEAD))
+		prev->state = EXIT_DEAD;
 	/*
 	 * if entering off of a kernel preemption go straight
 	 * to picking the next task.

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

* Re: [PATCH] little schedule() cleanup: use cached current value
  2004-11-09 14:27   ` Oleg Nesterov
@ 2004-11-09 15:32     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2004-11-09 15:32 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Andrew Morton


* Oleg Nesterov <oleg@tv-sign.ru> wrote:

> Ingo Molnar wrote:
> 
> > nack. We switch the kernel stack in switch_to() so 'next' here
> > is the old task we switched to before we went off the CPU.
> 
> yes, sorry. here is corrected patch.
> 
> schedule() can use prev instead of get_current().
> 
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Acked-by: Ingo Molnar <mingo@elte.hu>

	Ingo

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

end of thread, other threads:[~2004-11-09 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-09 11:45 [PATCH] little schedule() cleanup: use cached current value Oleg Nesterov
2004-11-09 12:45 ` Ingo Molnar
2004-11-09 14:27   ` Oleg Nesterov
2004-11-09 15:32     ` Ingo Molnar

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®