sched/uclamp: Always using uclamp_is_used()
PATCH v2 1/2 sched/uclamp: Always using uclamp_is_used()
Now, we have the uclamp_is_used() func to judge the uclamp enabled, so replace the static_branch_unlikely(&sched_uclamp_used) with it.
---
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(-)
kernel/sched/core.c +2 -2
@@ -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))
kernel/sched/sched.h +14 -14
@@ -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)++)
Signature · 1 line
2.25.1
PATCH v2 2/2 sched/uclamp: Add uclamp_is_used() check before enable it
Because the static_branch_enable() would get the cpus_read_lock(), and sometimes users may frequently set the uclamp value of tasks, and this operation would call the static_branch_enable() frequently, so add the uclamp_is_used() check to prevent calling the cpus_read_lock() frequently.
And to make the code more concise, add a helper function to encapsulate this and use it everywhere we enable sched_uclamp_used.
---
V2:
- change some commit message;
- Add a helper function and use it everywhere when enable uclamp (Vincent)
---
--- kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 14 ++++++++++++++ kernel/sched/syscalls.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -3
@@ -1942,12 +1942,12 @@ static int sysctl_sched_uclamp_handler(const struct ctl_table *table, int write, }if (update_root_tg) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_update_root_tg (); }if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_sync_util_min_rt_default (); }
@@ -9295,7 +9295,7 @@ static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,if (req.ret)return req.ret; -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();guard (mutex)(&uclamp_mutex);guard (rcu)();
kernel/sched/sched.h +14 -0
@@ -3407,6 +3407,18 @@ static inline bool uclamp_is_used(void)return static_branch_likely (&sched_uclamp_used); } +/* +* Enabling static branches would get the cpus_read_lock(), +* check whether uclamp_is_used before enable it to avoid always +* calling cpus_read_lock(). Because we never disable this +* static key once enable it. +*/ +static inline void sched_uclamp_enable (void ) +{ +if (!uclamp_is_used ()) +static_branch_enable (&sched_uclamp_used); +} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
@@ -3486,6 +3498,8 @@ static inline bool uclamp_is_used(void)return false; } +static inline void sched_uclamp_enable (void ) {} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
kernel/sched/syscalls.c +1 -1
@@ -368,7 +368,7 @@ static int uclamp_validate(struct task_struct *p,* blocking operation which obviously cannot be done while holding * scheduler locks. */ -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();return 0 ; }
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] sched/uclamp: Add uclamp_is_used() check before enable it
Quoted 58 lines · Xuewen Yan
Because the
static_branch_enable()would get thecpus_read_lock(), and sometimes users may frequently set the uclamp value of tasks, and this operation would call thestatic_branch_enable()frequently, so add theuclamp_is_used()check to prevent calling thecpus_read_lock()frequently.
And to make the code more concise, add a helper function to encapsulate this and use it everywhere we enablesched_uclamp_used.Signed-off-by Xuewen Yan <[email protected]>---
V2:
- change some commit message;
- Add a helper function and use it everywhere when enable uclamp (Vincent)
------ kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 14 ++++++++++++++ kernel/sched/syscalls.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)kernel/sched/core.c +3
-3@@ -1942,12 +1942,12 @@ static int sysctl_sched_uclamp_handler(const struct ctl_table *table, int write, }if (update_root_tg) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_update_root_tg (); }if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_sync_util_min_rt_default (); }@@ -9295,7 +9295,7 @@ static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,if (req.ret)return req.ret; -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();guard (mutex)(&uclamp_mutex);guard (rcu)();kernel/sched/sched.h +2
-0@@ -3407,6 +3407,18 @@ static inline bool uclamp_is_used(void)return static_branch_likely (&sched_uclamp_used); } +/* +* Enabling static branches would get the cpus_read_lock(),
kernel/sched/sched.h static inline bool uclamp_is_used(void) · line 3421
Quoted 10 lines
kernel/sched/sched.h +10
-0+* check whether uclamp_is_used before enable it to avoid always +* calling cpus_read_lock(). Because we never disable this +* static key once enable it. +*/ +static inline void sched_uclamp_enable (void ) +{ +if (!uclamp_is_used ()) +static_branch_enable (&sched_uclamp_used); +} +
Reviewed-by
Quoted 17 lines
kernel/sched/sched.h +2
-0static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {@@ -3486,6 +3498,8 @@ static inline bool uclamp_is_used(void)return false; } +static inline void sched_uclamp_enable (void ) {} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {kernel/sched/syscalls.c +0
-0
kernel/sched/syscalls.c static int uclamp_validate(struct task_struct *p, · line 374
Quoted 8 lines
kernel/sched/syscalls.c +1
-1@@ -368,7 +368,7 @@ static int uclamp_validate(struct task_struct *p,* blocking operation which obviously cannot be done while holding * scheduler locks. */ -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();return 0 ; }
Re: [PATCH v2 2/2] sched/uclamp: Add uclamp_is_used() check before enable it
In reply to Xuewen YanQuoted 10 lines · Xuewen Yan
Because the
static_branch_enable()would get thecpus_read_lock(), and sometimes users may frequently set the uclamp value of tasks, and this operation would call thestatic_branch_enable()frequently, so add theuclamp_is_used()check to prevent calling thecpus_read_lock()frequently.
And to make the code more concise, add a helper function to encapsulate this and use it everywhere we enablesched_uclamp_used.Signed-off-by Xuewen Yan <[email protected]>
Apart the small comment below
Quoted 44 lines
---
V2:
- change some commit message;
- Add a helper function and use it everywhere when enable uclamp (Vincent)
------ kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 14 ++++++++++++++ kernel/sched/syscalls.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)kernel/sched/core.c +3
-3@@ -1942,12 +1942,12 @@ static int sysctl_sched_uclamp_handler(const struct ctl_table *table, int write, }if (update_root_tg) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_update_root_tg (); }if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_sync_util_min_rt_default (); }@@ -9295,7 +9295,7 @@ static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,if (req.ret)return req.ret; -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();guard (mutex)(&uclamp_mutex);guard (rcu)();kernel/sched/sched.h +0
-0
kernel/sched/sched.h static inline bool uclamp_is_used(void) · line 3414
Quoted 8 lines
kernel/sched/sched.h +5
-0@@ -3407,6 +3407,18 @@ static inline bool uclamp_is_used(void)return static_branch_likely (&sched_uclamp_used); } +/* +* Enabling static branches would get the cpus_read_lock(), +* check whether uclamp_is_used before enable it to avoid always +* calling cpus_read_lock(). Because we never disable this +* static key once enable it.
Maybe, simply:
Enabling static branches would get the cpus_read_lock(), check uclamp_is_used before enabling it. There is no race issue because we never disable this static key once enabled.
Quoted 35 lines
kernel/sched/sched.h +9
-0+*/ +static inline void sched_uclamp_enable (void ) +{ +if (!uclamp_is_used ()) +static_branch_enable (&sched_uclamp_used); +} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {@@ -3486,6 +3498,8 @@ static inline bool uclamp_is_used(void)return false; } +static inline void sched_uclamp_enable (void ) {} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {kernel/sched/syscalls.c +1
-2@@ -368,7 +368,7 @@ static int uclamp_validate(struct task_struct *p,* blocking operation which obviously cannot be done while holding * scheduler locks. */ -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();return 0 ; } --2.25.1
[tip: sched/core] sched/uclamp: Add uclamp_is_used() check before enable it
In reply to Xuewen YanThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4a14bd0c67d5670844c54356a163aa0ce623dbe1 Gitweb: https://git.kernel.org/tip/4a14bd0c67d5670844c54356a163aa0ce623dbe1 Author: Xuewen Yan <[email protected]> AuthorDate: Wed, 19 Feb 2025 17:37:47 +08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Mar 2025 21:13:19 +01:00
sched/uclamp: Add uclamp_is_used() check before enable it
Because the static_branch_enable() would get the cpus_read_lock(), and sometimes users may frequently set the uclamp value of tasks, and this operation would call the static_branch_enable() frequently, so add the uclamp_is_used() check to prevent calling the cpus_read_lock() frequently.
And to make the code more concise, add a helper function to encapsulate this and use it everywhere we enable sched_uclamp_used.
--- kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 14 ++++++++++++++ kernel/sched/syscalls.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -3
@@ -1941,12 +1941,12 @@ static int sysctl_sched_uclamp_handler(const struct ctl_table *table, int write, }if (update_root_tg) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_update_root_tg (); }if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_sync_util_min_rt_default (); }
@@ -9294,7 +9294,7 @@ static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,if (req.ret)return req.ret; -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();guard (mutex)(&uclamp_mutex);guard (rcu)();
kernel/sched/sched.h +14 -0
@@ -3407,6 +3407,18 @@ static inline bool uclamp_is_used(void)return static_branch_likely (&sched_uclamp_used); } +/* +* Enabling static branches would get the cpus_read_lock(), +* check whether uclamp_is_used before enable it to avoid always +* calling cpus_read_lock(). Because we never disable this +* static key once enable it. +*/ +static inline void sched_uclamp_enable (void ) +{ +if (!uclamp_is_used ()) +static_branch_enable (&sched_uclamp_used); +} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
@@ -3486,6 +3498,8 @@ static inline bool uclamp_is_used(void)return false; } +static inline void sched_uclamp_enable (void ) {} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
kernel/sched/syscalls.c +1 -1
@@ -368,7 +368,7 @@ static int uclamp_validate(struct task_struct *p,* blocking operation which obviously cannot be done while holding * scheduler locks. */ -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();return 0 ; }
[tip: sched/core] sched/uclamp: Optimize sched_uclamp_used static key enabling
In reply to Xuewen YanThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4bc45824149ea83a1e293c674e7f542b8127afb6 Gitweb: https://git.kernel.org/tip/4bc45824149ea83a1e293c674e7f542b8127afb6 Author: Xuewen Yan <[email protected]> AuthorDate: Wed, 19 Feb 2025 17:37:47 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 15 Mar 2025 10:28:50 +01:00
sched/uclamp: Optimize sched_uclamp_used static key enabling
Repeat calls of static_branch_enable() to an already enabled static key introduce overhead, because it calls cpus_read_lock().
Users may frequently set the uclamp value of tasks, triggering the repeat enabling of the sched_uclamp_used static key.
Optimize this and avoid repeat calls to static_branch_enable() by checking whether it's enabled already.
[ mingo: Rewrote the changelog for legibility ]
--- kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 14 ++++++++++++++ kernel/sched/syscalls.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -3
@@ -1941,12 +1941,12 @@ static int sysctl_sched_uclamp_handler(const struct ctl_table *table, int write, }if (update_root_tg) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_update_root_tg (); }if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) { -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();uclamp_sync_util_min_rt_default (); }
@@ -9294,7 +9294,7 @@ static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,if (req.ret)return req.ret; -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();guard (mutex)(&uclamp_mutex);guard (rcu)();
kernel/sched/sched.h +14 -0
@@ -3407,6 +3407,18 @@ static inline bool uclamp_is_used(void)return static_branch_likely (&sched_uclamp_used); } +/* +* Enabling static branches would get the cpus_read_lock(), +* check whether uclamp_is_used before enable it to avoid always +* calling cpus_read_lock(). Because we never disable this +* static key once enable it. +*/ +static inline void sched_uclamp_enable (void ) +{ +if (!uclamp_is_used ()) +static_branch_enable (&sched_uclamp_used); +} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
@@ -3486,6 +3498,8 @@ static inline bool uclamp_is_used(void)return false; } +static inline void sched_uclamp_enable (void ) {} +static inline unsigned long uclamp_rq_get (struct rq *rq,enum uclamp_id clamp_id) {
kernel/sched/syscalls.c +1 -1
@@ -368,7 +368,7 @@ static int uclamp_validate(struct task_struct *p,* blocking operation which obviously cannot be done while holding * scheduler locks. */ -static_branch_enable (&sched_uclamp_used); +sched_uclamp_enable ();return 0 ; }
Quoted 31 lines · Xuewen Yan
Now, we have the
uclamp_is_used()func to judge the uclamp enabled, so replace thestatic_branch_unlikely(&sched_uclamp_used)with it.Signed-off-by Xuewen Yan <[email protected]>Reviewed-by Hongyan Xia <[email protected]>Reviewed-by Christian Loehle <[email protected]>Reviewed-by Vincent Guittot <[email protected]>---
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(-)kernel/sched/core.c +1
-1@@ -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))
kernel/sched/core.c static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) · line 1788
Quoted 6 lines
kernel/sched/core.c +1
-1@@ -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.
The following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 12fc0fdcbd1cc2f906596b77c03d7e5ed58947d1 Gitweb: https://git.kernel.org/tip/12fc0fdcbd1cc2f906596b77c03d7e5ed58947d1 Author: Xuewen Yan <[email protected]> AuthorDate: Wed, 19 Feb 2025 17:37:46 +08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Mar 2025 21:13:18 +01:00
sched/uclamp: Always using uclamp_is_used()
Now, we have the uclamp_is_used() func to judge the uclamp enabled, so replace the static_branch_unlikely(&sched_uclamp_used) with it.
--- kernel/sched/core.c | 4 ++-- kernel/sched/sched.h | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-)
kernel/sched/core.c +2 -2
@@ -1756,7 +1756,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))
@@ -1783,7 +1783,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))
kernel/sched/sched.h +14 -14
@@ -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)++)
[tip: sched/core] sched/uclamp: Use the uclamp_is_used() helper instead of open-coding it
In reply to Xuewen YanThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 5fca5a4cf97313dd2f5eae29624ceb1dc48f258a Gitweb: https://git.kernel.org/tip/5fca5a4cf97313dd2f5eae29624ceb1dc48f258a Author: Xuewen Yan <[email protected]> AuthorDate: Wed, 19 Feb 2025 17:37:46 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 15 Mar 2025 10:26:37 +01:00
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 ]
--- kernel/sched/core.c | 4 ++-- kernel/sched/sched.h | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-)
kernel/sched/core.c +2 -2
@@ -1756,7 +1756,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))
@@ -1783,7 +1783,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))
kernel/sched/sched.h +14 -14
@@ -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)++)