diff mbox series

[v3,2/3] powerpc/numa: Allow cpu_to_coregroup_id without PPC_SPLPAR

Message ID 20260902123458.340456-7-srikar@linux.ibm.com (mailing list archive)
State New
Headers show
Series powerpc/numa: Enable coregroup support on PowerNV | expand

Commit Message

Srikar Dronamraju Sept. 2, 2026, 12:35 p.m. UTC
Make cpu_to_coregroup_id() available outside PPC_SPLPAR so it can be
used by platforms that do not rely on the SPLPAR-specific VPHN path.

Keep the existing fallback behavior by returning the core ID when
coregroup information is unavailable.

Signed-off-by: Srikar Dronamraju <srikar@linux.ibm.com>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
  patch 3 to build correctly)

Changelog from v1:
- Handle comments from Christophe Leroy; Remove extern key word in
  declaration

 arch/powerpc/include/asm/topology.h | 15 +++++++--------
 arch/powerpc/mm/numa.c              | 22 +++++++++++++++-------
 2 files changed, 22 insertions(+), 15 deletions(-)

Comments

Shrikanth Hegde Sept. 4, 2026, 9:59 a.m. UTC | #1
On 9/2/26 6:05 PM, Srikar Dronamraju wrote:
> Make cpu_to_coregroup_id() available outside PPC_SPLPAR so it can be
> used by platforms that do not rely on the SPLPAR-specific VPHN path.
> 
> Keep the existing fallback behavior by returning the core ID when
> coregroup information is unavailable.
> 
> Signed-off-by: Srikar Dronamraju <srikar@linux.ibm.com>
> ---
> Changelog from v2:
> - Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
>    patch 3 to build correctly)
> 
> Changelog from v1:
> - Handle comments from Christophe Leroy; Remove extern key word in
>    declaration
> 
>   arch/powerpc/include/asm/topology.h | 15 +++++++--------
>   arch/powerpc/mm/numa.c              | 22 +++++++++++++++-------
>   2 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
> index 44ec416fa489..02c3c9ab3ea9 100644
> --- a/arch/powerpc/include/asm/topology.h
> +++ b/arch/powerpc/include/asm/topology.h
> @@ -71,6 +71,7 @@ extern void map_cpu_to_node(int cpu, int node);
>   extern void unmap_cpu_from_node(unsigned long cpu);
>   #endif /* CONFIG_HOTPLUG_CPU */
>   
> +int cpu_to_coregroup_id(int cpu);

nit:

I prefer extern before declaration so that i can see it is defined
elsewhere.

Other than that, rest looks good to me.

Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>

>   #else
>   
>   static inline int early_cpu_to_node(int cpu) { return 0; }
> @@ -107,14 +108,6 @@ static inline void map_cpu_to_node(int cpu, int node) {}
>   static inline void unmap_cpu_from_node(unsigned long cpu) {}
>   #endif /* CONFIG_HOTPLUG_CPU */
>   #endif /* CONFIG_SMP */
> -
> -#endif /* CONFIG_NUMA */
> -
> -#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
> -void find_and_update_cpu_nid(int cpu);
> -extern int cpu_to_coregroup_id(int cpu);
> -#else
> -static inline void find_and_update_cpu_nid(int cpu) {}
>   static inline int cpu_to_coregroup_id(int cpu)
>   {
>   #ifdef CONFIG_SMP
> @@ -124,6 +117,12 @@ static inline int cpu_to_coregroup_id(int cpu)
>   #endif
>   }
>   
> +#endif /* CONFIG_NUMA */
> +
> +#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
> +void find_and_update_cpu_nid(int cpu);
> +#else
> +static inline void find_and_update_cpu_nid(int cpu) {}
>   #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
>   
>   #include <asm-generic/topology.h>
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index c44a80d8fc11..5f326b005a2a 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -1428,6 +1428,21 @@ void find_and_update_cpu_nid(int cpu)
>   	pr_debug("%s:%d cpu %d nid %d\n", __func__, __LINE__, cpu, new_nid);
>   }
>   
> +static int topology_update_init(void)
> +{
> +	topology_inited = 1;
> +	return 0;
> +}
> +device_initcall(topology_update_init);
> +
> +#else
> +static long vphn_get_associativity(unsigned long cpu,
> +					__be32 *associativity)
> +{
> +	return -1;
> +}
> +#endif /* CONFIG_PPC_SPLPAR */
> +
>   int cpu_to_coregroup_id(int cpu)
>   {
>   	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
> @@ -1453,10 +1468,3 @@ int cpu_to_coregroup_id(int cpu)
>   	return cpu_to_core_id(cpu);
>   }
>   
> -static int topology_update_init(void)
> -{
> -	topology_inited = 1;
> -	return 0;
> -}
> -device_initcall(topology_update_init);
> -#endif /* CONFIG_PPC_SPLPAR */
Srikar Dronamraju Sept. 4, 2026, 11:10 a.m. UTC | #2
* Shrikanth Hegde <sshegde@linux.ibm.com> [2026-09-04 15:29:03]:

> 
> 
> On 9/2/26 6:05 PM, Srikar Dronamraju wrote:
> > Make cpu_to_coregroup_id() available outside PPC_SPLPAR so it can be
> > used by platforms that do not rely on the SPLPAR-specific VPHN path.
> > 
> > 
> > diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
> > index 44ec416fa489..02c3c9ab3ea9 100644
> > --- a/arch/powerpc/include/asm/topology.h
> > +++ b/arch/powerpc/include/asm/topology.h
> > @@ -71,6 +71,7 @@ extern void map_cpu_to_node(int cpu, int node);
> >   extern void unmap_cpu_from_node(unsigned long cpu);
> >   #endif /* CONFIG_HOTPLUG_CPU */
> > +int cpu_to_coregroup_id(int cpu);
> 
> nit:
> 
> I prefer extern before declaration so that i can see it is defined
> elsewhere.

Hey Shrikanth,

Thanks for taking a look.

It was done on intention based on comment from Christophe Leroy here
https://lkml.kernel.org/r/6387fb12-76f1-4503-8ac2-3ca777c0186e@kernel.org

> 
> Other than that, rest looks good to me.
> 
> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
>
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 44ec416fa489..02c3c9ab3ea9 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -71,6 +71,7 @@  extern void map_cpu_to_node(int cpu, int node);
 extern void unmap_cpu_from_node(unsigned long cpu);
 #endif /* CONFIG_HOTPLUG_CPU */
 
+int cpu_to_coregroup_id(int cpu);
 #else
 
 static inline int early_cpu_to_node(int cpu) { return 0; }
@@ -107,14 +108,6 @@  static inline void map_cpu_to_node(int cpu, int node) {}
 static inline void unmap_cpu_from_node(unsigned long cpu) {}
 #endif /* CONFIG_HOTPLUG_CPU */
 #endif /* CONFIG_SMP */
-
-#endif /* CONFIG_NUMA */
-
-#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
-void find_and_update_cpu_nid(int cpu);
-extern int cpu_to_coregroup_id(int cpu);
-#else
-static inline void find_and_update_cpu_nid(int cpu) {}
 static inline int cpu_to_coregroup_id(int cpu)
 {
 #ifdef CONFIG_SMP
@@ -124,6 +117,12 @@  static inline int cpu_to_coregroup_id(int cpu)
 #endif
 }
 
+#endif /* CONFIG_NUMA */
+
+#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
+void find_and_update_cpu_nid(int cpu);
+#else
+static inline void find_and_update_cpu_nid(int cpu) {}
 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
 
 #include <asm-generic/topology.h>
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index c44a80d8fc11..5f326b005a2a 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1428,6 +1428,21 @@  void find_and_update_cpu_nid(int cpu)
 	pr_debug("%s:%d cpu %d nid %d\n", __func__, __LINE__, cpu, new_nid);
 }
 
+static int topology_update_init(void)
+{
+	topology_inited = 1;
+	return 0;
+}
+device_initcall(topology_update_init);
+
+#else
+static long vphn_get_associativity(unsigned long cpu,
+					__be32 *associativity)
+{
+	return -1;
+}
+#endif /* CONFIG_PPC_SPLPAR */
+
 int cpu_to_coregroup_id(int cpu)
 {
 	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
@@ -1453,10 +1468,3 @@  int cpu_to_coregroup_id(int cpu)
 	return cpu_to_core_id(cpu);
 }
 
-static int topology_update_init(void)
-{
-	topology_inited = 1;
-	return 0;
-}
-device_initcall(topology_update_init);
-#endif /* CONFIG_PPC_SPLPAR */