Re: [PATCH v2 3/6] powerpc/smp: Move shared_processor static key to smp.h

2023-10-20 Thread Michael Ellerman
Srikar Dronamraju  writes:
> * Michael Ellerman  [2023-10-19 15:41:40]:
>
>> Srikar Dronamraju  writes:
>> > The ability to detect if the system is running in a shared processor
>> > mode is helpful in few more generic cases not just in
>> > paravirtualization.
>> > For example: At boot time, different scheduler/ topology flags may be
>> > set based on the processor mode. Hence move it to a more generic file.
>> 
>> I'd rather you just included paravirt.h in the few files where you need it.
>
> I thought, detecting if a Processor was shared or not was more a
> smp/processor related than a paravirt related.

It's both really :)

It's definitely paravirt related though, because if we weren't
*para*virt then we wouldn't know there was a hypervisor at all :)

But having smaller more focused headers is preferable in general just
for mechanical reasons.

cheers


Re: [PATCH v2 3/6] powerpc/smp: Move shared_processor static key to smp.h

2023-10-19 Thread Srikar Dronamraju
* Michael Ellerman  [2023-10-19 15:41:40]:

> Srikar Dronamraju  writes:
> > The ability to detect if the system is running in a shared processor
> > mode is helpful in few more generic cases not just in
> > paravirtualization.
> > For example: At boot time, different scheduler/ topology flags may be
> > set based on the processor mode. Hence move it to a more generic file.
> 
> I'd rather you just included paravirt.h in the few files where you need it.


I thought, detecting if a Processor was shared or not was more a
smp/processor related than a paravirt related.

Will drop as suggested.

> 
> cheers
> 
> > diff --git a/arch/powerpc/include/asm/paravirt.h 
> > b/arch/powerpc/include/asm/paravirt.h
> > index 0372b0093f72..cf83e837a571 100644
> > --- a/arch/powerpc/include/asm/paravirt.h
> > +++ b/arch/powerpc/include/asm/paravirt.h
> > @@ -15,13 +15,6 @@
> >  #include 
> >  #include 
> >  
> > -DECLARE_STATIC_KEY_FALSE(shared_processor);
> > -
> > -static inline bool is_shared_processor(void)
> > -{
> > -   return static_branch_unlikely(_processor);
> > -}
> > -
> >  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
> >  extern struct static_key paravirt_steal_enabled;
> >  extern struct static_key paravirt_steal_rq_enabled;
> > @@ -77,11 +70,6 @@ static inline bool is_vcpu_idle(int vcpu)
> > return lppaca_of(vcpu).idle;
> >  }
> >  #else
> > -static inline bool is_shared_processor(void)
> > -{
> > -   return false;
> > -}
> > -
> >  static inline u32 yield_count_of(int cpu)
> >  {
> > return 0;
> > diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
> > index 576d0e15..08631b2a4528 100644
> > --- a/arch/powerpc/include/asm/smp.h
> > +++ b/arch/powerpc/include/asm/smp.h
> > @@ -34,6 +34,20 @@ extern bool coregroup_enabled;
> >  extern int cpu_to_chip_id(int cpu);
> >  extern int *chip_id_lookup_table;
> >  
> > +#ifdef CONFIG_PPC_SPLPAR
> > +DECLARE_STATIC_KEY_FALSE(shared_processor);
> > +
> > +static inline bool is_shared_processor(void)
> > +{
> > +   return static_branch_unlikely(_processor);
> > +}
> > +#else
> > +static inline bool is_shared_processor(void)
> > +{
> > +   return false;
> > +}
> > +#endif
> > +
> >  DECLARE_PER_CPU(cpumask_var_t, thread_group_l1_cache_map);
> >  DECLARE_PER_CPU(cpumask_var_t, thread_group_l2_cache_map);
> >  DECLARE_PER_CPU(cpumask_var_t, thread_group_l3_cache_map);
> > -- 
> > 2.31.1

-- 
Thanks and Regards
Srikar Dronamraju


Re: [PATCH v2 3/6] powerpc/smp: Move shared_processor static key to smp.h

2023-10-19 Thread Shrikanth Hegde



On 10/18/23 10:07 PM, Srikar Dronamraju wrote:
> The ability to detect if the system is running in a shared processor
> mode is helpful in few more generic cases not just in
> paravirtualization.
> For example: At boot time, different scheduler/ topology flags may be
> set based on the processor mode. Hence move it to a more generic file.
> 
> Signed-off-by: Srikar Dronamraju 
> ---
>  arch/powerpc/include/asm/paravirt.h | 12 
>  arch/powerpc/include/asm/smp.h  | 14 ++
>  2 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/paravirt.h 
> b/arch/powerpc/include/asm/paravirt.h
> index 0372b0093f72..cf83e837a571 100644
> --- a/arch/powerpc/include/asm/paravirt.h
> +++ b/arch/powerpc/include/asm/paravirt.h
> @@ -15,13 +15,6 @@
>  #include 
>  #include 
> 
> -DECLARE_STATIC_KEY_FALSE(shared_processor);
> -
> -static inline bool is_shared_processor(void)
> -{
> - return static_branch_unlikely(_processor);
> -}
> -
>  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
>  extern struct static_key paravirt_steal_enabled;
>  extern struct static_key paravirt_steal_rq_enabled;
> @@ -77,11 +70,6 @@ static inline bool is_vcpu_idle(int vcpu)
>   return lppaca_of(vcpu).idle;
>  }

Hi Srikar, 

This patch fails to apply on tip/master as it depends on 
https://lore.kernel.org/all/20231019091452.95260-1-sri...@linux.vnet.ibm.com/ 
to be applied first.

>  #else
> -static inline bool is_shared_processor(void)
> -{
> - return false;
> -}
> -
>  static inline u32 yield_count_of(int cpu)
>  {
>   return 0;
> diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
> index 576d0e15..08631b2a4528 100644
> --- a/arch/powerpc/include/asm/smp.h
> +++ b/arch/powerpc/include/asm/smp.h
> @@ -34,6 +34,20 @@ extern bool coregroup_enabled;
>  extern int cpu_to_chip_id(int cpu);
>  extern int *chip_id_lookup_table;
> 
> +#ifdef CONFIG_PPC_SPLPAR
> +DECLARE_STATIC_KEY_FALSE(shared_processor);
> +
> +static inline bool is_shared_processor(void)
> +{
> + return static_branch_unlikely(_processor);
> +}
> +#else
> +static inline bool is_shared_processor(void)
> +{
> + return false;
> +}
> +#endif
> +
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l1_cache_map);
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l2_cache_map);
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l3_cache_map);


Re: [PATCH v2 3/6] powerpc/smp: Move shared_processor static key to smp.h

2023-10-18 Thread Michael Ellerman
Srikar Dronamraju  writes:
> The ability to detect if the system is running in a shared processor
> mode is helpful in few more generic cases not just in
> paravirtualization.
> For example: At boot time, different scheduler/ topology flags may be
> set based on the processor mode. Hence move it to a more generic file.

I'd rather you just included paravirt.h in the few files where you need it.

cheers

> diff --git a/arch/powerpc/include/asm/paravirt.h 
> b/arch/powerpc/include/asm/paravirt.h
> index 0372b0093f72..cf83e837a571 100644
> --- a/arch/powerpc/include/asm/paravirt.h
> +++ b/arch/powerpc/include/asm/paravirt.h
> @@ -15,13 +15,6 @@
>  #include 
>  #include 
>  
> -DECLARE_STATIC_KEY_FALSE(shared_processor);
> -
> -static inline bool is_shared_processor(void)
> -{
> - return static_branch_unlikely(_processor);
> -}
> -
>  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
>  extern struct static_key paravirt_steal_enabled;
>  extern struct static_key paravirt_steal_rq_enabled;
> @@ -77,11 +70,6 @@ static inline bool is_vcpu_idle(int vcpu)
>   return lppaca_of(vcpu).idle;
>  }
>  #else
> -static inline bool is_shared_processor(void)
> -{
> - return false;
> -}
> -
>  static inline u32 yield_count_of(int cpu)
>  {
>   return 0;
> diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
> index 576d0e15..08631b2a4528 100644
> --- a/arch/powerpc/include/asm/smp.h
> +++ b/arch/powerpc/include/asm/smp.h
> @@ -34,6 +34,20 @@ extern bool coregroup_enabled;
>  extern int cpu_to_chip_id(int cpu);
>  extern int *chip_id_lookup_table;
>  
> +#ifdef CONFIG_PPC_SPLPAR
> +DECLARE_STATIC_KEY_FALSE(shared_processor);
> +
> +static inline bool is_shared_processor(void)
> +{
> + return static_branch_unlikely(_processor);
> +}
> +#else
> +static inline bool is_shared_processor(void)
> +{
> + return false;
> +}
> +#endif
> +
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l1_cache_map);
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l2_cache_map);
>  DECLARE_PER_CPU(cpumask_var_t, thread_group_l3_cache_map);
> -- 
> 2.31.1


[PATCH v2 3/6] powerpc/smp: Move shared_processor static key to smp.h

2023-10-18 Thread Srikar Dronamraju
The ability to detect if the system is running in a shared processor
mode is helpful in few more generic cases not just in
paravirtualization.
For example: At boot time, different scheduler/ topology flags may be
set based on the processor mode. Hence move it to a more generic file.

Signed-off-by: Srikar Dronamraju 
---
 arch/powerpc/include/asm/paravirt.h | 12 
 arch/powerpc/include/asm/smp.h  | 14 ++
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/paravirt.h 
b/arch/powerpc/include/asm/paravirt.h
index 0372b0093f72..cf83e837a571 100644
--- a/arch/powerpc/include/asm/paravirt.h
+++ b/arch/powerpc/include/asm/paravirt.h
@@ -15,13 +15,6 @@
 #include 
 #include 
 
-DECLARE_STATIC_KEY_FALSE(shared_processor);
-
-static inline bool is_shared_processor(void)
-{
-   return static_branch_unlikely(_processor);
-}
-
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
 extern struct static_key paravirt_steal_enabled;
 extern struct static_key paravirt_steal_rq_enabled;
@@ -77,11 +70,6 @@ static inline bool is_vcpu_idle(int vcpu)
return lppaca_of(vcpu).idle;
 }
 #else
-static inline bool is_shared_processor(void)
-{
-   return false;
-}
-
 static inline u32 yield_count_of(int cpu)
 {
return 0;
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 576d0e15..08631b2a4528 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -34,6 +34,20 @@ extern bool coregroup_enabled;
 extern int cpu_to_chip_id(int cpu);
 extern int *chip_id_lookup_table;
 
+#ifdef CONFIG_PPC_SPLPAR
+DECLARE_STATIC_KEY_FALSE(shared_processor);
+
+static inline bool is_shared_processor(void)
+{
+   return static_branch_unlikely(_processor);
+}
+#else
+static inline bool is_shared_processor(void)
+{
+   return false;
+}
+#endif
+
 DECLARE_PER_CPU(cpumask_var_t, thread_group_l1_cache_map);
 DECLARE_PER_CPU(cpumask_var_t, thread_group_l2_cache_map);
 DECLARE_PER_CPU(cpumask_var_t, thread_group_l3_cache_map);
-- 
2.31.1