Skip to content

Commit 411440d

Browse files
committed
sched/uclamp: Use the uclamp_is_used() helper instead of open-coding it
JIRA: https://issues.redhat.com/browse/RHEL-110301 commit 5fca5a4 Author: Xuewen Yan <[email protected]> Date: Wed Feb 19 17:37:46 2025 +0800 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] Signed-off-by: Phil Auld <[email protected]>
1 parent e80aade commit 411440d

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
@@ -1732,7 +1732,7 @@ static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p, int flags
17321732
* The condition is constructed such that a NOP is generated when
17331733
* sched_uclamp_used is disabled.
17341734
*/
1735-
if (!static_branch_unlikely(&sched_uclamp_used))
1735+
if (!uclamp_is_used())
17361736
return;
17371737

17381738
if (unlikely(!p->sched_class->uclamp_enabled))
@@ -1760,7 +1760,7 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
17601760
* The condition is constructed such that a NOP is generated when
17611761
* sched_uclamp_used is disabled.
17621762
*/
1763-
if (!static_branch_unlikely(&sched_uclamp_used))
1763+
if (!uclamp_is_used())
17641764
return;
17651765

17661766
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
@@ -3240,6 +3240,19 @@ static inline unsigned long cpu_util_rt(struct rq *rq)
32403240

32413241
unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
32423242

3243+
/*
3244+
* When uclamp is compiled in, the aggregation at rq level is 'turned off'
3245+
* by default in the fast path and only gets turned on once userspace performs
3246+
* an operation that requires it.
3247+
*
3248+
* Returns true if userspace opted-in to use uclamp and aggregation at rq level
3249+
* hence is active.
3250+
*/
3251+
static inline bool uclamp_is_used(void)
3252+
{
3253+
return static_branch_likely(&sched_uclamp_used);
3254+
}
3255+
32433256
static inline unsigned long uclamp_rq_get(struct rq *rq,
32443257
enum uclamp_id clamp_id)
32453258
{
@@ -3263,7 +3276,7 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
32633276
unsigned long rq_util;
32643277
unsigned long max_util;
32653278

3266-
if (!static_branch_likely(&sched_uclamp_used))
3279+
if (!uclamp_is_used())
32673280
return false;
32683281

32693282
rq_util = cpu_util_cfs(cpu_of(rq)) + cpu_util_rt(rq);
@@ -3272,19 +3285,6 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
32723285
return max_util != SCHED_CAPACITY_SCALE && rq_util >= max_util;
32733286
}
32743287

3275-
/*
3276-
* When uclamp is compiled in, the aggregation at rq level is 'turned off'
3277-
* by default in the fast path and only gets turned on once userspace performs
3278-
* an operation that requires it.
3279-
*
3280-
* Returns true if userspace opted-in to use uclamp and aggregation at rq level
3281-
* hence is active.
3282-
*/
3283-
static inline bool uclamp_is_used(void)
3284-
{
3285-
return static_branch_likely(&sched_uclamp_used);
3286-
}
3287-
32883288
#define for_each_clamp_id(clamp_id) \
32893289
for ((clamp_id) = 0; (clamp_id) < UCLAMP_CNT; (clamp_id)++)
32903290

0 commit comments

Comments
 (0)