Skip to contentSkip to conversation

powerpc/numa: add ability to disable and debug topology updates

PATCH Superseded Nishanth Aravamudan 2 participants 3 messages Oct 9, 2014 – Oct 10, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 powerpc/numa: add ability to disable and debug topology updates

We have hit a few customer issues with the topology update code (VPHN and PRRN). It would be nice to be able to debug the notifications coming from the hypervisor in both cases to the LPAR, as well as to disable responding to the notifications at boot-time, to narrow down the source of the problems. Add a basic level of such functionality, similar to the numa= command-line parameter. We already have a toggle in /proc/powerpc/topology_updates that allows run-time enabling/disabling, so the updates can be started at run-time if desired. But the bugs we've run into have occured during boot or very shortly after coming to login, and have resulted in a broken NUMA topology.

---
v1 -> v2:
Updated commit message to answer some of mpe's reviews. Switched to pr_fmt based debugging, which removes the need for the
debug flag.
Be a little less verbose in the debugging, as it was duplicating
information.

Documentation/kernel-parameters.txt +6 -0
index d9a452e8fb9b..35a46b8240ad 100644
@@ -3388,6 +3388,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			e.g. base its process migration decisions on it.
 			Default is on.
 
+	topology_updates= [KNL, PPC, NUMA]
+			Format: {off}
+			Specify if the kernel should ignore (off)
+			topology updates sent by the hypervisor to this
+			LPAR.
+
 	tp720=		[HW,PS2]
 
 	tpm_suspend_pcr=[HW,TPM]
arch/powerpc/mm/numa.c +32 -1
index e28c21ba862d..ad240a41d3e4 100644
@@ -45,6 +45,7 @@ static char *cmdline __initdata;
 
 static int numa_debug;
 #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
+#define pr_fmt(fmt) "numa: " fmt
 
 int numa_cpu_lookup_table[NR_CPUS];
 cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
@@ -1160,6 +1161,22 @@ static int __init early_numa(char *p)
 }
 early_param("numa", early_numa);
 
+static int topology_updates_enabled = 1;
+
+static int __init early_topology_updates(char *p)
+{
+	if (!p)
+		return 0;
+
+	if (strstr(p, "off")) {
+		pr_info("Disabling topology updates\n");
+		topology_updates_enabled = 0;
+	}
+
+	return 0;
+}
+early_param("topology_updates", early_topology_updates);
+
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
  * Find the node associated with a hot added memory section for
@@ -1546,6 +1563,9 @@ int arch_update_cpu_topology(void)
 	struct device *dev;
 	int weight, new_nid, i = 0;
 
+	if (!prrn_enabled && !vphn_enabled)
+		return 0;
+
 	weight = cpumask_weight(&cpu_associativity_changes_mask);
 	if (!weight)
 		return 0;
@@ -1599,6 +1619,15 @@ int arch_update_cpu_topology(void)
 		cpu = cpu_last_thread_sibling(cpu);
 	}
 
+	pr_debug("Topology update for the following CPUs:\n");
+	if (cpumask_weight(&updated_cpus)) {
+		for (ud = &updates[0]; ud; ud = ud->next) {
+			pr_debug("cpu %d moving from node %d "
+					  "to %d\n", ud->cpu,
+					  ud->old_nid, ud->new_nid);
+		}
+	}
+
 	/*
 	 * In cases where we have nothing to update (because the updates list
 	 * is too short or because the new topology is same as the old one),
@@ -1807,7 +1836,9 @@ static const struct file_operations topology_ops = {
 
 static int topology_update_init(void)
 {
-	start_topology_update();
+	/* Do not poll for changes if disabled at boot */
+	if (topology_updates_enabled)
+		start_topology_update();
 	if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
 		return -ENOMEM;
 
#1 lore raw
Quoted 10 lines · Nishanth Aravamudan

We have hit a few customer issues with the topology update code (VPHN and PRRN). It would be nice to be able to debug the notifications coming from the hypervisor in both cases to the LPAR, as well as to disable responding to the notifications at boot-time, to narrow down the source of the problems. Add a basic level of such functionality, similar to the numa= command-line parameter. We already have a toggle in /proc/powerpc/topology_updates that allows run-time enabling/disabling, so the updates can be started at run-time if desired. But the bugs we've run into have occured during boot or very shortly after coming to login, and have resulted in a broken NUMA topology.

Thanks Nish, a couple of minor nits.

arch/powerpc/mm/numa.c static char *cmdline __initdata; · line 48

Quoted 9 lines
arch/powerpc/mm/numa.c +1 -0
index e28c21ba862d..ad240a41d3e4 100644
@@ -45,6 +45,7 @@ static char *cmdline __initdata;
 
 static int numa_debug;
 #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
+#define pr_fmt(fmt) "numa: " fmt

This needs to come before printk.h to take effect, typically it goes before all headers.

arch/powerpc/mm/numa.c static int __init early_numa(char *p) · line 1164

Quoted 5 lines
arch/powerpc/mm/numa.c +1 -0
@@ -1160,6 +1161,22 @@ static int __init early_numa(char *p)
 }
 early_param("numa", early_numa);
 
+static int topology_updates_enabled = 1;

bool ?

arch/powerpc/mm/numa.c static int __init early_numa(char *p) · line 1171

Quoted 6 lines
arch/powerpc/mm/numa.c +6 -0
+static int __init early_topology_updates(char *p)
+{
+	if (!p)
+		return 0;
+
+	if (strstr(p, "off")) {

You're better off using strcmp. Using strstr() is nice if you need to support multiple values, but it's sloppy otherwise. This will match "offset", "smirnoff" etc.

arch/powerpc/mm/numa.c static const struct file_operations topology_ops = { · line 1841

Quoted 8 lines
arch/powerpc/mm/numa.c +3 -1
@@ -1807,7 +1836,9 @@ static const struct file_operations topology_ops = {
 
 static int topology_update_init(void)
 {
-	start_topology_update();
+	/* Do not poll for changes if disabled at boot */
+	if (topology_updates_enabled)
+		start_topology_update();

Newline please!

arch/powerpc/mm/numa.c static const struct file_operations topology_ops = { · line 1843

Quoted 2 lines
arch/powerpc/mm/numa.c +0 -0
 	if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
 		return -ENOMEM;

cheers

#2 lore raw

PATCH v3 1/1 powerpc/numa: add ability to disable and debug topology updates

Quoted 12 lines · Michael Ellerman
Quoted 10 lines · Nishanth Aravamudan

We have hit a few customer issues with the topology update code (VPHN and PRRN). It would be nice to be able to debug the notifications coming from the hypervisor in both cases to the LPAR, as well as to disable responding to the notifications at boot-time, to narrow down the source of the problems. Add a basic level of such functionality, similar to the numa= command-line parameter. We already have a toggle in /proc/powerpc/topology_updates that allows run-time enabling/disabling, so the updates can be started at run-time if desired. But the bugs we've run into have occured during boot or very shortly after coming to login, and have resulted in a broken NUMA topology.

Quoted 1 line

Thanks Nish, a couple of minor nits.

Thanks for the review, fixed.

<snip>

Quoted 10 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int __init early_topology_updates(char *p)
+{
+	if (!p)
+		return 0;
+
+	if (strstr(p, "off")) {

You're better off using strcmp. Using strstr() is nice if you need to support multiple values, but it's sloppy otherwise. This will match "offset", "smirnoff" etc.

I feel like this is the Linux-equivalent of "You just got iced!"

<snip>

We have hit a few customer issues with the topology update code (VPHN and PRRN). It would be nice to be able to debug the notifications coming from the hypervisor in both cases to the LPAR, as well as to disable responding to the notifications at boot-time, to narrow down the source of the problems. Add a basic level of such functionality, similar to the numa= command-line parameter. We already have a toggle in /proc/powerpc/topology_updates that allows run-time enabling/disabling, so the updates can be started at run-time if desired. But the bugs we've run into have occured during boot or very shortly after coming to login, and have resulted in a broken NUMA topology.

---
v1 -> v2:
Updated commit message to answer some of mpe's reviews. Switched to pr_fmt based debugging, which removes the need for the
debug flag.
Be a little less verbose in the debugging, as it was duplicating
information.
v2 -> v3:
Move pr_fmt define to the right spot.
Make topology_updates_enabled bool.
Use strcmp instead of strstr for topology_updates= parsing. Add a missing newline.

Documentation/kernel-parameters.txt +6 -0
index d9a452e8fb9b..35a46b8240ad 100644
@@ -3388,6 +3388,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			e.g. base its process migration decisions on it.
 			Default is on.
 
+	topology_updates= [KNL, PPC, NUMA]
+			Format: {off}
+			Specify if the kernel should ignore (off)
+			topology updates sent by the hypervisor to this
+			LPAR.
+
 	tp720=		[HW,PS2]
 
 	tpm_suspend_pcr=[HW,TPM]
arch/powerpc/mm/numa.c +34 -1
index e28c21ba862d..6fde1d4351e6 100644
@@ -8,6 +8,8 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
+#define pr_fmt(fmt) "numa: " fmt
+
 #include <linux/threads.h>
 #include <linux/bootmem.h>
 #include <linux/init.h>
@@ -1160,6 +1162,22 @@ static int __init early_numa(char *p)
 }
 early_param("numa", early_numa);
 
+static bool topology_updates_enabled = true;
+
+static int __init early_topology_updates(char *p)
+{
+	if (!p)
+		return 0;
+
+	if (!strcmp(p, "off")) {
+		pr_info("Disabling topology updates\n");
+		topology_updates_enabled = false;
+	}
+
+	return 0;
+}
+early_param("topology_updates", early_topology_updates);
+
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
  * Find the node associated with a hot added memory section for
@@ -1546,6 +1564,9 @@ int arch_update_cpu_topology(void)
 	struct device *dev;
 	int weight, new_nid, i = 0;
 
+	if (!prrn_enabled && !vphn_enabled)
+		return 0;
+
 	weight = cpumask_weight(&cpu_associativity_changes_mask);
 	if (!weight)
 		return 0;
@@ -1599,6 +1620,15 @@ int arch_update_cpu_topology(void)
 		cpu = cpu_last_thread_sibling(cpu);
 	}
 
+	pr_debug("Topology update for the following CPUs:\n");
+	if (cpumask_weight(&updated_cpus)) {
+		for (ud = &updates[0]; ud; ud = ud->next) {
+			pr_debug("cpu %d moving from node %d "
+					  "to %d\n", ud->cpu,
+					  ud->old_nid, ud->new_nid);
+		}
+	}
+
 	/*
 	 * In cases where we have nothing to update (because the updates list
 	 * is too short or because the new topology is same as the old one),
@@ -1807,7 +1837,10 @@ static const struct file_operations topology_ops = {
 
 static int topology_update_init(void)
 {
-	start_topology_update();
+	/* Do not poll for changes if disabled at boot */
+	if (topology_updates_enabled)
+		start_topology_update();
+
 	if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
 		return -ENOMEM;