From d44a098dc92cc9fc7a5b3843fc49e636360e9859 Mon Sep 17 00:00:00 2001 From: Ivan T. Ivanov Date: Apr 25 2023 13:44:31 +0000 Subject: Merge branch 'users/msuchanek/SLE12-SP5/for-next' into SLE12-SP5 --- diff --git a/patches.suse/powerpc-numa-Consider-the-max-NUMA-node-for-migratab.patch b/patches.suse/powerpc-numa-Consider-the-max-NUMA-node-for-migratab.patch new file mode 100644 index 0000000..e62acc0 --- /dev/null +++ b/patches.suse/powerpc-numa-Consider-the-max-NUMA-node-for-migratab.patch @@ -0,0 +1,82 @@ +From 9c7248bb8de31f51c693bfa6a6ea53b1c07e0fa8 Mon Sep 17 00:00:00 2001 +From: Laurent Dufour +Date: Tue, 11 May 2021 09:31:36 +0200 +Subject: [PATCH] powerpc/numa: Consider the max NUMA node for migratable LPAR + +References: bsc#1209999 ltc#202140 bsc#1190544 ltc#194520 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.15-rc1 +Git-commit: 9c7248bb8de31f51c693bfa6a6ea53b1c07e0fa8 + +When a LPAR is migratable, we should consider the maximum possible NUMA +node instead of the number of NUMA nodes from the actual system. + +The DT property 'ibm,current-associativity-domains' defines the maximum +number of nodes the LPAR can see when running on that box. But if the +LPAR is being migrated on another box, it may see up to the nodes +defined by 'ibm,max-associativity-domains'. So if a LPAR is migratable, +that value should be used. + +Unfortunately, there is no easy way to know if an LPAR is migratable or +not. The hypervisor exports the property 'ibm,migratable-partition' in +the case it set to migrate partition, but that would not mean that the +current partition is migratable. + +Without this patch, when a LPAR is started on a 2 node box and then +migrated to a 3 node box, the hypervisor may spread the LPAR's CPUs on +the 3rd node. In that case if a CPU from that 3rd node is added to the +LPAR, it will be wrongly assigned to the node because the kernel has +been set to use up to 2 nodes (the configuration of the departure node). +With this patch applies, the CPU is correctly added to the 3rd node. + +Fixes: f9f130ff2ec9 ("powerpc/numa: Detect support for coregroup") +Signed-off-by: Laurent Dufour +Reviewed-by: Srikar Dronamraju +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210511073136.17795-1-ldufour@linux.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/mm/numa.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index f2bf98bdcea2..094a1076fd1f 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -893,7 +893,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) + static void __init find_possible_nodes(void) + { + struct device_node *rtas; +- const __be32 *domains; ++ const __be32 *domains = NULL; + int prop_length, max_nodes; + u32 i; + +@@ -909,9 +909,14 @@ static void __init find_possible_nodes(void) + * it doesn't exist, then fallback on ibm,max-associativity-domains. + * Current denotes what the platform can support compared to max + * which denotes what the Hypervisor can support. ++ * ++ * If the LPAR is migratable, new nodes might be activated after a LPM, ++ * so we should consider the max number in that case. + */ +- domains = of_get_property(rtas, "ibm,current-associativity-domains", +- &prop_length); ++ if (!of_get_property(of_root, "ibm,migratable-partition", NULL)) ++ domains = of_get_property(rtas, ++ "ibm,current-associativity-domains", ++ &prop_length); + if (!domains) { + domains = of_get_property(rtas, "ibm,max-associativity-domains", + &prop_length); +@@ -920,6 +925,8 @@ static void __init find_possible_nodes(void) + } + + max_nodes = of_read_number(&domains[min_common_depth], 1); ++ pr_info("Partition configured for %d NUMA nodes.\n", max_nodes); ++ + for (i = 0; i < max_nodes; i++) { + if (!node_possible(i)) + node_set(i, node_possible_map); +-- +2.40.0 + diff --git a/patches.suse/powerpc-numa-Detect-support-for-coregroup.patch b/patches.suse/powerpc-numa-Detect-support-for-coregroup.patch new file mode 100644 index 0000000..18bf63c --- /dev/null +++ b/patches.suse/powerpc-numa-Detect-support-for-coregroup.patch @@ -0,0 +1,120 @@ +From f9f130ff2ec93c5949576bbfb168cc9530c23649 Mon Sep 17 00:00:00 2001 +From: Srikar Dronamraju +Date: Mon, 10 Aug 2020 12:48:31 +0530 +Subject: [PATCH] powerpc/numa: Detect support for coregroup + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.10-rc1 +Git-commit: f9f130ff2ec93c5949576bbfb168cc9530c23649 + +Add support for grouping cores based on the device-tree classification. +- The last domain in the associativity domains always refers to the +core. +- If primary reference domain happens to be the penultimate domain in +the associativity domains device-tree property, then there are no +coregroups. However if its not a penultimate domain, then there are +coregroups. There can be more than one coregroup. For now we would be +interested in the last or the smallest coregroups, i.e one sub-group +per DIE. + +Currently there are no firmwares that are exposing this grouping. Hence +allow the basis for grouping to be abstract. Once the firmware starts +using this grouping, code would be added to detect the type of grouping +and adjust the sd domain flags accordingly. + +Signed-off-by: Srikar Dronamraju +Reviewed-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20200810071834.92514-8-srikar@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/smp.h | 1 + + arch/powerpc/kernel/smp.c | 1 + + arch/powerpc/mm/numa.c | 34 +++++++++++++++++++++------------- + 3 files changed, 23 insertions(+), 13 deletions(-) + +diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h +index b727f5f7b8f9..041f0b97c45b 100644 +--- a/arch/powerpc/include/asm/smp.h ++++ b/arch/powerpc/include/asm/smp.h +@@ -28,6 +28,7 @@ + extern int boot_cpuid; + extern int spinning_secondaries; + extern u32 *cpu_to_phys_id; ++extern bool coregroup_enabled; + + extern void cpu_die(void); + extern int cpu_to_chip_id(int cpu); +diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c +--- a/arch/powerpc/kernel/smp.c ++++ b/arch/powerpc/kernel/smp.c +@@ -75,6 +75,7 @@ static DEFINE_PER_CPU(int, cpu_state) = { 0 }; + + struct thread_info *secondary_ti; + bool has_big_cores; ++bool coregroup_enabled; + + DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map); + DEFINE_PER_CPU(cpumask_var_t, cpu_smallcore_map); +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index 481951ac3e55..b2c44c5a81fb 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -897,7 +897,9 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) + static void __init find_possible_nodes(void) + { + struct device_node *rtas; +- u32 numnodes, i; ++ const __be32 *domains; ++ int prop_length, max_nodes; ++ u32 i; + + if (!numa_enabled) + return; +@@ -906,25 +908,31 @@ static void __init find_possible_nodes(void) + if (!rtas) + return; + +- if (of_property_read_u32_index(rtas, "ibm,current-associativity-domains", +- min_common_depth, &numnodes)) { +- /* +- * ibm,current-associativity-domains is a fairly recent +- * property. If it doesn't exist, then fallback on +- * ibm,max-associativity-domains. Current denotes what the +- * platform can support compared to max which denotes what the +- * Hypervisor can support. +- */ +- if (of_property_read_u32_index(rtas, "ibm,max-associativity-domains", +- min_common_depth, &numnodes)) ++ /* ++ * ibm,current-associativity-domains is a fairly recent property. If ++ * it doesn't exist, then fallback on ibm,max-associativity-domains. ++ * Current denotes what the platform can support compared to max ++ * which denotes what the Hypervisor can support. ++ */ ++ domains = of_get_property(rtas, "ibm,current-associativity-domains", ++ &prop_length); ++ if (!domains) { ++ domains = of_get_property(rtas, "ibm,max-associativity-domains", ++ &prop_length); ++ if (!domains) + goto out; + } + +- for (i = 0; i < numnodes; i++) { ++ max_nodes = of_read_number(&domains[min_common_depth], 1); ++ for (i = 0; i < max_nodes; i++) { + if (!node_possible(i)) + node_set(i, node_possible_map); + } + ++ prop_length /= sizeof(int); ++ if (prop_length > min_common_depth + 2) ++ coregroup_enabled = 1; ++ + out: + of_node_put(rtas); + } +-- +2.40.0 + diff --git a/patches.suse/powerpc-numa-Limit-possible-nodes-to-within-num_poss.patch b/patches.suse/powerpc-numa-Limit-possible-nodes-to-within-num_poss.patch new file mode 100644 index 0000000..0afc456 --- /dev/null +++ b/patches.suse/powerpc-numa-Limit-possible-nodes-to-within-num_poss.patch @@ -0,0 +1,61 @@ +From dbce456280857f329af9069af5e48a9b6ebad146 Mon Sep 17 00:00:00 2001 +From: Srikar Dronamraju +Date: Fri, 24 Jul 2020 16:28:09 +0530 +Subject: [PATCH] powerpc/numa: Limit possible nodes to within + num_possible_nodes + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.9-rc1 +Git-commit: dbce456280857f329af9069af5e48a9b6ebad146 + +MAX_NUMNODES is a theoretical maximum number of nodes thats is +supported by the kernel. Device tree properties exposes the number of +possible nodes on the current platform. The kernel would detected this +and would use it for most of its resource allocations. If the platform +now increases the nodes to over what was already exposed, then it may +lead to inconsistencies. Hence limit it to the already exposed nodes. + +Suggested-by: Nathan Lynch +Signed-off-by: Srikar Dronamraju +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20200724105809.24733-1-srikar@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/mm/numa.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index e437a9ac4956..92938393fec6 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -221,7 +221,8 @@ static void initialize_distance_lookup_table(int nid, + } + } + +-/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa ++/* ++ * Returns nid in the range [0..nr_node_ids], or -1 if no useful NUMA + * info is found. + */ + static int associativity_to_nid(const __be32 *associativity) +@@ -235,7 +236,7 @@ static int associativity_to_nid(const __be32 *associativity) + nid = of_read_number(&associativity[min_common_depth], 1); + + /* POWER4 LPAR uses 0xffff as invalid node */ +- if (nid == 0xffff || nid >= MAX_NUMNODES) ++ if (nid == 0xffff || nid >= nr_node_ids) + nid = NUMA_NO_NODE; + + if (nid > 0 && +@@ -448,7 +449,7 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb) + index = lmb->aa_index * aa.array_sz + min_common_depth - 1; + nid = of_read_number(&aa.arrays[index], 1); + +- if (nid == 0xffff || nid >= MAX_NUMNODES) ++ if (nid == 0xffff || nid >= nr_node_ids) + nid = default_nid; + + if (nid > 0) { +-- +2.40.0 + diff --git a/patches.suse/powerpc-numa-Restrict-possible-nodes-based-on-platfo.patch b/patches.suse/powerpc-numa-Restrict-possible-nodes-based-on-platfo.patch new file mode 100644 index 0000000..5a598ba --- /dev/null +++ b/patches.suse/powerpc-numa-Restrict-possible-nodes-based-on-platfo.patch @@ -0,0 +1,150 @@ +From 67df77845c181166d4bc324cbb0382f7e81c7631 Mon Sep 17 00:00:00 2001 +From: Srikar Dronamraju +Date: Mon, 17 Aug 2020 11:22:57 +0530 +Subject: [PATCH] powerpc/numa: Restrict possible nodes based on platform + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.10-rc1 +Git-commit: 67df77845c181166d4bc324cbb0382f7e81c7631 + +As per draft LoPAPR (Revision 2.9_pre7), section B.5.3 "Run Time +Abstraction Services (RTAS) Node" available at: + https://openpowerfoundation.org/wp-content/uploads/2020/07/LoPAR-20200611.pdf + +... there are 2 device tree properties: + + "ibm,max-associativity-domains" + which defines the maximum number of domains that the firmware i.e + PowerVM can support. + +and: + + "ibm,current-associativity-domains" + which defines the maximum number of domains that the current + platform can support. + +The value of "ibm,max-associativity-domains" is always greater than or +equal to "ibm,current-associativity-domains" property. If the latter +property is not available, use "ibm,max-associativity-domain" as a +fallback. In this yet to be released LoPAPR, "ibm,current-associativity-domains" +is mentioned in page 833 / B.5.3 which is covered under under +"Appendix B. System Binding" section + +Currently powerpc uses the "ibm,max-associativity-domains" property +while setting the possible number of nodes. This is currently set at +32. However the possible number of nodes for a platform may be +significantly less. Hence set the possible number of nodes based on +"ibm,current-associativity-domains" property. + +Nathan Lynch had raised a valid concern that post LPM (Live Partition +Migration), a user could DLPAR add processors and memory after LPM +with "new" associativity properties: + https://lore.kernel.org/linuxppc-dev/871rljfet9.fsf@linux.ibm.com/t/#u + +He also pointed out that "ibm,max-associativity-domains" has the same +contents on all currently available PowerVM systems, unlike +"ibm,current-associativity-domains" and hence may be better able to +handle the new NUMA associativity properties. + +However with the recent commit dbce45628085 ("powerpc/numa: Limit +possible nodes to within num_possible_nodes"), all new NUMA +associativity properties are capped to initially set nr_node_ids. +Hence this commit should be safe with any new DLPAR add post LPM. + + $ lsprop /proc/device-tree/rtas/ibm,*associ*-domains + /proc/device-tree/rtas/ibm,current-associativity-domains + 00000005 00000001 00000002 00000002 00000002 00000010 + /proc/device-tree/rtas/ibm,max-associativity-domains + 00000005 00000001 00000008 00000020 00000020 00000100 + + $ cat /sys/devices/system/node/possible ##Before patch + 0-31 + + $ cat /sys/devices/system/node/possible ##After patch + 0-1 + +Note the maximum nodes this platform can support is only 2 but the +possible nodes is set to 32. + +This is important because lot of kernel and user space code allocate +structures for all possible nodes leading to a lot of memory that is +allocated but not used. + +I ran a simple experiment to create and destroy 100 memory cgroups on +boot on a 8 node machine (Power8 Alpine). + +Before patch: + free -k at boot + total used free shared buff/cache available + Mem: 523498176 4106816 518820608 22272 570752 516606720 + Swap: 4194240 0 4194240 + + free -k after creating 100 memory cgroups + total used free shared buff/cache available + Mem: 523498176 4628416 518246464 22336 623296 516058688 + Swap: 4194240 0 4194240 + + free -k after destroying 100 memory cgroups + total used free shared buff/cache available + Mem: 523498176 4697408 518173760 22400 627008 515987904 + Swap: 4194240 0 4194240 + +After patch: + free -k at boot + total used free shared buff/cache available + Mem: 523498176 3969472 518933888 22272 594816 516731776 + Swap: 4194240 0 4194240 + + free -k after creating 100 memory cgroups + total used free shared buff/cache available + Mem: 523498176 4181888 518676096 22208 640192 516496448 + Swap: 4194240 0 4194240 + + free -k after destroying 100 memory cgroups + total used free shared buff/cache available + Mem: 523498176 4232320 518619904 22272 645952 516443264 + Swap: 4194240 0 4194240 + +Observations: + Fixed kernel takes 137344 kb (4106816-3969472) less to boot. + Fixed kernel takes 309184 kb (4628416-4181888-137344) less to create 100 memcgs. + +Signed-off-by: Srikar Dronamraju +[mpe: Reformat change log a bit for readability] +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20200817055257.110873-1-srikar@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/mm/numa.c | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index 1f61fa2148b5..5ddc83ba20f4 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -900,10 +900,19 @@ static void __init find_possible_nodes(void) + if (!rtas) + return; + +- if (of_property_read_u32_index(rtas, +- "ibm,max-associativity-domains", ++ if (of_property_read_u32_index(rtas, "ibm,current-associativity-domains", ++ min_common_depth, &numnodes)) { ++ /* ++ * ibm,current-associativity-domains is a fairly recent ++ * property. If it doesn't exist, then fallback on ++ * ibm,max-associativity-domains. Current denotes what the ++ * platform can support compared to max which denotes what the ++ * Hypervisor can support. ++ */ ++ if (of_property_read_u32_index(rtas, "ibm,max-associativity-domains", + min_common_depth, &numnodes)) +- goto out; ++ goto out; ++ } + + for (i = 0; i < numnodes; i++) { + if (!node_possible(i)) +-- +2.40.0 + diff --git a/patches.suse/powerpc-papr_scm-Update-the-NUMA-distance-table-for-.patch b/patches.suse/powerpc-papr_scm-Update-the-NUMA-distance-table-for-.patch new file mode 100644 index 0000000..c02e78e --- /dev/null +++ b/patches.suse/powerpc-papr_scm-Update-the-NUMA-distance-table-for-.patch @@ -0,0 +1,84 @@ +From b277fc793daf258877b4c0744b52f69d6e6ba22e Mon Sep 17 00:00:00 2001 +From: "Aneesh Kumar K.V" +Date: Tue, 4 Apr 2023 09:44:33 +0530 +Subject: [PATCH] powerpc/papr_scm: Update the NUMA distance table for the + target node + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v6.3-rc7 +Git-commit: b277fc793daf258877b4c0744b52f69d6e6ba22e + +Platform device helper routines won't update the NUMA distance table +while creating a platform device, even if the device is present on a +NUMA node that doesn't have memory or CPU. This is especially true for +pmem devices. If the target node of the pmem device is not online, we +find the nearest online node to the device and associate the pmem device +with that online node. To find the nearest online node, we should have +the numa distance table updated correctly. Update the distance +information during the device probe. + +For a papr scm device on NUMA node 3 distance_lookup_table value for +distance_ref_points_depth = 2 before and after fix is below: + +Before fix: + node 3 distance depth 0 - 0 + node 3 distance depth 1 - 0 + node 4 distance depth 0 - 4 + node 4 distance depth 1 - 2 + node 5 distance depth 0 - 5 + node 5 distance depth 1 - 1 + +After fix + node 3 distance depth 0 - 3 + node 3 distance depth 1 - 1 + node 4 distance depth 0 - 4 + node 4 distance depth 1 - 2 + node 5 distance depth 0 - 5 + node 5 distance depth 1 - 1 + +Without the fix, the nearest numa node to the pmem device (NUMA node 3) +will be picked as 4. After the fix, we get the correct numa node which +is 5. + +Fixes: da1115fdbd6e ("powerpc/nvdimm: Pick nearby online node if the device node is not online") +Signed-off-by: Aneesh Kumar K.V +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230404041433.1781804-1-aneesh.kumar@linux.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/mm/numa.c | 1 + + arch/powerpc/platforms/pseries/papr_scm.c | 7 +++++++ + 2 files changed, 8 insertions(+) + +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -312,6 +312,7 @@ void update_numa_distance(struct device_ + return; + } + } ++EXPORT_SYMBOL_GPL(update_numa_distance); + + static int __init find_primary_domain_index(void) + { +diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c +index 2f8385523a13..1a53e048ceb7 100644 +--- a/arch/powerpc/platforms/pseries/papr_scm.c ++++ b/arch/powerpc/platforms/pseries/papr_scm.c +@@ -1428,6 +1428,13 @@ static int papr_scm_probe(struct platform_device *pdev) + return -ENODEV; + } + ++ /* ++ * open firmware platform device create won't update the NUMA ++ * distance table. For PAPR SCM devices we use numa_map_to_online_node() ++ * to find the nearest online NUMA node and that requires correct ++ * distance table information. ++ */ ++ update_numa_distance(dn); + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) +-- +2.40.0 + diff --git a/patches.suse/powerpc-pseries-Consolidate-different-NUMA-distance-.patch b/patches.suse/powerpc-pseries-Consolidate-different-NUMA-distance-.patch new file mode 100644 index 0000000..e5d1b56 --- /dev/null +++ b/patches.suse/powerpc-pseries-Consolidate-different-NUMA-distance-.patch @@ -0,0 +1,391 @@ +From 8ddc6448ec5a5ef50eaa581a7dec0e12a02850ff Mon Sep 17 00:00:00 2001 +From: "Aneesh Kumar K.V" +Date: Thu, 12 Aug 2021 18:52:21 +0530 +Subject: [PATCH] powerpc/pseries: Consolidate different NUMA distance update + code paths + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.15-rc1 +Git-commit: 8ddc6448ec5a5ef50eaa581a7dec0e12a02850ff + +The associativity details of the newly added resourced are collected from +the hypervisor via "ibm,configure-connector" rtas call. Update the numa +distance details of the newly added numa node after the above call. + +Instead of updating NUMA distance every time we lookup a node id +from the associativity property, add helpers that can be used +during boot which does this only once. Also remove the distance +update from node id lookup helpers. + +Currently, we duplicate parsing code for ibm,associativity and +ibm,associativity-lookup-arrays in the kernel. The associativity array provided +by these device tree properties are very similar and hence can use +a helper to parse the node id and numa distance details. + +Signed-off-by: Aneesh Kumar K.V +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210812132223.225214-4-aneesh.kumar@linux.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/topology.h | 2 + + arch/powerpc/mm/numa.c | 212 +++++++++++++----- + arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 + + .../platforms/pseries/hotplug-memory.c | 2 + + 4 files changed, 161 insertions(+), 57 deletions(-) + +diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h +index e4db64c0e184..a6425a70c37b 100644 +--- a/arch/powerpc/include/asm/topology.h ++++ b/arch/powerpc/include/asm/topology.h +@@ -64,6 +64,7 @@ static inline int early_cpu_to_node(int cpu) + } + + int of_drconf_to_nid_single(struct drmem_lmb *lmb); ++void update_numa_distance(struct device_node *node); + + #else + +@@ -93,6 +94,7 @@ static inline int of_drconf_to_nid_single(struct drmem_lmb *lmb) + return first_online_node; + } + ++static inline void update_numa_distance(struct device_node *node) {} + #endif /* CONFIG_NUMA */ + + #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR) +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index 0bad11b3e929..3cda37c52f26 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -208,50 +208,35 @@ int __node_distance(int a, int b) + } + EXPORT_SYMBOL(__node_distance); + +-static void initialize_distance_lookup_table(int nid, +- const __be32 *associativity) ++static int __associativity_to_nid(const __be32 *associativity, ++ int max_array_sz) + { +- int i; ++ int nid; ++ /* ++ * primary_domain_index is 1 based array index. ++ */ ++ int index = primary_domain_index - 1; + +- if (affinity_form != FORM1_AFFINITY) +- return; ++ if (!numa_enabled || index >= max_array_sz) ++ return NUMA_NO_NODE; + +- for (i = 0; i < distance_ref_points_depth; i++) { +- const __be32 *entry; ++ nid = of_read_number(&associativity[index], 1); + +- entry = &associativity[be32_to_cpu(distance_ref_points[i]) - 1]; +- distance_lookup_table[nid][i] = of_read_number(entry, 1); +- } ++ /* POWER4 LPAR uses 0xffff as invalid node */ ++ if (nid == 0xffff || nid >= nr_node_ids) ++ nid = NUMA_NO_NODE; ++ return nid; + } +- + /* + * Returns nid in the range [0..nr_node_ids], or -1 if no useful NUMA + * info is found. + */ + static int associativity_to_nid(const __be32 *associativity) + { +- int nid = NUMA_NO_NODE; +- +- if (!numa_enabled) +- goto out; +- +- if (of_read_number(associativity, 1) >= primary_domain_index) +- nid = of_read_number(&associativity[primary_domain_index], 1); +- +- /* POWER4 LPAR uses 0xffff as invalid node */ +- if (nid == 0xffff || nid >= nr_node_ids) +- nid = NUMA_NO_NODE; +- +- if (nid > 0 && +- of_read_number(associativity, 1) >= distance_ref_points_depth) { +- /* +- * Skip the length field and send start of associativity array +- */ +- initialize_distance_lookup_table(nid, associativity + 1); +- } ++ int array_sz = of_read_number(associativity, 1); + +-out: +- return nid; ++ /* Skip the first element in the associativity array */ ++ return __associativity_to_nid((associativity + 1), array_sz); + } + + /* Returns the nid associated with the given device tree node, +@@ -287,6 +272,60 @@ int of_node_to_nid(struct device_node *device) + } + EXPORT_SYMBOL(of_node_to_nid); + ++static void __initialize_form1_numa_distance(const __be32 *associativity, ++ int max_array_sz) ++{ ++ int i, nid; ++ ++ if (affinity_form != FORM1_AFFINITY) ++ return; ++ ++ nid = __associativity_to_nid(associativity, max_array_sz); ++ if (nid != NUMA_NO_NODE) { ++ for (i = 0; i < distance_ref_points_depth; i++) { ++ const __be32 *entry; ++ int index = be32_to_cpu(distance_ref_points[i]) - 1; ++ ++ /* ++ * broken hierarchy, return with broken distance table ++ */ ++ if (WARN(index >= max_array_sz, "Broken ibm,associativity property")) ++ return; ++ ++ entry = &associativity[index]; ++ distance_lookup_table[nid][i] = of_read_number(entry, 1); ++ } ++ } ++} ++ ++static void initialize_form1_numa_distance(const __be32 *associativity) ++{ ++ int array_sz; ++ ++ array_sz = of_read_number(associativity, 1); ++ /* Skip the first element in the associativity array */ ++ __initialize_form1_numa_distance(associativity + 1, array_sz); ++} ++ ++/* ++ * Used to update distance information w.r.t newly added node. ++ */ ++void update_numa_distance(struct device_node *node) ++{ ++ if (affinity_form == FORM0_AFFINITY) ++ return; ++ else if (affinity_form == FORM1_AFFINITY) { ++ const __be32 *associativity; ++ ++ associativity = of_get_associativity(node); ++ if (!associativity) ++ return; ++ ++ initialize_form1_numa_distance(associativity); ++ return; ++ } ++} ++ + static int __init find_primary_domain_index(void) + { + int index; +@@ -433,6 +472,38 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa) + return 0; + } + ++static int get_nid_and_numa_distance(struct drmem_lmb *lmb) ++{ ++ struct assoc_arrays aa = { .arrays = NULL }; ++ int default_nid = NUMA_NO_NODE; ++ int nid = default_nid; ++ int rc, index; ++ ++ if ((primary_domain_index < 0) || !numa_enabled) ++ return default_nid; ++ ++ rc = of_get_assoc_arrays(&aa); ++ if (rc) ++ return default_nid; ++ ++ if (primary_domain_index <= aa.array_sz && ++ !(lmb->flags & DRCONF_MEM_AI_INVALID) && lmb->aa_index < aa.n_arrays) { ++ const __be32 *associativity; ++ ++ index = lmb->aa_index * aa.array_sz; ++ associativity = &aa.arrays[index]; ++ nid = __associativity_to_nid(associativity, aa.array_sz); ++ if (nid > 0 && affinity_form == FORM1_AFFINITY) { ++ /* ++ * lookup array associativity entries have ++ * no length of the array as the first element. ++ */ ++ __initialize_form1_numa_distance(associativity, aa.array_sz); ++ } ++ } ++ return nid; ++} ++ + /* + * This is like of_node_to_nid_single() for memory represented in the + * ibm,dynamic-reconfiguration-memory node. +@@ -453,26 +524,19 @@ int of_drconf_to_nid_single(struct drmem_lmb *lmb) + + if (primary_domain_index <= aa.array_sz && + !(lmb->flags & DRCONF_MEM_AI_INVALID) && lmb->aa_index < aa.n_arrays) { +- index = lmb->aa_index * aa.array_sz + primary_domain_index - 1; +- nid = of_read_number(&aa.arrays[index], 1); +- +- if (nid == 0xffff || nid >= nr_node_ids) +- nid = default_nid; ++ const __be32 *associativity; + +- if (nid > 0) { +- index = lmb->aa_index * aa.array_sz; +- initialize_distance_lookup_table(nid, +- &aa.arrays[index]); +- } ++ index = lmb->aa_index * aa.array_sz; ++ associativity = &aa.arrays[index]; ++ nid = __associativity_to_nid(associativity, aa.array_sz); + } +- + return nid; + } + + #ifdef CONFIG_PPC_SPLPAR +-static int vphn_get_nid(long lcpu) ++ ++static int __vphn_get_associativity(long lcpu, __be32 *associativity) + { +- __be32 associativity[VPHN_ASSOC_BUFSIZE] = {0}; + long rc, hwid; + + /* +@@ -492,12 +556,30 @@ static int vphn_get_nid(long lcpu) + + rc = hcall_vphn(hwid, VPHN_FLAG_VCPU, associativity); + if (rc == H_SUCCESS) +- return associativity_to_nid(associativity); ++ return 0; + } + ++ return -1; ++} ++ ++static int vphn_get_nid(long lcpu) ++{ ++ __be32 associativity[VPHN_ASSOC_BUFSIZE] = {0}; ++ ++ ++ if (!__vphn_get_associativity(lcpu, associativity)) ++ return associativity_to_nid(associativity); ++ + return NUMA_NO_NODE; ++ + } + #else ++ ++static int __vphn_get_associativity(long lcpu, __be32 *associativity) ++{ ++ return -1; ++} ++ + static int vphn_get_nid(long unused) + { + return NUMA_NO_NODE; +@@ -692,7 +774,7 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, + size = read_n_cells(n_mem_size_cells, usm); + } + +- nid = of_drconf_to_nid_single(lmb); ++ nid = get_nid_and_numa_distance(lmb); + fake_numa_create_new_node(((base + size) >> PAGE_SHIFT), + &nid); + node_set_online(nid); +@@ -709,6 +791,7 @@ static int __init parse_numa_properties(void) + struct device_node *memory; + int default_nid = 0; + unsigned long i; ++ const __be32 *associativity; + + if (numa_enabled == 0) { + printk(KERN_WARNING "NUMA disabled by user\n"); +@@ -734,18 +817,30 @@ static int __init parse_numa_properties(void) + * each node to be onlined must have NODE_DATA etc backing it. + */ + for_each_present_cpu(i) { ++ __be32 vphn_assoc[VPHN_ASSOC_BUFSIZE]; + struct device_node *cpu; +- int nid = vphn_get_nid(i); ++ int nid = NUMA_NO_NODE; + +- /* +- * Don't fall back to default_nid yet -- we will plug +- * cpus into nodes once the memory scan has discovered +- * the topology. +- */ +- if (nid == NUMA_NO_NODE) { ++ memset(vphn_assoc, 0, VPHN_ASSOC_BUFSIZE * sizeof(__be32)); ++ ++ if (__vphn_get_associativity(i, vphn_assoc) == 0) { ++ nid = associativity_to_nid(vphn_assoc); ++ initialize_form1_numa_distance(vphn_assoc); ++ } else { ++ ++ /* ++ * Don't fall back to default_nid yet -- we will plug ++ * cpus into nodes once the memory scan has discovered ++ * the topology. ++ */ + cpu = of_get_cpu_node(i, NULL); + BUG_ON(!cpu); +- nid = of_node_to_nid_single(cpu); ++ ++ associativity = of_get_associativity(cpu); ++ if (associativity) { ++ nid = associativity_to_nid(associativity); ++ initialize_form1_numa_distance(associativity); ++ } + of_node_put(cpu); + } + +@@ -781,8 +876,11 @@ static int __init parse_numa_properties(void) + * have associativity properties. If none, then + * everything goes to default_nid. + */ +- nid = of_node_to_nid_single(memory); +- if (nid < 0) ++ associativity = of_get_associativity(memory); ++ if (associativity) { ++ nid = associativity_to_nid(associativity); ++ initialize_form1_numa_distance(associativity); ++ } else + nid = default_nid; + + fake_numa_create_new_node(((start + size) >> PAGE_SHIFT), &nid); +diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c +index e1f224320102..1ef40ef699a6 100644 +--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c ++++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c +@@ -580,6 +580,8 @@ static ssize_t dlpar_cpu_add(u32 drc_index) + return saved_rc; + } + ++ update_numa_distance(dn); ++ + rc = dlpar_online_cpu(dn); + if (rc) { + saved_rc = rc; +diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c +index 0beb3ca2b549..14fccd7b9c99 100644 +--- a/arch/powerpc/platforms/pseries/hotplug-memory.c ++++ b/arch/powerpc/platforms/pseries/hotplug-memory.c +@@ -180,6 +180,8 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) + return -ENODEV; + } + ++ update_numa_distance(lmb_node); ++ + dr_node = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); + if (!dr_node) { + dlpar_free_cc_nodes(lmb_node); +-- +2.40.0 + diff --git a/patches.suse/powerpc-pseries-Rename-TYPE1_AFFINITY-to-FORM1_AFFIN.patch b/patches.suse/powerpc-pseries-Rename-TYPE1_AFFINITY-to-FORM1_AFFIN.patch new file mode 100644 index 0000000..977ef96 --- /dev/null +++ b/patches.suse/powerpc-pseries-Rename-TYPE1_AFFINITY-to-FORM1_AFFIN.patch @@ -0,0 +1,168 @@ +From 0eacd06bb8adea8dd9edb0a30144166d9f227e64 Mon Sep 17 00:00:00 2001 +From: "Aneesh Kumar K.V" +Date: Thu, 12 Aug 2021 18:52:20 +0530 +Subject: [PATCH] powerpc/pseries: Rename TYPE1_AFFINITY to FORM1_AFFINITY + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.15-rc1 +Git-commit: 0eacd06bb8adea8dd9edb0a30144166d9f227e64 + +Also make related code cleanup that will allow adding FORM2_AFFINITY in +later patches. No functional change in this patch. + +Signed-off-by: Aneesh Kumar K.V +Reviewed-by: David Gibson +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210812132223.225214-3-aneesh.kumar@linux.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/firmware.h | 4 +-- + arch/powerpc/include/asm/prom.h | 2 +- + arch/powerpc/kernel/prom_init.c | 2 +- + arch/powerpc/mm/numa.c | 35 ++++++++++++++--------- + arch/powerpc/platforms/pseries/firmware.c | 2 +- + 5 files changed, 26 insertions(+), 19 deletions(-) + +diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h +--- a/arch/powerpc/include/asm/firmware.h ++++ b/arch/powerpc/include/asm/firmware.h +@@ -44,7 +44,7 @@ + #define FW_FEATURE_OPAL ASM_CONST(0x0000000010000000) + #define FW_FEATURE_SET_MODE ASM_CONST(0x0000000040000000) + #define FW_FEATURE_BEST_ENERGY ASM_CONST(0x0000000080000000) +-#define FW_FEATURE_TYPE1_AFFINITY ASM_CONST(0x0000000100000000) ++#define FW_FEATURE_FORM1_AFFINITY ASM_CONST(0x0000000100000000) + #define FW_FEATURE_PRRN ASM_CONST(0x0000000200000000) + #define FW_FEATURE_DRMEM_V2 ASM_CONST(0x0000000400000000) + #define FW_FEATURE_DRC_INFO ASM_CONST(0x0000000800000000) +@@ -69,7 +69,7 @@ enum { + FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | + FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO | + FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY | +- FW_FEATURE_TYPE1_AFFINITY | FW_FEATURE_PRRN | ++ FW_FEATURE_FORM1_AFFINITY | FW_FEATURE_PRRN | + FW_FEATURE_HPT_RESIZE | FW_FEATURE_DRMEM_V2 | + FW_FEATURE_DRC_INFO | FW_FEATURE_BLOCK_REMOVE | + FW_FEATURE_PAPR_SCM | FW_FEATURE_RPT_INVALIDATE, +diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h +index 324a13351749..df9fec9d232c 100644 +--- a/arch/powerpc/include/asm/prom.h ++++ b/arch/powerpc/include/asm/prom.h +@@ -147,7 +147,7 @@ extern int of_read_drc_info_cell(struct property **prop, + #define OV5_MSI 0x0201 /* PCIe/MSI support */ + #define OV5_CMO 0x0480 /* Cooperative Memory Overcommitment */ + #define OV5_XCMO 0x0440 /* Page Coalescing */ +-#define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */ ++#define OV5_FORM1_AFFINITY 0x0580 /* FORM1 NUMA affinity */ + #define OV5_PRRN 0x0540 /* Platform Resource Reassignment */ + #define OV5_HP_EVT 0x0604 /* Hot Plug Event support */ + #define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */ +diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c +index a5bf355ce1d6..57db605ad33a 100644 +--- a/arch/powerpc/kernel/prom_init.c ++++ b/arch/powerpc/kernel/prom_init.c +@@ -1096,7 +1096,7 @@ static const struct ibm_arch_vec ibm_architecture_vec_template __initconst = { + #else + 0, + #endif +- .associativity = OV5_FEAT(OV5_TYPE1_AFFINITY) | OV5_FEAT(OV5_PRRN), ++ .associativity = OV5_FEAT(OV5_FORM1_AFFINITY) | OV5_FEAT(OV5_PRRN), + .bin_opts = OV5_FEAT(OV5_RESIZE_HPT) | OV5_FEAT(OV5_HP_EVT), + .micro_checkpoint = 0, + .reserved0 = 0, +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +index 79132744b728..0bad11b3e929 100644 +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -53,7 +53,10 @@ EXPORT_SYMBOL(node_data); + + static int primary_domain_index; + static int n_mem_addr_cells, n_mem_size_cells; +-static int form1_affinity; ++ ++#define FORM0_AFFINITY 0 ++#define FORM1_AFFINITY 1 ++static int affinity_form; + + #define MAX_DISTANCE_REF_POINTS 4 + static int distance_ref_points_depth; +@@ -190,7 +193,7 @@ int __node_distance(int a, int b) + int i; + int distance = LOCAL_DISTANCE; + +- if (!form1_affinity) ++ if (affinity_form == FORM0_AFFINITY) + return ((a == b) ? LOCAL_DISTANCE : REMOTE_DISTANCE); + + for (i = 0; i < distance_ref_points_depth; i++) { +@@ -210,7 +213,7 @@ static void initialize_distance_lookup_table(int nid, + { + int i; + +- if (!form1_affinity) ++ if (affinity_form != FORM1_AFFINITY) + return; + + for (i = 0; i < distance_ref_points_depth; i++) { +@@ -289,6 +292,17 @@ static int __init find_primary_domain_index(void) + int index; + struct device_node *root; + ++ /* ++ * Check for which form of affinity. ++ */ ++ if (firmware_has_feature(FW_FEATURE_OPAL)) { ++ affinity_form = FORM1_AFFINITY; ++ } else if (firmware_has_feature(FW_FEATURE_FORM1_AFFINITY)) { ++ dbg("Using form 1 affinity\n"); ++ affinity_form = FORM1_AFFINITY; ++ } else ++ affinity_form = FORM0_AFFINITY; ++ + if (firmware_has_feature(FW_FEATURE_OPAL)) + root = of_find_node_by_path("/ibm,opal"); + else +@@ -318,23 +332,16 @@ static int __init find_primary_domain_index(void) + } + + distance_ref_points_depth /= sizeof(int); +- +- if (firmware_has_feature(FW_FEATURE_OPAL) || +- firmware_has_feature(FW_FEATURE_TYPE1_AFFINITY)) { +- dbg("Using form 1 affinity\n"); +- form1_affinity = 1; +- } +- +- if (form1_affinity) { +- index = of_read_number(distance_ref_points, 1); +- } else { ++ if (affinity_form == FORM0_AFFINITY) { + if (distance_ref_points_depth < 2) { + printk(KERN_WARNING "NUMA: " +- "short ibm,associativity-reference-points\n"); ++ "short ibm,associativity-reference-points\n"); + goto err; + } + + index = of_read_number(&distance_ref_points[1], 1); ++ } else { ++ index = of_read_number(distance_ref_points, 1); + } + + /* +diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c +index 4c7b7f5a2ebc..5d4c2bc20bba 100644 +--- a/arch/powerpc/platforms/pseries/firmware.c ++++ b/arch/powerpc/platforms/pseries/firmware.c +@@ -119,7 +119,7 @@ struct vec5_fw_feature { + + static __initdata struct vec5_fw_feature + vec5_fw_features_table[] = { +- {FW_FEATURE_TYPE1_AFFINITY, OV5_TYPE1_AFFINITY}, ++ {FW_FEATURE_FORM1_AFFINITY, OV5_FORM1_AFFINITY}, + {FW_FEATURE_PRRN, OV5_PRRN}, + {FW_FEATURE_DRMEM_V2, OV5_DRMEM_V2}, + {FW_FEATURE_DRC_INFO, OV5_DRC_INFO}, +-- +2.40.0 + diff --git a/patches.suse/powerpc-pseries-rename-min_common_depth-to-primary_d.patch b/patches.suse/powerpc-pseries-rename-min_common_depth-to-primary_d.patch new file mode 100644 index 0000000..b6b8eaf --- /dev/null +++ b/patches.suse/powerpc-pseries-rename-min_common_depth-to-primary_d.patch @@ -0,0 +1,145 @@ +From 7e35ef662ca05c42dbc2f401bb76d9219dd7fd02 Mon Sep 17 00:00:00 2001 +From: "Aneesh Kumar K.V" +Date: Thu, 12 Aug 2021 18:52:19 +0530 +Subject: [PATCH] powerpc/pseries: rename min_common_depth to + primary_domain_index + +References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes +Patch-mainline: v5.15-rc1 +Git-commit: 7e35ef662ca05c42dbc2f401bb76d9219dd7fd02 + +No functional change in this patch. + +Signed-off-by: Aneesh Kumar K.V +Reviewed-by: David Gibson +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210812132223.225214-2-aneesh.kumar@linux.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/mm/numa.c | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c +--- a/arch/powerpc/mm/numa.c ++++ b/arch/powerpc/mm/numa.c +@@ -51,7 +51,7 @@ EXPORT_SYMBOL(numa_cpu_lookup_table); + EXPORT_SYMBOL(node_to_cpumask_map); + EXPORT_SYMBOL(node_data); + +-static int min_common_depth; ++static int primary_domain_index; + static int n_mem_addr_cells, n_mem_size_cells; + static int form1_affinity; + +@@ -232,8 +232,8 @@ static int associativity_to_nid(const __be32 *associativity) + if (!numa_enabled) + goto out; + +- if (of_read_number(associativity, 1) >= min_common_depth) +- nid = of_read_number(&associativity[min_common_depth], 1); ++ if (of_read_number(associativity, 1) >= primary_domain_index) ++ nid = of_read_number(&associativity[primary_domain_index], 1); + + /* POWER4 LPAR uses 0xffff as invalid node */ + if (nid == 0xffff || nid >= nr_node_ids) +@@ -284,9 +284,9 @@ int of_node_to_nid(struct device_node *device) + } + EXPORT_SYMBOL(of_node_to_nid); + +-static int __init find_min_common_depth(void) ++static int __init find_primary_domain_index(void) + { +- int depth; ++ int index; + struct device_node *root; + + if (firmware_has_feature(FW_FEATURE_OPAL)) +@@ -326,7 +326,7 @@ static int __init find_min_common_depth(void) + } + + if (form1_affinity) { +- depth = of_read_number(distance_ref_points, 1); ++ index = of_read_number(distance_ref_points, 1); + } else { + if (distance_ref_points_depth < 2) { + printk(KERN_WARNING "NUMA: " +@@ -334,7 +334,7 @@ static int __init find_min_common_depth(void) + goto err; + } + +- depth = of_read_number(&distance_ref_points[1], 1); ++ index = of_read_number(&distance_ref_points[1], 1); + } + + /* +@@ -348,7 +348,7 @@ static int __init find_min_common_depth(void) + } + + of_node_put(root); +- return depth; ++ return index; + + err: + of_node_put(root); +@@ -437,16 +437,16 @@ int of_drconf_to_nid_single(struct drmem_lmb *lmb) + int nid = default_nid; + int rc, index; + +- if ((min_common_depth < 0) || !numa_enabled) ++ if ((primary_domain_index < 0) || !numa_enabled) + return default_nid; + + rc = of_get_assoc_arrays(&aa); + if (rc) + return default_nid; + +- if (min_common_depth <= aa.array_sz && ++ if (primary_domain_index <= aa.array_sz && + !(lmb->flags & DRCONF_MEM_AI_INVALID) && lmb->aa_index < aa.n_arrays) { +- index = lmb->aa_index * aa.array_sz + min_common_depth - 1; ++ index = lmb->aa_index * aa.array_sz + primary_domain_index - 1; + nid = of_read_number(&aa.arrays[index], 1); + + if (nid == 0xffff || nid >= nr_node_ids) +@@ -708,18 +708,18 @@ static int __init parse_numa_properties(void) + return -1; + } + +- min_common_depth = find_min_common_depth(); ++ primary_domain_index = find_primary_domain_index(); + +- if (min_common_depth < 0) { ++ if (primary_domain_index < 0) { + /* +- * if we fail to parse min_common_depth from device tree ++ * if we fail to parse primary_domain_index from device tree + * mark the numa disabled, boot with numa disabled. + */ + numa_enabled = false; +- return min_common_depth; ++ return primary_domain_index; + } + +- dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth); ++ dbg("NUMA associativity depth for CPU/Memory: %d\n", primary_domain_index); + + /* + * Even though we connect cpus to numa domains later in SMP +@@ -924,7 +924,7 @@ static void __init find_possible_nodes(void) + goto out; + } + +- max_nodes = of_read_number(&domains[min_common_depth], 1); ++ max_nodes = of_read_number(&domains[primary_domain_index], 1); + pr_info("Partition configured for %d NUMA nodes.\n", max_nodes); + + for (i = 0; i < max_nodes; i++) { +@@ -933,7 +933,7 @@ static void __init find_possible_nodes(void) + } + + prop_length /= sizeof(int); +- if (prop_length > min_common_depth + 2) ++ if (prop_length > primary_domain_index + 2) + coregroup_enabled = 1; + + out: diff --git a/series.conf b/series.conf index 5e874e4..a7c589f 100644 --- a/series.conf +++ b/series.conf @@ -57704,6 +57704,7 @@ patches.suse/powerpc-book3s64-pkeys-Use-PVR-check-instead-of-cpu-.patch patches.suse/powerpc-perf-Fix-missing-is_sier_aviable-during-buil.patch patches.suse/powerpc-pseries-PCIE-PHB-reset.patch + patches.suse/powerpc-numa-Limit-possible-nodes-to-within-num_poss.patch patches.suse/powerpc-Allow-4224-bytes-of-stack-expansion-for-the-.patch patches.suse/powerpc-mm-Limit-resize_hpt_for_hotplug-call-to-hash.patch patches.suse/powerpc-boot-Fix-CONFIG_PPC_MPC52XX-references.patch @@ -58547,7 +58548,9 @@ patches.suse/powerpc-pseries-explicitly-reschedule-during-drmem_l.patch patches.suse/pseries-drmem-don-t-cache-node-id-in-drmem_lmb-struc.patch patches.suse/powerepc-book3s64-hash-Align-start-end-address-corre.patch + patches.suse/powerpc-numa-Restrict-possible-nodes-based-on-platfo.patch patches.suse/powerpc-numa-Prefer-node-id-queried-from-vphn.patch + patches.suse/powerpc-numa-Detect-support-for-coregroup.patch patches.suse/powerpc-powernv-elog-Fix-race-while-processing-OPAL-.patch patches.suse/powerpc-pseries-add-new-branch-prediction-security-b.patch patches.suse/powerpc-rtas-Restrict-RTAS-requests-from-userspace.patch @@ -61544,8 +61547,12 @@ patches.suse/memcg-enable-accounting-of-ipc-resources.patch patches.suse/mm-vmscan-guarantee-drop_slab_node-termination.patch patches.suse/s390-pv-fix-the-forcing-of-the-swiotlb + patches.suse/powerpc-numa-Consider-the-max-NUMA-node-for-migratab.patch patches.suse/pseries-drmem-update-LMBs-after-LPM.patch patches.suse/powerpc-pseries-Prevent-free-CPU-ids-being-reused-on.patch + patches.suse/powerpc-pseries-rename-min_common_depth-to-primary_d.patch + patches.suse/powerpc-pseries-Rename-TYPE1_AFFINITY-to-FORM1_AFFIN.patch + patches.suse/powerpc-pseries-Consolidate-different-NUMA-distance-.patch patches.suse/powerpc-pseries-Fix-build-error-when-NUMA-n.patch patches.suse/powerpc-perf-hv-gpci-Fix-counter-value-parsing.patch patches.suse/powerpc-perf-Use-stack-siar-instead-of-mfspr.patch @@ -63230,6 +63237,7 @@ patches.suse/ring-buffer-Fix-race-while-reader-and-writer-are-on-the-same-page.patch patches.suse/ftrace-Mark-get_lock_parent_ip-__always_inline.patch patches.suse/cifs-fix-negotiate-context-parsing.patch + patches.suse/powerpc-papr_scm-Update-the-NUMA-distance-table-for-.patch # dhowells/linux-fs keys-uefi patches.suse/0001-KEYS-Allow-unrestricted-boot-time-addition-of-keys-t.patch