Skip to content

Commit fc9dc69

Browse files
deggemanPeter Zijlstra
authored andcommitted
sched/deadline: Add dl_bw_capacity()
Capacity-aware SCHED_DEADLINE Admission Control (AC) needs root domain (rd) CPU capacity sum. Introduce dl_bw_capacity() which for a symmetric rd w/ a CPU capacity of SCHED_CAPACITY_SCALE simply relies on dl_bw_cpus() to return #CPUs multiplied by SCHED_CAPACITY_SCALE. For an asymmetric rd or a CPU capacity < SCHED_CAPACITY_SCALE it computes the CPU capacity sum over rd span and cpu_active_mask. A 'XXX Fix:' comment was added to highlight that if 'rq->rd == def_root_domain' AC should be performed against the capacity of the CPU the task is running on rather the rd CPU capacity sum. This issue already exists w/o capacity awareness. Signed-off-by: Dietmar Eggemann <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Juri Lelli <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c81b893 commit fc9dc69

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

kernel/sched/deadline.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,34 @@ static inline int dl_bw_cpus(int i)
6969

7070
return cpus;
7171
}
72+
73+
static inline unsigned long __dl_bw_capacity(int i)
74+
{
75+
struct root_domain *rd = cpu_rq(i)->rd;
76+
unsigned long cap = 0;
77+
78+
RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
79+
"sched RCU must be held");
80+
81+
for_each_cpu_and(i, rd->span, cpu_active_mask)
82+
cap += capacity_orig_of(i);
83+
84+
return cap;
85+
}
86+
87+
/*
88+
* XXX Fix: If 'rq->rd == def_root_domain' perform AC against capacity
89+
* of the CPU the task is running on rather rd's \Sum CPU capacity.
90+
*/
91+
static inline unsigned long dl_bw_capacity(int i)
92+
{
93+
if (!static_branch_unlikely(&sched_asym_cpucapacity) &&
94+
capacity_orig_of(i) == SCHED_CAPACITY_SCALE) {
95+
return dl_bw_cpus(i) << SCHED_CAPACITY_SHIFT;
96+
} else {
97+
return __dl_bw_capacity(i);
98+
}
99+
}
72100
#else
73101
static inline struct dl_bw *dl_bw_of(int i)
74102
{
@@ -79,6 +107,11 @@ static inline int dl_bw_cpus(int i)
79107
{
80108
return 1;
81109
}
110+
111+
static inline unsigned long dl_bw_capacity(int i)
112+
{
113+
return SCHED_CAPACITY_SCALE;
114+
}
82115
#endif
83116

84117
static inline

0 commit comments

Comments
 (0)