Skip to contentSkip to conversation

sched/fair: Sync task util before slow-path wakeup

PATCH In review Brendan Jackman 2 participants 3 messages Aug 8, 2017 – Oct 10, 2017 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched/fair: Sync task util before slow-path wakeup

We use task_util in find_idlest_group via capacity_spare_wake. This task_util is updated in wake_cap. However wake_cap is not the only reason for ending up in find_idlest_group - we could have been sent there by wake_wide. So explicitly sync the task util with prev_cpu when we are about to head to find_idlest_group.

We could simply do this at the beginning of select_task_rq_fair (i.e. irrespective of whether we're heading to select_idle_sibling or find_idlest_group & co), but I didn't want to slow down the select_idle_sibling path more than necessary.

Don't do this during fork balancing, we won't need the task_util and we'd just clobber the last_update_time, which is supposed to be 0.

Cc Dietmar Eggemann <[email protected]>
Cc Vincent Guittot <[email protected]>
Cc Josef Bacik <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Morten Rasmussen <[email protected]>
Cc Peter Zijlstra <[email protected]>

---

changes v1 -> v2: Just cosmetic

 kernel/sched/fair.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/sched/fair.c +10 -1
index c95880e216f6..20275178604d 100644
@@ -5913,8 +5913,17 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
 			new_cpu = cpu;
 	}
 
+	if (sd && !(sd_flag & SD_BALANCE_FORK)) {
+		/*
+		 * We're going to need the task's util for capacity_spare_wake
+		 * in find_idlest_group. Sync it up to prev_cpu's
+		 * last_update_time.
+		 */
+		sync_entity_load_avg(&p->se);
+	}
+
 	if (!sd) {
- pick_cpu:
+pick_cpu:
 		if (sd_flag & SD_BALANCE_WAKE) /* XXX always ? */
 			new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
 

--
2.13.0

#1 lore raw

Hi Peter,

Ping.

Log of previous discussion: https://patchwork.kernel.org/patch/9876769/

Cheers,
Brendan

Quoted 50 lines · Brendan Jackman

We use task_util in find_idlest_group via capacity_spare_wake. This task_util is updated in wake_cap. However wake_cap is not the only reason for ending up in find_idlest_group - we could have been sent there by wake_wide. So explicitly sync the task util with prev_cpu when we are about to head to find_idlest_group.

We could simply do this at the beginning of select_task_rq_fair (i.e. irrespective of whether we're heading to select_idle_sibling or find_idlest_group & co), but I didn't want to slow down the select_idle_sibling path more than necessary.

Don't do this during fork balancing, we won't need the task_util and we'd just clobber the last_update_time, which is supposed to be 0.

Cc Dietmar Eggemann <[email protected]>
Cc Vincent Guittot <[email protected]>
Cc Josef Bacik <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Morten Rasmussen <[email protected]>
Cc Peter Zijlstra <[email protected]>

---

changes v1 -> v2: Just cosmetic

 kernel/sched/fair.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/sched/fair.c +10 -1
index c95880e216f6..20275178604d 100644
@@ -5913,8 +5913,17 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
 			new_cpu = cpu;
 	}
 
+	if (sd && !(sd_flag & SD_BALANCE_FORK)) {
+		/*
+		 * We're going to need the task's util for capacity_spare_wake
+		 * in find_idlest_group. Sync it up to prev_cpu's
+		 * last_update_time.
+		 */
+		sync_entity_load_avg(&p->se);
+	}
+
 	if (!sd) {
- pick_cpu:
+pick_cpu:
 		if (sd_flag & SD_BALANCE_WAKE) /* XXX always ? */
 			new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
#2 lore raw
In reply to Brendan Jackman
sched/fair: Sync task util before slow-path wakeup
Commit-ID:  ea16f0ea6c3dc9e1aa083bd3d1792ba02860526e
Gitweb:     https://git.kernel.org/tip/ea16f0ea6c3dc9e1aa083bd3d1792ba02860526e
Author:     Brendan Jackman <[email protected]>
AuthorDate: Thu, 5 Oct 2017 11:55:51 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Oct 2017 11:45:31 +0200

sched/fair: Sync task util before slow-path wakeup

We use task_util() in find_idlest_group() via capacity_spare_wake(). This task_util() updated in wake_cap(). However wake_cap() is not the only reason for ending up in find_idlest_group() - we could have been sent there by wake_wide(). So explicitly sync the task util with prev_cpu when we are about to head to find_idlest_group().

We could simply do this at the beginning of select_task_rq_fair() (i.e. irrespective of whether we're heading to select_idle_sibling() or find_idlest_group() & co), but I didn't want to slow down the select_idle_sibling() path more than necessary.

Don't do this during fork balancing, we won't need the task_util and we'd just clobber the last_update_time, which is supposed to be 0.

Cc Andres Oportus <[email protected]>
Cc Dietmar Eggemann <[email protected]>
Cc Joel Fernandes <[email protected]>
Cc Josef Bacik <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Morten Rasmussen <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincent Guittot <[email protected]>
---
 kernel/sched/fair.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/sched/fair.c +10 -1
index cc0bfb0..c04a425 100644
@@ -6263,8 +6263,17 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
 			new_cpu = cpu;
 	}
 
+	if (sd && !(sd_flag & SD_BALANCE_FORK)) {
+		/*
+		 * We're going to need the task's util for capacity_spare_wake
+		 * in find_idlest_group. Sync it up to prev_cpu's
+		 * last_update_time.
+		 */
+		sync_entity_load_avg(&p->se);
+	}
+
 	if (!sd) {
- pick_cpu:
+pick_cpu:
 		if (sd_flag & SD_BALANCE_WAKE) /* XXX always ? */
 			new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);