Skip to content

Commit 41d4200

Browse files
jlelliPeter Zijlstra
authored andcommitted
sched/deadline: Restore dl_server bandwidth on non-destructive root domain changes
When root domain non-destructive changes (e.g., only modifying one of the existing root domains while the rest is not touched) happen we still need to clear DEADLINE bandwidth accounting so that it's then properly restored, taking into account DEADLINE tasks associated to each cpuset (associated to each root domain). After the introduction of dl_servers, we fail to restore such servers contribution after non-destructive changes (as they are only considered on destructive changes when runqueues are attached to the new domains). Fix this by making sure we iterate over the dl_servers attached to domains that have not been destroyed and add their bandwidth contribution back correctly. Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Phil Auld <[email protected]> Tested-by: Waiman Long <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 59297e2 commit 41d4200

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

kernel/sched/deadline.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,11 +2960,22 @@ void dl_add_task_root_domain(struct task_struct *p)
29602960

29612961
void dl_clear_root_domain(struct root_domain *rd)
29622962
{
2963-
unsigned long flags;
2963+
int i;
29642964

2965-
raw_spin_lock_irqsave(&rd->dl_bw.lock, flags);
2965+
guard(raw_spinlock_irqsave)(&rd->dl_bw.lock);
29662966
rd->dl_bw.total_bw = 0;
2967-
raw_spin_unlock_irqrestore(&rd->dl_bw.lock, flags);
2967+
2968+
/*
2969+
* dl_server bandwidth is only restored when CPUs are attached to root
2970+
* domains (after domains are created or CPUs moved back to the
2971+
* default root doamin).
2972+
*/
2973+
for_each_cpu(i, rd->span) {
2974+
struct sched_dl_entity *dl_se = &cpu_rq(i)->fair_server;
2975+
2976+
if (dl_server(dl_se) && cpu_active(i))
2977+
rd->dl_bw.total_bw += dl_se->dl_bw;
2978+
}
29682979
}
29692980

29702981
#endif /* CONFIG_SMP */

kernel/sched/topology.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,9 +2721,11 @@ void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[],
27212721

27222722
/*
27232723
* This domain won't be destroyed and as such
2724-
* its dl_bw->total_bw needs to be cleared. It
2725-
* will be recomputed in function
2726-
* update_tasks_root_domain().
2724+
* its dl_bw->total_bw needs to be cleared.
2725+
* Tasks contribution will be then recomputed
2726+
* in function dl_update_tasks_root_domain(),
2727+
* dl_servers contribution in function
2728+
* dl_restore_server_root_domain().
27272729
*/
27282730
rd = cpu_rq(cpumask_any(doms_cur[i]))->rd;
27292731
dl_clear_root_domain(rd);

0 commit comments

Comments
 (0)