Skip to contentSkip to conversation

sched/fair: Push down check for high priority class task into idle_balance()

PATCH In review Kirill Tkhai 3 participants 3 messages Mar 6, 2014 – Mar 11, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sched/fair: Push down check for high priority class task into idle_balance()

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

CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/fair.c      |   15 ++++++++++-----
 kernel/sched/idle_task.c |    1 -
 2 files changed, 10 insertions(+), 6 deletions(-)
kernel/sched/fair.c +10 -5
index d8482e1..b956e70 100644
@@ -4787,17 +4787,16 @@ simple:
 	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;
@@ -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;
 }
kernel/sched/idle_task.c +0 -1
index 1f37258..879f2b7 100644
@@ -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;
 }
 
maintainer
#1 lore raw
Quoted 3 lines · Kirill Tkhai

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

Thanks Kirill.

#2 lore raw
In reply to Kirill Tkhai
sched/fair: Push down check for high priority class task into idle_balance()
Commit-ID:  e4aa358b6c23f98b2715594f6b1e9a4996a55f04
Gitweb:     http://git.kernel.org/tip/e4aa358b6c23f98b2715594f6b1e9a4996a55f04
Author:     Kirill Tkhai <[email protected]>
AuthorDate: Thu, 6 Mar 2014 13:31:55 +0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 11 Mar 2014 12:05:37 +0100

sched/fair: Push down check for high priority class task into idle_balance()

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

---
 kernel/sched/fair.c      | 15 ++++++++++-----
 kernel/sched/idle_task.c |  1 -
 2 files changed, 10 insertions(+), 6 deletions(-)
kernel/sched/fair.c +10 -5
index d8482e1..b956e70 100644
@@ -4787,17 +4787,16 @@ simple:
 	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;
@@ -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;
 }
kernel/sched/idle_task.c +0 -1
index 1f37258..879f2b7 100644
@@ -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;
 }