Skip to contentSkip to conversation

sched: call resched_task() conditionally from new task wake up path.

PATCH In review Bharata B Rao 3 participants 3 messages Aug 28, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: call resched_task() conditionally from new task wake up path.

Hi,

sched: call resched_task() conditionally from new task wake up path.

- During wake up of a new task, task_new_fair() can do a resched_task() on the current task. Later in the code path, check_preempt_curr() also ends up doing the same, which can be avoided. Check if TIF_NEED_RESCHED is already set for the current task.

- task_new_fair() does a resched_task() on the current task unconditionally. This can be done only in case when child runs before the parent.

CC Srivatsa Vaddagiri <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched_fair.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/sched_fair.c +8 -1
@@ -1348,6 +1348,13 @@ static void check_preempt_wakeup(struct 
 	if (unlikely(se == pse))
 		return;
 
+	/*
+	 * We can come here with TIF_NEED_RESCHED already set from new task
+	 * wake up path.
+	 */
+	if (test_tsk_need_resched(curr))
+		return;
+
 	cfs_rq_of(pse)->next = pse;
 
 	/*
@@ -1615,10 +1622,10 @@ static void task_new_fair(struct rq *rq,
 		 * 'current' within the tree based on its new key value.
 		 */
 		swap(curr->vruntime, se->vruntime);
+		resched_task(rq->curr);
 	}
 
 	enqueue_task_fair(rq, p, 0);
-	resched_task(rq->curr);
 }
 
 /*

Regards,
Bharata.

#1 lore raw
Quoted 9 lines · Bharata B Rao

Hi,

sched: call resched_task() conditionally from new task wake up path.

- During wake up of a new task, task_new_fair() can do a resched_task() on the current task. Later in the code path, check_preempt_curr() also ends up doing the same, which can be avoided. Check if TIF_NEED_RESCHED is already set for the current task.

Quoted 4 lines

- task_new_fair() does a resched_task() on the current task unconditionally. This can be done only in case when child runs before the parent.

well spotted - applied to tip/sched/devel, thanks Bharata.

Ingo

Acked-by on v1 1/1
#2 lore raw
In reply to Bharata B Rao
Quoted 9 lines · Bharata B Rao

Hi,

sched: call resched_task() conditionally from new task wake up path.

- During wake up of a new task, task_new_fair() can do a resched_task() on the current task. Later in the code path, check_preempt_curr() also ends up doing the same, which can be avoided. Check if TIF_NEED_RESCHED is already set for the current task.

Quoted 5 lines

- task_new_fair() does a resched_task() on the current task unconditionally. This can be done only in case when child runs before the parent.

CC Srivatsa Vaddagiri <[email protected]>
Quoted 36 lines
CC Ingo Molnar <[email protected]>
---
 kernel/sched_fair.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/sched_fair.c +8 -1
@@ -1348,6 +1348,13 @@ static void check_preempt_wakeup(struct 
 	if (unlikely(se == pse))
 		return;
 
+	/*
+	 * We can come here with TIF_NEED_RESCHED already set from new task
+	 * wake up path.
+	 */
+	if (test_tsk_need_resched(curr))
+		return;
+
 	cfs_rq_of(pse)->next = pse;
 
 	/*
@@ -1615,10 +1622,10 @@ static void task_new_fair(struct rq *rq,
 		 * 'current' within the tree based on its new key value.
 		 */
 		swap(curr->vruntime, se->vruntime);
+		resched_task(rq->curr);
 	}
 
 	enqueue_task_fair(rq, p, 0);
-	resched_task(rq->curr);
 }
 
 /*

Regards,
Bharata.