Skip to content

Commit 5fca5a4

Browse files
Xuewen YanIngo Molnar
authored andcommitted
sched/uclamp: Use the uclamp_is_used() helper instead of open-coding it
Don't open-code static_branch_unlikely(&sched_uclamp_used), we have the uclamp_is_used() wrapper around it. [ mingo: Clean up the changelog ] Signed-off-by: Xuewen Yan <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Hongyan Xia <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Reviewed-by: Vincent Guittot <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e6644c9 commit 5fca5a4

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

kernel/sched/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p)
17561756
* The condition is constructed such that a NOP is generated when
17571757
* sched_uclamp_used is disabled.
17581758
*/
1759-
if (!static_branch_unlikely(&sched_uclamp_used))
1759+
if (!uclamp_is_used())
17601760
return;
17611761

17621762
if (unlikely(!p->sched_class->uclamp_enabled))
@@ -1783,7 +1783,7 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
17831783
* The condition is constructed such that a NOP is generated when
17841784
* sched_uclamp_used is disabled.
17851785
*/
1786-
if (!static_branch_unlikely(&sched_uclamp_used))
1786+
if (!uclamp_is_used())
17871787
return;
17881788

17891789
if (unlikely(!p->sched_class->uclamp_enabled))

kernel/sched/sched.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,6 +3394,19 @@ static inline bool update_other_load_avgs(struct rq *rq) { return false; }
33943394

33953395
unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
33963396

3397+
/*
3398+
* When uclamp is compiled in, the aggregation at rq level is 'turned off'
3399+
* by default in the fast path and only gets turned on once userspace performs
3400+
* an operation that requires it.
3401+
*
3402+
* Returns true if userspace opted-in to use uclamp and aggregation at rq level
3403+
* hence is active.
3404+
*/
3405+
static inline bool uclamp_is_used(void)
3406+
{
3407+
return static_branch_likely(&sched_uclamp_used);
3408+
}
3409+
33973410
static inline unsigned long uclamp_rq_get(struct rq *rq,
33983411
enum uclamp_id clamp_id)
33993412
{
@@ -3417,7 +3430,7 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
34173430
unsigned long rq_util;
34183431
unsigned long max_util;
34193432

3420-
if (!static_branch_likely(&sched_uclamp_used))
3433+
if (!uclamp_is_used())
34213434
return false;
34223435

34233436
rq_util = cpu_util_cfs(cpu_of(rq)) + cpu_util_rt(rq);
@@ -3426,19 +3439,6 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
34263439
return max_util != SCHED_CAPACITY_SCALE && rq_util >= max_util;
34273440
}
34283441

3429-
/*
3430-
* When uclamp is compiled in, the aggregation at rq level is 'turned off'
3431-
* by default in the fast path and only gets turned on once userspace performs
3432-
* an operation that requires it.
3433-
*
3434-
* Returns true if userspace opted-in to use uclamp and aggregation at rq level
3435-
* hence is active.
3436-
*/
3437-
static inline bool uclamp_is_used(void)
3438-
{
3439-
return static_branch_likely(&sched_uclamp_used);
3440-
}
3441-
34423442
#define for_each_clamp_id(clamp_id) \
34433443
for ((clamp_id) = 0; (clamp_id) < UCLAMP_CNT; (clamp_id)++)
34443444

0 commit comments

Comments
 (0)