little schedule() cleanup: use cached current value
PATCH 1/1 little schedule() cleanup: use cached current value
Hello.
schedule() can use prev/next instead of get_current().
Oleg.
kernel/sched.c renamed from kernel/sched.c~ +4 -4
@@ -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;
kernel/sched.c switch_tasks: · line 2642
Quoted 9 lines · Oleg Nesterov
kernel/sched.c renamed from kernel/sched.c~ +1
-1@@ -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
Quoted 2 lines · Ingo Molnar
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().
kernel/sched.c renamed from kernel/sched.c~ +3 -3
@@ -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.
Ingo Molnar
Acked-byQuoted 10 lines · Oleg Nesterov
Quoted 2 lines · Ingo Molnar
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 ofget_current().Signed-off-by Oleg Nesterov <[email protected]>
Ingo