Move the CPU associativity processing loop from parse_numa_properties()
into a dedicated process_cpu_associativity() function. This improves code
organization by separating concerns:

- parse_numa_properties() handles overall NUMA initialization
- process_cpu_associativity() focuses on CPU associativity processing

This also allows CPU associativity processing to be invoked again after
the processor sharing mode is known.

No functional change in the initialization flow.

Signed-off-by: Srikar Dronamraju <[email protected]>
---
 arch/powerpc/mm/numa.c | 65 +++++++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index c2aefb60ed5a..fde79f34340e 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -918,44 +918,18 @@ static int detect_and_enable_coregroup(const __be32 
*associativity, int index)
        return -1;
 }
 
-static int __init parse_numa_properties(void)
+static void process_cpu_associativity(void)
 {
        bool vphn = firmware_has_feature(FW_FEATURE_VPHN);
-       struct device_node *memory, *pci;
-       int default_nid = 0, index = 0;
-       const __be32 *associativity;
        unsigned long i;
+       int index = 0;
 
-       primary_domain_index = find_primary_domain_index();
-
-       if (primary_domain_index < 0) {
-               /*
-                * if we fail to parse primary_domain_index from device tree
-                * mark the numa disabled, boot with numa disabled.
-                */
-               numa_enabled = false;
-               return primary_domain_index;
-       }
-
-       pr_debug("associativity depth for CPU/Memory: %d\n", 
primary_domain_index);
-
-       /*
-        * If it is FORM2 initialize the distance table here.
-        */
-       if (affinity_form == FORM2_AFFINITY)
-               initialize_form2_numa_distance_lookup_table();
-
-       /*
-        * Even though we connect cpus to numa domains later in SMP
-        * init, we need to know the node ids now. This is because
-        * each node to be onlined must have NODE_DATA etc backing it.
-        */
        for_each_present_cpu(i) {
+               const __be32 *associativity = NULL;
                __be32 vphn_assoc[VPHN_ASSOC_BUFSIZE];
                struct device_node *cpu = NULL;
                int nid = NUMA_NO_NODE;
 
-               associativity = NULL;
                if (vphn) {
                        memset(vphn_assoc, 0, VPHN_ASSOC_BUFSIZE * 
sizeof(__be32));
                        if (vphn_get_associativity(i, vphn_assoc) == 0)
@@ -984,6 +958,39 @@ static int __init parse_numa_properties(void)
                if (likely(nid >= 0) && numa_enabled)
                        node_set_online(nid);
        }
+}
+
+static int __init parse_numa_properties(void)
+{
+       struct device_node *memory, *pci;
+       int default_nid = 0;
+       const __be32 *associativity;
+
+       primary_domain_index = find_primary_domain_index();
+
+       if (primary_domain_index < 0) {
+               /*
+                * if we fail to parse primary_domain_index from device tree
+                * mark the numa disabled, boot with numa disabled.
+                */
+               numa_enabled = false;
+               return primary_domain_index;
+       }
+
+       pr_debug("associativity depth for CPU/Memory: %d\n", 
primary_domain_index);
+
+       /*
+        * If it is FORM2 initialize the distance table here.
+        */
+       if (affinity_form == FORM2_AFFINITY)
+               initialize_form2_numa_distance_lookup_table();
+
+       /*
+        * Even though we connect cpus to numa domains later in SMP
+        * init, we need to know the node ids now. This is because
+        * each node to be onlined must have NODE_DATA etc backing it.
+        */
+       process_cpu_associativity();
 
        if (numa_enabled == 0) {
                pr_warn("disabled by user\n");
-- 
2.47.1


Reply via email to