Skip to content

Commit

Permalink
sched/fair: Push down check for high priority class task into idle_ba…
Browse files Browse the repository at this point in the history
…lance()

We close idle_exit_fair() bracket in case of we've pulled something or we've received
task of high priority class.

Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Link: http://lkml.kernel.org/r/1394098315.19290.10.camel@tkhai
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Kirill Tkhai authored and Ingo Molnar committed Mar 11, 2014
1 parent 734ff2a commit e4aa358
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 10 additions & 5 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -4787,17 +4787,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
return p;

idle:
new_tasks = idle_balance(rq);
/*
* Because idle_balance() releases (and re-acquires) rq->lock, it is
* possible for any higher priority task to appear. In that case we
* must re-start the pick_next_entity() loop.
*/
new_tasks = idle_balance(rq);

if (rq->nr_running != rq->cfs.h_nr_running)
if (new_tasks < 0)
return RETRY_TASK;

if (new_tasks)
if (new_tasks > 0)
goto again;

return NULL;
Expand Down Expand Up @@ -6728,8 +6727,14 @@ static int idle_balance(struct rq *this_rq)
this_rq->max_idle_balance_cost = curr_cost;

out:
if (pulled_task)
/* Is there a task of a high priority class? */
if (this_rq->nr_running != this_rq->cfs.h_nr_running)
pulled_task = -1;

if (pulled_task) {
idle_exit_fair(this_rq);
this_rq->idle_stamp = 0;
}

return pulled_task;
}
Expand Down
1 change: 0 additions & 1 deletion kernel/sched/idle_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pick_next_task_idle(struct rq *rq, struct task_struct *prev)
put_prev_task(rq, prev);

schedstat_inc(rq, sched_goidle);
idle_enter_fair(rq);
return rq->idle;
}

Expand Down

0 comments on commit e4aa358

Please sign in to comment.