mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched: Remove unnecessary initialization in init_cfs_bandwidth() function
@ 2024-11-04 12:14 Bitao Hu
  2024-11-04 12:18 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Bitao Hu @ 2024-11-04 12:14 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot; +Cc: linux-kernel, yaoma

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.

Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
---
 kernel/sched/fair.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2d16c8545c71..2fd96641164f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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);
-- 
2.46.0


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

* Re: [PATCH] sched: Remove unnecessary initialization in init_cfs_bandwidth() function
  2024-11-04 12:14 [PATCH] sched: Remove unnecessary initialization in init_cfs_bandwidth() function Bitao Hu
@ 2024-11-04 12:18 ` Peter Zijlstra
  2024-11-05  1:21   ` yaoma
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2024-11-04 12:18 UTC (permalink / raw)
  To: Bitao Hu; +Cc: mingo, juri.lelli, vincent.guittot, linux-kernel

On Mon, Nov 04, 2024 at 08:14:43PM +0800, Bitao Hu wrote:
> 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.
> 
> Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
> ---
>  kernel/sched/fair.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 2d16c8545c71..2fd96641164f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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.


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

* Re: [PATCH] sched: Remove unnecessary initialization in init_cfs_bandwidth() function
  2024-11-04 12:18 ` Peter Zijlstra
@ 2024-11-05  1:21   ` yaoma
  0 siblings, 0 replies; 3+ messages in thread
From: yaoma @ 2024-11-05  1:21 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, juri.lelli, vincent.guittot, linux-kernel



在 2024/11/4 20:18, Peter Zijlstra 写道:
> On Mon, Nov 04, 2024 at 08:14:43PM +0800, Bitao Hu wrote:
>> 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.
>>
>> Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
>> ---
>>   kernel/sched/fair.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 2d16c8545c71..2fd96641164f 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -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.

Okay, I got it.


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

end of thread, other threads:[~2024-11-05  1:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-04 12:14 [PATCH] sched: Remove unnecessary initialization in init_cfs_bandwidth() function Bitao Hu
2024-11-04 12:18 ` Peter Zijlstra
2024-11-05  1:21   ` yaoma

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®