Skip to contentSkip to conversation

powerpc/dlpar: Correct display of hot-add/hot-remove CPUs and memory

PATCH Superseded Michael Bringmann 2 participants 4 messages Aug 29, 2017 PowerPC

v11 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v11 cover powerpc/dlpar: Correct display of hot-add/hot-remove CPUs and memory

On Power systems with shared configurations of CPUs and memory, there are some issues with association of additional CPUs and memory to nodes when hot-adding resources. These patches address some of those problems.

powerpc/numa: Correct the currently broken capability to set the topology for shared CPUs in LPARs. At boot time for shared CPU lpars, the topology for each shared CPU is set to node zero, however, this is now updated correctly using the Virtual Processor Home Node (VPHN) capabilities information provided by the pHyp. The VPHN handling in Linux is disabled, if PRRN handling is present.

Also, update initialization checks for device-tree attributes to independently recognize PRRN or VPHN usage.

powerpc/nodes: On systems like PowerPC which allow 'hot-add' of CPU or memory resources, it may occur that the new resources are to be inserted into nodes that were not used for these resources at bootup. In the kernel, any node that is used must be defined and initialized at boot.

This patch extracts the value of the 'min_common_depth' element from the "rtas" device tree property "ibm,max-associativity-domains" to use as the maximum number of nodes to setup as possibly available in the system. [The 'min_common_depth' element is calculated from memory associations found while loading all of the configured memory into the system data structures at boot.] This new setting will override the instruction,

    nodes_and(node_possible_map, node_possible_map, node_online_map);

presently seen in the function arch/powerpc/mm/numa.c:initmem_init().

If the property is not present at boot, no operation will be performed to define or enable additional nodes.

powerpc/vphn: Rearrange file contents to better distinguish the VPHN code from the NUMA code better, and move relevant functions to another file.

Michael Bringmann (3):
powerpc/numa: Update CPU topology when VPHN enabled powerpc/nodes: Ensure enough nodes avail for operations powerpc/vphn: Rearrange file contents for improved clarity
---
Changes in V11:
-- Reorganize patches to make individual changes clearer

#1 lore raw

PATCH v11 1/3 powerpc/numa: Update CPU topology when VPHN enabled

powerpc/numa: Correct the currently broken capability to set the topology for shared CPUs in LPARs. At boot time for shared CPU lpars, the topology for each shared CPU is set to node zero, however, this is now updated correctly using the Virtual Processor Home Node (VPHN) capabilities information provided by the pHyp.

Also, update initialization checks for device-tree attributes to independently recognize PRRN or VPHN usage.

---
Changes in V11:
-- Cleanup presentation of patch changes

---
 arch/powerpc/include/asm/topology.h          |   14 ++++++
 arch/powerpc/mm/numa.c                       |   61 +++++++++++++++++++++++---
 arch/powerpc/platforms/pseries/dlpar.c       |    2 +
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    2 +
 4 files changed, 73 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/topology.h +14 -0
index dc4e159..85d6428 100644
@@ -98,6 +98,20 @@ static inline int prrn_is_enabled(void)
 }
 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
 
+#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES)
+#if defined(CONFIG_PPC_SPLPAR)
+extern int timed_topology_update(int nsecs);
+#else
+#define	timed_topology_update(nsecs)	0
+#endif /* CONFIG_PPC_SPLPAR */
+#endif /* CONFIG_HOTPLUG_CPU || CONFIG_NEED_MULTIPLE_NODES */
+
+#if defined(CONFIG_PPC_SPLPAR)
+extern void shared_topology_update(void);
+#else
+#define	shared_topology_update()	0
+#endif /* CONFIG_PPC_SPLPAR */
+
 #include <asm-generic/topology.h>
 
 #ifdef CONFIG_SMP
arch/powerpc/mm/numa.c +55 -6

145 lines not on this page · raw message

arch/powerpc/platforms/pseries/dlpar.c +2 -0
index 3918769..ba9a4a0 100644
@@ -592,6 +592,8 @@ static ssize_t dlpar_show(struct class *class, struct class_attribute *attr,
 
 static int __init pseries_dlpar_init(void)
 {
+	shared_topology_update();
+
 	pseries_hp_wq = alloc_workqueue("pseries hotplug workqueue",
 					WQ_UNBOUND, 1);
 	return sysfs_create_file(kernel_kobj, &class_attr_dlpar.attr);
arch/powerpc/platforms/pseries/hotplug-cpu.c +2 -0
index 6afd1ef..5a7fb1e 100644
@@ -356,6 +356,7 @@ static int dlpar_online_cpu(struct device_node *dn)
 			BUG_ON(get_cpu_current_state(cpu)
 					!= CPU_STATE_OFFLINE);
 			cpu_maps_update_done();
+			timed_topology_update(1);
 			rc = device_online(get_cpu_device(cpu));
 			if (rc)
 				goto out;
@@ -522,6 +523,7 @@ static int dlpar_offline_cpu(struct device_node *dn)
 				set_preferred_offline_state(cpu,
 							    CPU_STATE_OFFLINE);
 				cpu_maps_update_done();
+				timed_topology_update(1);
 				rc = device_offline(get_cpu_device(cpu));
 				if (rc)
 					goto out;
Signature · 8 lines
----------
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line  363-5196
External: (512) 286-5196
Cell:       (512) 466-0650
[email protected]
#2 lore raw

PATCH v11 2/3 powerpc/nodes: Ensure enough nodes avail for operations

In reply to Michael Bringmann

powerpc/nodes: On systems like PowerPC which allow 'hot-add' of CPU or memory resources, it may occur that the new resources are to be inserted into nodes that were not used for these resources at bootup. In the kernel, any node that is used must be defined and initialized at boot.

This patch extracts the value of the lowest domain level (number of allocable resources) from the "rtas" device tree property "ibm,max-associativity-domains" to use as the maximum number of nodes to setup as possibly available in the system. This new setting will override the instruction,

    nodes_and(node_possible_map, node_possible_map, node_online_map);

presently seen in the function arch/powerpc/mm/numa.c:initmem_init().

If the property is not present at boot, no operation will be performed to define or enable additional nodes.

---
Changes in V11:
-- Cleanup/simplify code that extracts max num of nodes

---
 arch/powerpc/mm/numa.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
arch/powerpc/mm/numa.c +43 -0
index cf8cd42..2e8258a 100644
@@ -893,6 +893,47 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)
 	NODE_DATA(nid)->node_spanned_pages = spanned_pages;
 }
 
+static void __init node_associativity_setup(void)
+{
+	struct device_node *rtas;
+
+	rtas = of_find_node_by_path("/rtas");
+	if (rtas) {
+		const __be32 *prop;
+		u32 len, entries, numnodes, i;
+
+		prop = of_get_property(rtas, "ibm,max-associativity-domains", &len);
+		if (!prop || len < sizeof(unsigned int))
+			goto endit;
+
+		entries = of_read_number(prop++, 1);
+
+		if (len < (entries * sizeof(unsigned int)))
+			goto endit;
+
+		if ((0 <= min_common_depth) && (min_common_depth <= (entries-1)))
+			entries = min_common_depth;
+		else
+			entries -= 1;
+
+		numnodes = of_read_number(&prop[entries], 1);
+
+		printk(KERN_INFO "numa: Nodes = %d (mcd = %d)\n", numnodes,
+			min_common_depth);
+
+		for (i = 0; i < numnodes; i++) {
+			if (!node_possible(i)) {
+				setup_node_data(i, 0, 0);
+				node_set(i, node_possible_map);
+			}
+		}
+	}
+
+endit:
+	if (rtas)
+		of_node_put(rtas);
+}
+
 void __init initmem_init(void)
 {
 	int nid, cpu;
@@ -912,6 +953,8 @@ void __init initmem_init(void)
 	 */
 	nodes_and(node_possible_map, node_possible_map, node_online_map);
 
+	node_associativity_setup();
+
 	for_each_online_node(nid) {
 		unsigned long start_pfn, end_pfn;
 
#3 lore raw

PATCH v11 3/3 powerpc/vphn: Better integrate vphn source code

In reply to Michael Bringmann

powerpc/vphn: Reorganize source code in order to better distinguish the VPHN code from the NUMA code better, by moving relevant functions to appropriate files.

---
 arch/powerpc/include/asm/topology.h    |    6 
 arch/powerpc/mm/numa.c                 |  550 +------------------------------
 arch/powerpc/mm/vphn.c                 |  574 ++++++++++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/dlpar.c |    2 
 4 files changed, 583 insertions(+), 549 deletions(-)
arch/powerpc/include/asm/topology.h +0 -6
index 85d6428..600e1c6 100644
@@ -106,12 +106,6 @@ static inline int prrn_is_enabled(void)
 #endif /* CONFIG_PPC_SPLPAR */
 #endif /* CONFIG_HOTPLUG_CPU || CONFIG_NEED_MULTIPLE_NODES */
 
-#if defined(CONFIG_PPC_SPLPAR)
-extern void shared_topology_update(void);
-#else
-#define	shared_topology_update()	0
-#endif /* CONFIG_PPC_SPLPAR */
-
 #include <asm-generic/topology.h>
 
 #ifdef CONFIG_SMP
arch/powerpc/mm/numa.c +9 -541

595 lines not on this page · raw message

arch/powerpc/mm/vphn.c +574 -0

583 lines not on this page · raw message

arch/powerpc/platforms/pseries/dlpar.c +0 -2
index ba9a4a0..3918769 100644
@@ -592,8 +592,6 @@ static ssize_t dlpar_show(struct class *class, struct class_attribute *attr,
 
 static int __init pseries_dlpar_init(void)
 {
-	shared_topology_update();
-
 	pseries_hp_wq = alloc_workqueue("pseries hotplug workqueue",
 					WQ_UNBOUND, 1);
 	return sysfs_create_file(kernel_kobj, &class_attr_dlpar.attr);