[PATCH 2/7] powerpc/numa: Consolidate VPHN associativity lookup
From: Srikar Dronamraju
Date: Fri Oct 16 2026 - 07:08:42 EST
There are two helpers for retrieving the associativity of a virtual
processor using VPHN. The helper used during NUMA initialization also
handles the case where the CPU is not yet mapped to a logical CPU,
while the helper used for topology updates operates on a logical CPU.
Consolidate them by extending the former helper to handle both cases.
If the argument corresponds to a possible CPU, translate it to its
hardware ID; otherwise, treat it as a hardware CPU ID directly.
Rename __vphn_get_associativity() to vphn_get_associativity() and use
it for both NUMA initialization and topology updates. Return the VPHN
hypercall return code instead of converting all failures to -1, and
remove the duplicate implementation.
Signed-off-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxx>
---
arch/powerpc/mm/numa.c | 54 ++++--------------------------------------
1 file changed, 5 insertions(+), 49 deletions(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 09f7e7b2b192..df3b51a1beb4 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -641,7 +641,7 @@ int of_drconf_to_nid_single(struct drmem_lmb *lmb)
#ifdef CONFIG_PPC_SPLPAR
-static int __vphn_get_associativity(long lcpu, __be32 *associativity)
+static long vphn_get_associativity(unsigned long lcpu, __be32 *associativity)
{
long rc, hwid;
@@ -665,7 +665,7 @@ static int __vphn_get_associativity(long lcpu, __be32 *associativity)
return 0;
}
- return -1;
+ return rc;
}
static int vphn_get_nid(long lcpu)
@@ -673,7 +673,7 @@ static int vphn_get_nid(long lcpu)
__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
- if (!__vphn_get_associativity(lcpu, associativity))
+ if (!vphn_get_associativity(lcpu, associativity))
return associativity_to_nid(associativity);
return NUMA_NO_NODE;
@@ -681,7 +681,7 @@ static int vphn_get_nid(long lcpu)
}
#else
-static int __vphn_get_associativity(long lcpu, __be32 *associativity)
+static long vphn_get_associativity(unsigned long lcpu, __be32 *associativity)
{
return -1;
}
@@ -951,7 +951,7 @@ static int __init parse_numa_properties(void)
memset(vphn_assoc, 0, VPHN_ASSOC_BUFSIZE * sizeof(__be32));
- if (__vphn_get_associativity(i, vphn_assoc) == 0) {
+ if (vphn_get_associativity(i, vphn_assoc) == 0) {
nid = associativity_to_nid(vphn_assoc);
initialize_form1_numa_distance(vphn_assoc);
index = detect_and_enable_coregroup(vphn_assoc, index);
@@ -1384,43 +1384,6 @@ u64 memory_hotplug_max(void)
#ifdef CONFIG_PPC_SPLPAR
static int topology_inited;
-/*
- * Retrieve the new associativity information for a virtual processor's
- * home node.
- */
-static long vphn_get_associativity(unsigned long cpu,
- __be32 *associativity)
-{
- long rc;
-
- rc = hcall_vphn(get_hard_smp_processor_id(cpu),
- VPHN_FLAG_VCPU, associativity);
-
- switch (rc) {
- case H_SUCCESS:
- pr_debug("VPHN hcall succeeded. Reset polling...\n");
- goto out;
-
- case H_FUNCTION:
- pr_err_ratelimited("VPHN unsupported. Disabling polling...\n");
- break;
- case H_HARDWARE:
- pr_err_ratelimited("hcall_vphn() experienced a hardware fault "
- "preventing VPHN. Disabling polling...\n");
- break;
- case H_PARAMETER:
- pr_err_ratelimited("hcall_vphn() was passed an invalid parameter. "
- "Disabling polling...\n");
- break;
- default:
- pr_err_ratelimited("hcall_vphn() returned %ld. Disabling polling...\n"
- , rc);
- break;
- }
-out:
- return rc;
-}
-
void find_and_update_cpu_nid(int cpu)
{
__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
@@ -1449,13 +1412,6 @@ static int topology_update_init(void)
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)
--
2.47.1