mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] sched/uclamp: Always using uclamp_is_used()
@ 2025-02-19  9:37 Xuewen Yan
  2025-02-19  9:37 ` [PATCH v2 2/2] sched/uclamp: Add uclamp_is_used() check before enable it Xuewen Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Xuewen Yan @ 2025-02-19  9:37 UTC (permalink / raw)
  To: vincent.guittot, mingo, peterz, juri.lelli
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	christian.loehle, hongyan.xia2, ke.wang, di.shen, xuewen.yan94,
	linux-kernel

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@unisoc.com>
Reviewed-by: Hongyan Xia <hongyan.xia2@arm.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
---
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;
 
 	if (unlikely(!p->sched_class->uclamp_enabled))
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index b93c8c3dc05a..3624fdce5536 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3394,6 +3394,19 @@ static inline bool update_other_load_avgs(struct rq *rq) { return false; }
 
 unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
 
+/*
+ * When uclamp is compiled in, the aggregation at rq level is 'turned off'
+ * by default in the fast path and only gets turned on once userspace performs
+ * an operation that requires it.
+ *
+ * Returns true if userspace opted-in to use uclamp and aggregation at rq level
+ * hence is active.
+ */
+static inline bool uclamp_is_used(void)
+{
+	return static_branch_likely(&sched_uclamp_used);
+}
+
 static inline unsigned long uclamp_rq_get(struct rq *rq,
 					  enum uclamp_id clamp_id)
 {
@@ -3417,7 +3430,7 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
 	unsigned long rq_util;
 	unsigned long max_util;
 
-	if (!static_branch_likely(&sched_uclamp_used))
+	if (!uclamp_is_used())
 		return false;
 
 	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)
 	return max_util != SCHED_CAPACITY_SCALE && rq_util >= max_util;
 }
 
-/*
- * When uclamp is compiled in, the aggregation at rq level is 'turned off'
- * by default in the fast path and only gets turned on once userspace performs
- * an operation that requires it.
- *
- * Returns true if userspace opted-in to use uclamp and aggregation at rq level
- * hence is active.
- */
-static inline bool uclamp_is_used(void)
-{
-	return static_branch_likely(&sched_uclamp_used);
-}
-
 #define for_each_clamp_id(clamp_id) \
 	for ((clamp_id) = 0; (clamp_id) < UCLAMP_CNT; (clamp_id)++)
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-15  9:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-19  9:37 [PATCH v2 1/2] sched/uclamp: Always using uclamp_is_used() Xuewen Yan
2025-02-19  9:37 ` [PATCH v2 2/2] sched/uclamp: Add uclamp_is_used() check before enable it Xuewen Yan
2025-02-19 15:59   ` Christian Loehle
2025-02-19 16:25   ` Vincent Guittot
2025-03-14 20:24   ` [tip: sched/core] " tip-bot2 for Xuewen Yan
2025-03-15  9:37   ` [tip: sched/core] sched/uclamp: Optimize sched_uclamp_used static key enabling tip-bot2 for Xuewen Yan
2025-02-19 15:57 ` [PATCH v2 1/2] sched/uclamp: Always using uclamp_is_used() Christian Loehle
2025-03-14 20:24 ` [tip: sched/core] " tip-bot2 for Xuewen Yan
2025-03-15  9:37 ` [tip: sched/core] sched/uclamp: Use the uclamp_is_used() helper instead of open-coding it tip-bot2 for Xuewen Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®