Skip to content

Commit 3c18d44

Browse files
Juri LelliIngo Molnar
authored andcommitted
sched/core: Check for available DL bandwidth in cpuset_cpu_inactive()
Hotplug operations are destructive w.r.t. cpusets. In case such an operation is performed on a CPU belonging to an exlusive cpuset, the DL bandwidth information associated with the corresponding root domain is gone even if the operation fails (in sched_cpu_inactive()). For this reason we need to move the check we currently have in sched_cpu_inactive() to cpuset_cpu_inactive() to prevent useless cpusets reconfiguration in the CPU_DOWN_FAILED path. Signed-off-by: Juri Lelli <juri.lelli@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Juri Lelli <juri.lelli@gmail.com> Link: http://lkml.kernel.org/r/1427792017-7356-2-git-send-email-juri.lelli@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 4cd57f9 commit 3c18d44

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

kernel/sched/core.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,36 +5337,13 @@ static int sched_cpu_active(struct notifier_block *nfb,
53375337
static int sched_cpu_inactive(struct notifier_block *nfb,
53385338
unsigned long action, void *hcpu)
53395339
{
5340-
unsigned long flags;
5341-
long cpu = (long)hcpu;
5342-
struct dl_bw *dl_b;
5343-
53445340
switch (action & ~CPU_TASKS_FROZEN) {
53455341
case CPU_DOWN_PREPARE:
5346-
set_cpu_active(cpu, false);
5347-
5348-
/* explicitly allow suspend */
5349-
if (!(action & CPU_TASKS_FROZEN)) {
5350-
bool overflow;
5351-
int cpus;
5352-
5353-
rcu_read_lock_sched();
5354-
dl_b = dl_bw_of(cpu);
5355-
5356-
raw_spin_lock_irqsave(&dl_b->lock, flags);
5357-
cpus = dl_bw_cpus(cpu);
5358-
overflow = __dl_overflow(dl_b, cpus, 0, 0);
5359-
raw_spin_unlock_irqrestore(&dl_b->lock, flags);
5360-
5361-
rcu_read_unlock_sched();
5362-
5363-
if (overflow)
5364-
return notifier_from_errno(-EBUSY);
5365-
}
5342+
set_cpu_active((long)hcpu, false);
53665343
return NOTIFY_OK;
5344+
default:
5345+
return NOTIFY_DONE;
53675346
}
5368-
5369-
return NOTIFY_DONE;
53705347
}
53715348

53725349
static int __init migration_init(void)
@@ -7006,7 +6983,6 @@ static int cpuset_cpu_active(struct notifier_block *nfb, unsigned long action,
70066983
*/
70076984

70086985
case CPU_ONLINE:
7009-
case CPU_DOWN_FAILED:
70106986
cpuset_update_active_cpus(true);
70116987
break;
70126988
default:
@@ -7018,8 +6994,32 @@ static int cpuset_cpu_active(struct notifier_block *nfb, unsigned long action,
70186994
static int cpuset_cpu_inactive(struct notifier_block *nfb, unsigned long action,
70196995
void *hcpu)
70206996
{
7021-
switch (action) {
6997+
unsigned long flags;
6998+
long cpu = (long)hcpu;
6999+
struct dl_bw *dl_b;
7000+
7001+
switch (action & ~CPU_TASKS_FROZEN) {
70227002
case CPU_DOWN_PREPARE:
7003+
/* explicitly allow suspend */
7004+
if (!(action & CPU_TASKS_FROZEN)) {
7005+
bool overflow;
7006+
int cpus;
7007+
7008+
rcu_read_lock_sched();
7009+
dl_b = dl_bw_of(cpu);
7010+
7011+
raw_spin_lock_irqsave(&dl_b->lock, flags);
7012+
cpus = dl_bw_cpus(cpu);
7013+
overflow = __dl_overflow(dl_b, cpus, 0, 0);
7014+
raw_spin_unlock_irqrestore(&dl_b->lock, flags);
7015+
7016+
rcu_read_unlock_sched();
7017+
7018+
if (overflow) {
7019+
trace_printk("hotplug failed for cpu %lu", cpu);
7020+
return notifier_from_errno(-EBUSY);
7021+
}
7022+
}
70237023
cpuset_update_active_cpus(false);
70247024
break;
70257025
case CPU_DOWN_PREPARE_FROZEN:

0 commit comments

Comments
 (0)