Skip to content

Commit c259e01

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
sched: Separate the scheduler entry for preemption
Block-IO and workqueues call into notifier functions from the scheduler core code with interrupts and preemption disabled. These calls should be made before entering the scheduler core. To simplify this, separate the scheduler core code into __schedule(). __schedule() is directly called from the places which set PREEMPT_ACTIVE and from schedule(). This allows us to add the work checks into schedule(), so they are only called when a task voluntary goes to sleep. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: stable@kernel.org # 2.6.39+ Link: http://lkml.kernel.org/r/20110622174918.813258321@linutronix.de Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent c6a389f commit c259e01

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎kernel/sched.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,9 +4279,9 @@ pick_next_task(struct rq *rq)
42794279
}
42804280

42814281
/*
4282-
* schedule() is the main scheduler function.
4282+
* __schedule() is the main scheduler function.
42834283
*/
4284-
asmlinkage void __sched schedule(void)
4284+
static void __sched __schedule(void)
42854285
{
42864286
struct task_struct *prev, *next;
42874287
unsigned long *switch_count;
@@ -4369,6 +4369,11 @@ asmlinkage void __sched schedule(void)
43694369
if (need_resched())
43704370
goto need_resched;
43714371
}
4372+
4373+
asmlinkage void schedule(void)
4374+
{
4375+
__schedule();
4376+
}
43724377
EXPORT_SYMBOL(schedule);
43734378

43744379
#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
@@ -4435,7 +4440,7 @@ asmlinkage void __sched notrace preempt_schedule(void)
44354440

44364441
do {
44374442
add_preempt_count_notrace(PREEMPT_ACTIVE);
4438-
schedule();
4443+
__schedule();
44394444
sub_preempt_count_notrace(PREEMPT_ACTIVE);
44404445

44414446
/*
@@ -4463,7 +4468,7 @@ asmlinkage void __sched preempt_schedule_irq(void)
44634468
do {
44644469
add_preempt_count(PREEMPT_ACTIVE);
44654470
local_irq_enable();
4466-
schedule();
4471+
__schedule();
44674472
local_irq_disable();
44684473
sub_preempt_count(PREEMPT_ACTIVE);
44694474

@@ -5588,7 +5593,7 @@ static inline int should_resched(void)
55885593
static void __cond_resched(void)
55895594
{
55905595
add_preempt_count(PREEMPT_ACTIVE);
5591-
schedule();
5596+
__schedule();
55925597
sub_preempt_count(PREEMPT_ACTIVE);
55935598
}
55945599

0 commit comments

Comments
 (0)