[PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical

Waiman Long posted 2 patches 1 year, 3 months ago
There is a newer version of this series
[PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical
Posted by Waiman Long 1 year, 3 months ago
The housekeeping cpumasks are only set by two boot commandline
parameters: "nohz_full" and "isolcpus". When there is more than one of
"nohz_full" or "isolcpus", the extra ones must have the same CPU list
or the setup will fail partially.

The HK_TYPE_TICK, HK_TYPE_DOMAIN and HK_TYPE_MANAGED_IRQ types are
settable by "isolcpus" and they can be set individually. The other
housekeeping types are all set by "nohz_full" without a way to set them
individually. So they all have identical cpumasks.

There is actually no point in having different cpumasks for these
"nohz_full" only housekeeping types. Consolidate these types to use the
same cpumask by aliasing them to the same value. If there is a need to
set any of them independently in the future, we can break them out to
their own cpumasks again.

With this change, the number of cpumasks in the housekeeping structure
drops from 9 to 4. There is no other functional change.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 include/linux/sched/isolation.h | 18 ++++++++++++------
 kernel/sched/isolation.c        |  9 ++-------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index 499d5e480882..e2c42172de82 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -7,15 +7,21 @@
 #include <linux/tick.h>
 
 enum hk_type {
-	HK_TYPE_TIMER,
-	HK_TYPE_RCU,
-	HK_TYPE_MISC,
 	HK_TYPE_TICK,
 	HK_TYPE_DOMAIN,
-	HK_TYPE_WQ,
 	HK_TYPE_MANAGED_IRQ,
-	HK_TYPE_KTHREAD,
-	HK_TYPE_MAX
+	HK_TYPE_KERNEL_NOISE,
+	HK_TYPE_MAX,
+
+	/*
+	 * The following housekeeping types are only set by the nohz_full
+	 * boot commandline option. So they can share the same value.
+	 */
+	HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE,
+	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
+	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
+	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
+	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE
 };
 
 #ifdef CONFIG_CPU_ISOLATION
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 5345e11f3d44..61d0f97341c3 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -9,14 +9,10 @@
  */
 
 enum hk_flags {
-	HK_FLAG_TIMER		= BIT(HK_TYPE_TIMER),
-	HK_FLAG_RCU		= BIT(HK_TYPE_RCU),
-	HK_FLAG_MISC		= BIT(HK_TYPE_MISC),
 	HK_FLAG_TICK		= BIT(HK_TYPE_TICK),
 	HK_FLAG_DOMAIN		= BIT(HK_TYPE_DOMAIN),
-	HK_FLAG_WQ		= BIT(HK_TYPE_WQ),
 	HK_FLAG_MANAGED_IRQ	= BIT(HK_TYPE_MANAGED_IRQ),
-	HK_FLAG_KTHREAD		= BIT(HK_TYPE_KTHREAD),
+	HK_FLAG_KERNEL_NOISE	= BIT(HK_TYPE_KERNEL_NOISE),
 };
 
 DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
@@ -194,8 +190,7 @@ static int __init housekeeping_nohz_full_setup(char *str)
 {
 	unsigned long flags;
 
-	flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU |
-		HK_FLAG_MISC | HK_FLAG_KTHREAD;
+	flags = HK_FLAG_TICK | HK_FLAG_KERNEL_NOISE;
 
 	return housekeeping_setup(str, flags);
 }
-- 
2.43.5
Re: [PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical
Posted by Frederic Weisbecker 1 year, 3 months ago
Le Wed, Sep 04, 2024 at 02:36:50PM -0400, Waiman Long a écrit :
> The housekeeping cpumasks are only set by two boot commandline
> parameters: "nohz_full" and "isolcpus". When there is more than one of
> "nohz_full" or "isolcpus", the extra ones must have the same CPU list
> or the setup will fail partially.
> 
> The HK_TYPE_TICK, HK_TYPE_DOMAIN and HK_TYPE_MANAGED_IRQ types are
> settable by "isolcpus" and they can be set individually. The other
> housekeeping types are all set by "nohz_full" without a way to set them
> individually. So they all have identical cpumasks.

And HK_TYPE_TICK is part of them, so it should become HK_TYPE_KERNEL_NOISE.

> 
> There is actually no point in having different cpumasks for these
> "nohz_full" only housekeeping types. Consolidate these types to use the
> same cpumask by aliasing them to the same value. If there is a need to
> set any of them independently in the future, we can break them out to
> their own cpumasks again.
> 
> With this change, the number of cpumasks in the housekeeping structure
> drops from 9 to 4. There is no other functional change.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  include/linux/sched/isolation.h | 18 ++++++++++++------
>  kernel/sched/isolation.c        |  9 ++-------
>  2 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
> index 499d5e480882..e2c42172de82 100644
> --- a/include/linux/sched/isolation.h
> +++ b/include/linux/sched/isolation.h
> @@ -7,15 +7,21 @@
>  #include <linux/tick.h>
>  
>  enum hk_type {
> -	HK_TYPE_TIMER,
> -	HK_TYPE_RCU,
> -	HK_TYPE_MISC,
>  	HK_TYPE_TICK,
>  	HK_TYPE_DOMAIN,
> -	HK_TYPE_WQ,
>  	HK_TYPE_MANAGED_IRQ,
> -	HK_TYPE_KTHREAD,
> -	HK_TYPE_MAX
> +	HK_TYPE_KERNEL_NOISE,
> +	HK_TYPE_MAX,
> +
> +	/*
> +	 * The following housekeeping types are only set by the nohz_full
> +	 * boot commandline option. So they can share the same value.
> +	 */
> +	HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE,
> +	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
> +	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
> +	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
> +	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE

Why not removing them entirely and only keep HK_TYPE_KERNEL_NOISE ?

Thanks.

>  };
>  
>  #ifdef CONFIG_CPU_ISOLATION
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 5345e11f3d44..61d0f97341c3 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -9,14 +9,10 @@
>   */
>  
>  enum hk_flags {
> -	HK_FLAG_TIMER		= BIT(HK_TYPE_TIMER),
> -	HK_FLAG_RCU		= BIT(HK_TYPE_RCU),
> -	HK_FLAG_MISC		= BIT(HK_TYPE_MISC),
>  	HK_FLAG_TICK		= BIT(HK_TYPE_TICK),
>  	HK_FLAG_DOMAIN		= BIT(HK_TYPE_DOMAIN),
> -	HK_FLAG_WQ		= BIT(HK_TYPE_WQ),
>  	HK_FLAG_MANAGED_IRQ	= BIT(HK_TYPE_MANAGED_IRQ),
> -	HK_FLAG_KTHREAD		= BIT(HK_TYPE_KTHREAD),
> +	HK_FLAG_KERNEL_NOISE	= BIT(HK_TYPE_KERNEL_NOISE),
>  };
>  
>  DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
> @@ -194,8 +190,7 @@ static int __init housekeeping_nohz_full_setup(char *str)
>  {
>  	unsigned long flags;
>  
> -	flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU |
> -		HK_FLAG_MISC | HK_FLAG_KTHREAD;
> +	flags = HK_FLAG_TICK | HK_FLAG_KERNEL_NOISE;
>  
>  	return housekeeping_setup(str, flags);
>  }
> -- 
> 2.43.5
> 
Re: [PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical
Posted by Waiman Long 1 year, 3 months ago
On 9/4/24 17:18, Frederic Weisbecker wrote:
> Le Wed, Sep 04, 2024 at 02:36:50PM -0400, Waiman Long a écrit :
>> The housekeeping cpumasks are only set by two boot commandline
>> parameters: "nohz_full" and "isolcpus". When there is more than one of
>> "nohz_full" or "isolcpus", the extra ones must have the same CPU list
>> or the setup will fail partially.
>>
>> The HK_TYPE_TICK, HK_TYPE_DOMAIN and HK_TYPE_MANAGED_IRQ types are
>> settable by "isolcpus" and they can be set individually. The other
>> housekeeping types are all set by "nohz_full" without a way to set them
>> individually. So they all have identical cpumasks.
> And HK_TYPE_TICK is part of them, so it should become HK_TYPE_KERNEL_NOISE.
HK_TYPE_TICK can also be set with "isolcpus=tick,...". That is the 
reason why it is still a separate type.
>
>> There is actually no point in having different cpumasks for these
>> "nohz_full" only housekeeping types. Consolidate these types to use the
>> same cpumask by aliasing them to the same value. If there is a need to
>> set any of them independently in the future, we can break them out to
>> their own cpumasks again.
>>
>> With this change, the number of cpumasks in the housekeeping structure
>> drops from 9 to 4. There is no other functional change.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>>   include/linux/sched/isolation.h | 18 ++++++++++++------
>>   kernel/sched/isolation.c        |  9 ++-------
>>   2 files changed, 14 insertions(+), 13 deletions(-)
>>
>> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
>> index 499d5e480882..e2c42172de82 100644
>> --- a/include/linux/sched/isolation.h
>> +++ b/include/linux/sched/isolation.h
>> @@ -7,15 +7,21 @@
>>   #include <linux/tick.h>
>>   
>>   enum hk_type {
>> -	HK_TYPE_TIMER,
>> -	HK_TYPE_RCU,
>> -	HK_TYPE_MISC,
>>   	HK_TYPE_TICK,
>>   	HK_TYPE_DOMAIN,
>> -	HK_TYPE_WQ,
>>   	HK_TYPE_MANAGED_IRQ,
>> -	HK_TYPE_KTHREAD,
>> -	HK_TYPE_MAX
>> +	HK_TYPE_KERNEL_NOISE,
>> +	HK_TYPE_MAX,
>> +
>> +	/*
>> +	 * The following housekeeping types are only set by the nohz_full
>> +	 * boot commandline option. So they can share the same value.
>> +	 */
>> +	HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE,
>> +	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
>> +	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
>> +	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
>> +	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE
> Why not removing them entirely and only keep HK_TYPE_KERNEL_NOISE ?

All these HK_TYPE_* types are still used in other parts of kernel. We 
need to clean them all up before we can remove them, but that is outside 
the scope of this series.

Cheers,
Longman


Re: [PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical
Posted by Frederic Weisbecker 1 year, 3 months ago
Le Wed, Sep 04, 2024 at 07:57:13PM -0400, Waiman Long a écrit :
> > > diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
> > > index 499d5e480882..e2c42172de82 100644
> > > --- a/include/linux/sched/isolation.h
> > > +++ b/include/linux/sched/isolation.h
> > > @@ -7,15 +7,21 @@
> > >   #include <linux/tick.h>
> > >   enum hk_type {
> > > -	HK_TYPE_TIMER,
> > > -	HK_TYPE_RCU,
> > > -	HK_TYPE_MISC,
> > >   	HK_TYPE_TICK,
> > >   	HK_TYPE_DOMAIN,
> > > -	HK_TYPE_WQ,
> > >   	HK_TYPE_MANAGED_IRQ,
> > > -	HK_TYPE_KTHREAD,
> > > -	HK_TYPE_MAX
> > > +	HK_TYPE_KERNEL_NOISE,
> > > +	HK_TYPE_MAX,
> > > +
> > > +	/*
> > > +	 * The following housekeeping types are only set by the nohz_full
> > > +	 * boot commandline option. So they can share the same value.
> > > +	 */
> > > +	HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE,
> > > +	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
> > > +	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
> > > +	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
> > > +	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE
> > Why not removing them entirely and only keep HK_TYPE_KERNEL_NOISE ?
> 
> All these HK_TYPE_* types are still used in other parts of kernel. We need
> to clean them all up before we can remove them, but that is outside the
> scope of this series.

If that can help, I posted this a while ago:

https://lore.kernel.org/lkml/20230203232409.163847-2-frederic@kernel.org/

I think it is very much needed. People keep getting confused about these individual
bits.

> Cheers,
> Longman
> 
> 
Re: [PATCH v3 2/2] sched/isolation: Consolidate housekeeping cpumasks that are always identical
Posted by Waiman Long 1 year, 3 months ago
On 9/6/24 09:10, Frederic Weisbecker wrote:
> Le Wed, Sep 04, 2024 at 07:57:13PM -0400, Waiman Long a écrit :
>>>> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
>>>> index 499d5e480882..e2c42172de82 100644
>>>> --- a/include/linux/sched/isolation.h
>>>> +++ b/include/linux/sched/isolation.h
>>>> @@ -7,15 +7,21 @@
>>>>    #include <linux/tick.h>
>>>>    enum hk_type {
>>>> -	HK_TYPE_TIMER,
>>>> -	HK_TYPE_RCU,
>>>> -	HK_TYPE_MISC,
>>>>    	HK_TYPE_TICK,
>>>>    	HK_TYPE_DOMAIN,
>>>> -	HK_TYPE_WQ,
>>>>    	HK_TYPE_MANAGED_IRQ,
>>>> -	HK_TYPE_KTHREAD,
>>>> -	HK_TYPE_MAX
>>>> +	HK_TYPE_KERNEL_NOISE,
>>>> +	HK_TYPE_MAX,
>>>> +
>>>> +	/*
>>>> +	 * The following housekeeping types are only set by the nohz_full
>>>> +	 * boot commandline option. So they can share the same value.
>>>> +	 */
>>>> +	HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE,
>>>> +	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
>>>> +	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
>>>> +	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
>>>> +	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE
>>> Why not removing them entirely and only keep HK_TYPE_KERNEL_NOISE ?
>> All these HK_TYPE_* types are still used in other parts of kernel. We need
>> to clean them all up before we can remove them, but that is outside the
>> scope of this series.
> If that can help, I posted this a while ago:
>
> https://lore.kernel.org/lkml/20230203232409.163847-2-frederic@kernel.org/
>
> I think it is very much needed. People keep getting confused about these individual
> bits.

This patch does merge all the nohz_full bits (except HK_TYPE_TICK) into 
a single bit. I see that you tried to do that last year. This patch is 
less aggressive as it only touches the scheduling code. Once we agree 
that this is the direction to go and is merged, we can proceed to update 
the other kernel subsystems.

Cheers,
Longman