Skip to contentSkip to conversation

mem-hotplug: introduce movablenodes boot option for memory hotplug debugging

PATCH In review Xishi Qiu 2 participants 2 messages Aug 19, 2014

Subsystems (4)
lore
Share & tools
lore

Xishi Qiu

author
#0 lore raw

PATCH 1/1 mem-hotplug: introduce movablenodes boot option for memory hotplug debugging

This patch introduces a new boot option "movablenodes". This parameter depends on movable_node, it is used for debugging memory hotplug. Instead SRAT specifies which memory is hotpluggable.

e.g. movable_node movablenodes=1,2,4

It means nodes 1,2,4 will be set to movable nodes, the other nodes are unmovable nodes. Usually movable nodes are parsed from SRAT table which offered by BIOS.

---
 Documentation/kernel-parameters.txt |    5 ++++
 arch/x86/mm/srat.c                  |   36 +++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +5 -0
index 5ae8608..e072ccf 100644
@@ -1949,6 +1949,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	movable_node	[KNL,X86] Boot-time switch to enable the effects
 			of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details.
 
+	movablenodes=	[KNL,X86] This parameter depends on movable_node, it
+			is used for debugging memory hotplug. Instead SRAT
+			specifies which memory is hotpluggable.
+			e.g. movablenodes=1,2,4
+
 	MTD_Partition=	[MTD]
 			Format: <name>,<region-number>,<size>,<offset>
 
arch/x86/mm/srat.c +36 -0
index 66338a6..523e58b 100644
@@ -157,6 +157,37 @@ static inline int save_add_info(void) {return 1;}
 static inline int save_add_info(void) {return 0;}
 #endif
 
+static nodemask_t movablenodes_mask;
+
+static void __init parse_movablenodes_one(char *p)
+{
+	int node;
+
+	get_option(&p, &node);
+	node_set(node, movablenodes_mask);
+}
+
+static int __init parse_movablenodes_opt(char *str)
+{
+	nodes_clear(movablenodes_mask);
+
+#ifdef CONFIG_MOVABLE_NODE
+	while (str) {
+		char *k = strchr(str, ',');
+
+		if (k)
+			*k++ = 0;
+		parse_movablenodes_one(str);
+		str = k;
+	}
+#else
+	pr_warn("movable_node option not supported\n");
+#endif
+
+	return 0;
+}
+early_param("movablenodes", parse_movablenodes_opt);
+
 /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
 int __init
 acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
@@ -202,6 +233,11 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 		pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
 			(unsigned long long)start, (unsigned long long)end - 1);
 
+	if (node_isset(node, movablenodes_mask) &&
+		memblock_mark_hotplug(start, ma->length))
+		pr_warn("SRAT debug: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
+			(unsigned long long)start, (unsigned long long)end - 1);
+
 	return 0;
 out_err_bad_srat:
 	bad_srat();
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · Xishi Qiu

This patch introduces a new boot option "movablenodes". This parameter depends on movable_node, it is used for debugging memory hotplug. Instead SRAT specifies which memory is hotpluggable.

e.g. movable_node movablenodes=1,2,4

It means nodes 1,2,4 will be set to movable nodes, the other nodes are unmovable nodes. Usually movable nodes are parsed from SRAT table which offered by BIOS.

This may not work on some machines. So far as I know, there are machines that after a reboot, node id will change. So node 1,2,4 may be not the same nodes as before in the next boot.

Thanks.

Quoted 77 lines
---
  Documentation/kernel-parameters.txt |    5 ++++
  arch/x86/mm/srat.c                  |   36 +++++++++++++++++++++++++++++++++++
  2 files changed, 41 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +5 -0
index 5ae8608..e072ccf 100644
@@ -1949,6 +1949,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
  	movable_node	[KNL,X86] Boot-time switch to enable the effects
  			of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details.
 
+	movablenodes=	[KNL,X86] This parameter depends on movable_node, it
+			is used for debugging memory hotplug. Instead SRAT
+			specifies which memory is hotpluggable.
+			e.g. movablenodes=1,2,4
+
  	MTD_Partition=	[MTD]
  			Format: <name>,<region-number>,<size>,<offset>
 
arch/x86/mm/srat.c +36 -0
index 66338a6..523e58b 100644
@@ -157,6 +157,37 @@ static inline int save_add_info(void) {return 1;}
  static inline int save_add_info(void) {return 0;}
  #endif
 
+static nodemask_t movablenodes_mask;
+
+static void __init parse_movablenodes_one(char *p)
+{
+	int node;
+
+	get_option(&p, &node);
+	node_set(node, movablenodes_mask);
+}
+
+static int __init parse_movablenodes_opt(char *str)
+{
+	nodes_clear(movablenodes_mask);
+
+#ifdef CONFIG_MOVABLE_NODE
+	while (str) {
+		char *k = strchr(str, ',');
+
+		if (k)
+			*k++ = 0;
+		parse_movablenodes_one(str);
+		str = k;
+	}
+#else
+	pr_warn("movable_node option not supported\n");
+#endif
+
+	return 0;
+}
+early_param("movablenodes", parse_movablenodes_opt);
+
  /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
  int __init
  acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
@@ -202,6 +233,11 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
  		pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
  			(unsigned long long)start, (unsigned long long)end - 1);
 
+	if (node_isset(node, movablenodes_mask) &&
+		memblock_mark_hotplug(start, ma->length))
+		pr_warn("SRAT debug: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
+			(unsigned long long)start, (unsigned long long)end - 1);
+
  	return 0;
  out_err_bad_srat:
  	bad_srat();