sched: cleanup sched_update_scaling() return type and usage
PATCH 1/1 sched: cleanup sched_update_scaling() return type and usage
The function sched_update_scaling() always returned 0 and callers never checked its return value. This patch removes the return value and changes the function to return void for clarity.
The usage of the return value in kernel/sched/debug.c has also been updated to reflect this change. This cleanup improves code readability and eliminates unnecessary logic.
Tested:
- Kernel compiled successfully
- sched_update_scaling() invoked without errors
- No regressions in scheduler-related functionality
--- kernel/sched/debug.c | 3 +-- kernel/sched/fair.c | 4 +--- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-)
kernel/sched/debug.c +1 -2
@@ -189,8 +189,7 @@ static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,return -EINVAL ; sysctl_sched_tunable_scaling = scaling; -if (sched_update_scaling ()) -return -EINVAL ; +sched_update_scaling (); *ppos += cnt;return cnt;
kernel/sched/fair.c +1 -3
@@ -1004,7 +1004,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)/************************************************************** * Scheduling class statistics methods: */ -int sched_update_scaling (void ) +void sched_update_scaling (void ) {unsigned int factor =get_update_sysctl_factor ();
@@ -1012,8 +1012,6 @@ int sched_update_scaling(void) (normalized_sysctl_##name = sysctl_##name / (factor))WRT_SYSCTL (sched_base_slice);#undef WRT_SYSCTL - -return 0 ; }static void clear_buddies (struct cfs_rq *cfs_rq,struct sched_entity *se);
kernel/sched/sched.h +1 -1
@@ -2168,7 +2168,7 @@ extern int group_balance_cpu(struct sched_group *sg);extern void update_sched_domain_debugfs (void );extern void dirty_sched_domain_sysctl (int cpu); -extern int sched_update_scaling (void ); +extern void sched_update_scaling (void );static inline const struct cpumask *task_user_cpus (struct task_struct *p) {
Signature · 1 line
2.43.0
Hello Zhan,
Quoted 25 lines · Zhan Xusheng
The function
sched_update_scaling()always returned 0 and callers never checked its return value. This patch removes the return value and changes the function to return void for clarity.The usage of the return value in
kernel/sched/debug.chas also been updated to reflect this change. This cleanup improves code readability and eliminates unnecessary logic.Tested:
- Kernel compiled successfully
-sched_update_scaling()invoked without errors
- No regressions in scheduler-related functionalitySigned-off-by Zhan Xusheng <[email protected]>---
kernel/sched/debug.c | 3 +-- kernel/sched/fair.c | 4 +--- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-)kernel/sched/debug.c +0
-0
kernel/sched/debug.c static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf, · line 192
Quoted 6 lines
kernel/sched/debug.c +1
-2@@ -189,8 +189,7 @@ static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,return -EINVAL ; sysctl_sched_tunable_scaling = scaling; -if (sched_update_scaling ()) -return -EINVAL ; +sched_update_scaling ();
Okay. Good to remove a vestigial return value and dead -EINVAL check, as the function performs 'no-fail' math.
Quoted 17 lines
kernel/sched/debug.c +0
-0*ppos += cnt;return cnt;kernel/sched/fair.c +1
-1@@ -1004,7 +1004,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)/************************************************************** * Scheduling class statistics methods: */ -int sched_update_scaling (void ) +void sched_update_scaling (void ) {unsigned int factor =get_update_sysctl_factor ();
kernel/sched/fair.c int sched_update_scaling(void) · line 1015
Quoted 6 lines
kernel/sched/fair.c +0
-2@@ -1012,8 +1012,6 @@ int sched_update_scaling(void) (normalized_sysctl_##name = sysctl_##name / (factor))WRT_SYSCTL (sched_base_slice);#undef WRT_SYSCTL - -return 0 ; }
By changing this to void, we are asserting that the update is 'fire-and-forget'. If we later need to add sanity check preventing for eg. slice that is too small, the return type might need to revert to int.
Quoted 19 lines
kernel/sched/fair.c +0
-0static void clear_buddies (struct cfs_rq *cfs_rq,struct sched_entity *se);kernel/sched/sched.h +1
-1@@ -2168,7 +2168,7 @@ extern int group_balance_cpu(struct sched_group *sg);extern void update_sched_domain_debugfs (void );extern void dirty_sched_domain_sysctl (int cpu); -extern int sched_update_scaling (void ); +extern void sched_update_scaling (void );static inline const struct cpumask *task_user_cpus (struct task_struct *p) {Signature · 1 line
2.43.0
Regards,
Shubhang Kaushik