Re: [PATCH v2 1/2] sched/uclamp: Always using uclamp_is_used()

From: Christian Loehle
Date: Wed Feb 19 2025 - 10:59:02 EST


On 2/19/25 09:37, Xuewen Yan wrote:
> Now, we have the uclamp_is_used() func to judge the uclamp enabled,
> so replace the static_branch_unlikely(&sched_uclamp_used) with it.
>
> Signed-off-by: Xuewen Yan <xuewen.yan@xxxxxxxxxx>
> Reviewed-by: Hongyan Xia <hongyan.xia2@xxxxxxx>
> Reviewed-by: Christian Loehle <christian.loehle@xxxxxxx>
> Reviewed-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
> V2:
> - Correct the spelling mistakes in the commit message (Hongyan)
> - Add Reviewed-by
> ---
> ---
> kernel/sched/core.c | 4 ++--
> kernel/sched/sched.h | 28 ++++++++++++++--------------
> 2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 9aecd914ac69..38a7192bfc19 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1757,7 +1757,7 @@ static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p)
> * The condition is constructed such that a NOP is generated when
> * sched_uclamp_used is disabled.
> */
> - if (!static_branch_unlikely(&sched_uclamp_used))
> + if (!uclamp_is_used())
> return;
>
> if (unlikely(!p->sched_class->uclamp_enabled))
> @@ -1784,7 +1784,7 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
> * The condition is constructed such that a NOP is generated when
> * sched_uclamp_used is disabled.
> */
> - if (!static_branch_unlikely(&sched_uclamp_used))
> + if (!uclamp_is_used())
> return;

v2 includes the above two which inverse the likely annotation FYI.