]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc/numa: Online a node if PHB is attached.
authorNilay Shroff <nilay@linux.ibm.com>
Fri, 17 May 2024 14:25:23 +0000 (19:55 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 4 Jun 2024 07:13:55 +0000 (17:13 +1000)
In the current design, a numa-node is made online only if that node is
attached to cpu/memory. With this design, if any PCI/IO device is found
to be attached to a numa-node which is not online then the numa-node
id of the corresponding PCI/IO device is set to NUMA_NO_NODE(-1). This
design may negatively impact the performance of PCIe device if the
numa-node assigned to PCIe device is -1 because in such case we may not
be able to accurately calculate the distance between two nodes.

The multi-controller NVMe PCIe disk has an issue with calculating the
node distance if the PCIe NVMe controller is attached to a PCI host
bridge which has numa-node id value set to NUMA_NO_NODE. This patch
helps fix this ensuring that a cpu/memory less numa node is made online
if it's attached to PCI host bridge.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Srikar Dronamraju <srikar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240517142531.3273464-3-nilay@linux.ibm.com
arch/powerpc/mm/numa.c
arch/powerpc/platforms/pseries/pci_dlpar.c

index a490724e84adbf74517bb965e7690657e205fa92..aa89899f0c1a1e98e0dac530e39d58bfe13551e0 100644 (file)
@@ -896,7 +896,7 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,
 
 static int __init parse_numa_properties(void)
 {
-       struct device_node *memory;
+       struct device_node *memory, *pci;
        int default_nid = 0;
        unsigned long i;
        const __be32 *associativity;
@@ -1010,6 +1010,18 @@ new_range:
                        goto new_range;
        }
 
+       for_each_node_by_name(pci, "pci") {
+               int nid = NUMA_NO_NODE;
+
+               associativity = of_get_associativity(pci);
+               if (associativity) {
+                       nid = associativity_to_nid(associativity);
+                       initialize_form1_numa_distance(associativity);
+               }
+               if (likely(nid >= 0) && !node_online(nid))
+                       node_set_online(nid);
+       }
+
        /*
         * Now do the same thing for each MEMBLOCK listed in the
         * ibm,dynamic-memory property in the
index 4448386268d99155657fe6179ad8fd0132676f13..52e2623a741dede7228cf7ebaf281b25b3e73833 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/pci.h>
 #include <linux/export.h>
+#include <linux/node.h>
 #include <asm/pci-bridge.h>
 #include <asm/ppc-pci.h>
 #include <asm/firmware.h>
 struct pci_controller *init_phb_dynamic(struct device_node *dn)
 {
        struct pci_controller *phb;
+       int nid;
 
        pr_debug("PCI: Initializing new hotplug PHB %pOF\n", dn);
 
+       nid = of_node_to_nid(dn);
+       if (likely((nid) >= 0)) {
+               if (!node_online(nid)) {
+                       if (__register_one_node(nid)) {
+                               pr_err("PCI: Failed to register node %d\n", nid);
+                       } else {
+                               update_numa_distance(dn);
+                               node_set_online(nid);
+                       }
+               }
+       }
+
        phb = pcibios_alloc_controller(dn);
        if (!phb)
                return NULL;