Skip to content

Commit f1304ec

Browse files
deggemanPeter Zijlstra
authored andcommitted
sched/deadline: Move bandwidth mgmt and reclaim functions into sched class source file
Move the deadline bandwidth management (admission control) functions __dl_add(), __dl_sub() and __dl_overflow() as well as the bandwidth reclaim function __dl_update() from private task scheduler header file to the deadline sched class source file. The functions are only used internally so they don't have to be exported. Signed-off-by: Dietmar Eggemann <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Juri Lelli <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eb77cf1 commit f1304ec

File tree

2 files changed

+44
-49
lines changed

2 files changed

+44
-49
lines changed

kernel/sched/deadline.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ static inline bool dl_bw_visited(int cpu, u64 gen)
128128
rd->visit_gen = gen;
129129
return false;
130130
}
131+
132+
static inline
133+
void __dl_update(struct dl_bw *dl_b, s64 bw)
134+
{
135+
struct root_domain *rd = container_of(dl_b, struct root_domain, dl_bw);
136+
int i;
137+
138+
RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
139+
"sched RCU must be held");
140+
for_each_cpu_and(i, rd->span, cpu_active_mask) {
141+
struct rq *rq = cpu_rq(i);
142+
143+
rq->dl.extra_bw += bw;
144+
}
145+
}
131146
#else
132147
static inline struct dl_bw *dl_bw_of(int i)
133148
{
@@ -148,8 +163,37 @@ static inline bool dl_bw_visited(int cpu, u64 gen)
148163
{
149164
return false;
150165
}
166+
167+
static inline
168+
void __dl_update(struct dl_bw *dl_b, s64 bw)
169+
{
170+
struct dl_rq *dl = container_of(dl_b, struct dl_rq, dl_bw);
171+
172+
dl->extra_bw += bw;
173+
}
151174
#endif
152175

176+
static inline
177+
void __dl_sub(struct dl_bw *dl_b, u64 tsk_bw, int cpus)
178+
{
179+
dl_b->total_bw -= tsk_bw;
180+
__dl_update(dl_b, (s32)tsk_bw / cpus);
181+
}
182+
183+
static inline
184+
void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus)
185+
{
186+
dl_b->total_bw += tsk_bw;
187+
__dl_update(dl_b, -((s32)tsk_bw / cpus));
188+
}
189+
190+
static inline bool
191+
__dl_overflow(struct dl_bw *dl_b, unsigned long cap, u64 old_bw, u64 new_bw)
192+
{
193+
return dl_b->bw != -1 &&
194+
cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw;
195+
}
196+
153197
static inline
154198
void __add_running_bw(u64 dl_bw, struct dl_rq *dl_rq)
155199
{

kernel/sched/sched.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -301,29 +301,6 @@ struct dl_bw {
301301
u64 total_bw;
302302
};
303303

304-
static inline void __dl_update(struct dl_bw *dl_b, s64 bw);
305-
306-
static inline
307-
void __dl_sub(struct dl_bw *dl_b, u64 tsk_bw, int cpus)
308-
{
309-
dl_b->total_bw -= tsk_bw;
310-
__dl_update(dl_b, (s32)tsk_bw / cpus);
311-
}
312-
313-
static inline
314-
void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus)
315-
{
316-
dl_b->total_bw += tsk_bw;
317-
__dl_update(dl_b, -((s32)tsk_bw / cpus));
318-
}
319-
320-
static inline bool __dl_overflow(struct dl_bw *dl_b, unsigned long cap,
321-
u64 old_bw, u64 new_bw)
322-
{
323-
return dl_b->bw != -1 &&
324-
cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw;
325-
}
326-
327304
/*
328305
* Verify the fitness of task @p to run on @cpu taking into account the
329306
* CPU original capacity and the runtime/deadline ratio of the task.
@@ -2748,32 +2725,6 @@ extern void nohz_run_idle_balance(int cpu);
27482725
static inline void nohz_run_idle_balance(int cpu) { }
27492726
#endif
27502727

2751-
#ifdef CONFIG_SMP
2752-
static inline
2753-
void __dl_update(struct dl_bw *dl_b, s64 bw)
2754-
{
2755-
struct root_domain *rd = container_of(dl_b, struct root_domain, dl_bw);
2756-
int i;
2757-
2758-
RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
2759-
"sched RCU must be held");
2760-
for_each_cpu_and(i, rd->span, cpu_active_mask) {
2761-
struct rq *rq = cpu_rq(i);
2762-
2763-
rq->dl.extra_bw += bw;
2764-
}
2765-
}
2766-
#else
2767-
static inline
2768-
void __dl_update(struct dl_bw *dl_b, s64 bw)
2769-
{
2770-
struct dl_rq *dl = container_of(dl_b, struct dl_rq, dl_bw);
2771-
2772-
dl->extra_bw += bw;
2773-
}
2774-
#endif
2775-
2776-
27772728
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
27782729
struct irqtime {
27792730
u64 total;

0 commit comments

Comments
 (0)