sched: Remove unnecessary initialization in init_cfs_bandwidth() function
PATCH 1/1 sched: Remove unnecessary initialization in init_cfs_bandwidth() function
The root task group is statically defined, and non-root task groups are allocated memory using kmem_cache_alloc() with the __GFP_ZERO flag. In both cases, the corresponding 'struct cfs_bandwidth' is a block of all-zero memory. Therefore, it is unnecessary to explicitly set zeros in the init_cfs_bandwidth() function.
--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/fair.c +0 -2
@@ -6573,10 +6573,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)void init_cfs_bandwidth (struct cfs_bandwidth *cfs_b,struct cfs_bandwidth *parent) {raw_spin_lock_init (&cfs_b->lock); - cfs_b->runtime =0 ; cfs_b->quota =RUNTIME_INF ; cfs_b->period =ns_to_ktime (default_cfs_period ()); - cfs_b->burst =0 ; cfs_b->hierarchical_quota = parent ? parent->hierarchical_quota :RUNTIME_INF ;INIT_LIST_HEAD (&cfs_b->throttled_cfs_rq);
Signature · 1 line
2.46.0
Peter Zijlstra
maintainerQuoted 16 lines · Bitao Hu
The root task group is statically defined, and non-root task groups are allocated memory using
kmem_cache_alloc()with the__GFP_ZEROflag. In both cases, the corresponding 'structcfs_bandwidth' is a block of all-zero memory. Therefore, it is unnecessary to explicitly set zeros in theinit_cfs_bandwidth()function.Signed-off-by Bitao Hu <[email protected]>--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)kernel/sched/fair.c +0
-0
kernel/sched/fair.c static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) · line 6580
Quoted 10 lines
kernel/sched/fair.c +0
-2@@ -6573,10 +6573,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)void init_cfs_bandwidth (struct cfs_bandwidth *cfs_b,struct cfs_bandwidth *parent) {raw_spin_lock_init (&cfs_b->lock); - cfs_b->runtime =0 ; cfs_b->quota =RUNTIME_INF ; cfs_b->period =ns_to_ktime (default_cfs_period ()); - cfs_b->burst =0 ; cfs_b->hierarchical_quota = parent ? parent->hierarchical_quota :RUNTIME_INF ;INIT_LIST_HEAD (&cfs_b->throttled_cfs_rq);
But this shows someone thought about it and 0 is the right value, and not an oversight.
Quoted 26 lines · Peter Zijlstra
Quoted 25 lines · Bitao Hu
The root task group is statically defined, and non-root task groups are allocated memory using
kmem_cache_alloc()with the__GFP_ZEROflag. In both cases, the corresponding 'structcfs_bandwidth' is a block of all-zero memory. Therefore, it is unnecessary to explicitly set zeros in theinit_cfs_bandwidth()function.Signed-off-by Bitao Hu <[email protected]>--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)kernel/sched/fair.c +0
-2@@ -6573,10 +6573,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)void init_cfs_bandwidth (struct cfs_bandwidth *cfs_b,struct cfs_bandwidth *parent) {raw_spin_lock_init (&cfs_b->lock); - cfs_b->runtime =0 ; cfs_b->quota =RUNTIME_INF ; cfs_b->period =ns_to_ktime (default_cfs_period ()); - cfs_b->burst =0 ; cfs_b->hierarchical_quota = parent ? parent->hierarchical_quota :RUNTIME_INF ;
Quoted 4 lines
kernel/sched/fair.c static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) · line 6580
Quoted 1 line
kernel/sched/fair.c +0
-0INIT_LIST_HEAD (&cfs_b->throttled_cfs_rq);But this shows someone thought about it and 0 is the right value, and not an oversight.
Okay, I got it.