Skip to content

Commit 29cd8ba

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched: Fix SD_POWERSAVING_BALANCE|SD_PREFER_LOCAL vs SD_WAKE_AFFINE
The SD_POWERSAVING_BALANCE|SD_PREFER_LOCAL code can break out of the domain iteration early, making us miss the SD_WAKE_AFFINE bits. Fix this by continuing iteration until there is no need for a larger domain. This also cleans up the cgroup stuff a bit, but not having two update_shares() invocations. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent de69a80 commit 29cd8ba

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

kernel/sched_fair.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,12 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
13331333
*/
13341334
static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags)
13351335
{
1336-
struct sched_domain *tmp, *shares = NULL, *sd = NULL;
1336+
struct sched_domain *tmp, *affine_sd = NULL, *sd = NULL;
13371337
int cpu = smp_processor_id();
13381338
int prev_cpu = task_cpu(p);
13391339
int new_cpu = cpu;
13401340
int want_affine = 0;
1341+
int want_sd = 1;
13411342
int sync = wake_flags & WF_SYNC;
13421343

13431344
if (sd_flag & SD_BALANCE_WAKE) {
@@ -1369,33 +1370,44 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag
13691370
nr_running /= 2;
13701371

13711372
if (nr_running < capacity)
1372-
break;
1373+
want_sd = 0;
13731374
}
13741375

13751376
if (want_affine && (tmp->flags & SD_WAKE_AFFINE) &&
13761377
cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) {
13771378

1378-
if (sched_feat(LB_SHARES_UPDATE)) {
1379-
update_shares(tmp);
1380-
shares = tmp;
1381-
}
1382-
1383-
if (wake_affine(tmp, p, sync)) {
1384-
new_cpu = cpu;
1385-
goto out;
1386-
}
1387-
1379+
affine_sd = tmp;
13881380
want_affine = 0;
13891381
}
13901382

1383+
if (!want_sd && !want_affine)
1384+
break;
1385+
13911386
if (!(tmp->flags & sd_flag))
13921387
continue;
13931388

1394-
sd = tmp;
1389+
if (want_sd)
1390+
sd = tmp;
1391+
}
1392+
1393+
if (sched_feat(LB_SHARES_UPDATE)) {
1394+
/*
1395+
* Pick the largest domain to update shares over
1396+
*/
1397+
tmp = sd;
1398+
if (affine_sd && (!tmp ||
1399+
cpumask_weight(sched_domain_span(affine_sd)) >
1400+
cpumask_weight(sched_domain_span(sd))))
1401+
tmp = affine_sd;
1402+
1403+
if (tmp)
1404+
update_shares(tmp);
13951405
}
13961406

1397-
if (sd && sd != shares && sched_feat(LB_SHARES_UPDATE))
1398-
update_shares(sd);
1407+
if (affine_sd && wake_affine(affine_sd, p, sync)) {
1408+
new_cpu = cpu;
1409+
goto out;
1410+
}
13991411

14001412
while (sd) {
14011413
int load_idx = sd->forkexec_idx;

0 commit comments

Comments
 (0)