Skip to contentSkip to conversation

acpi: Fix and cleanup in acpi.

PATCH Superseded Tang Chen 3 participants 17 messages Aug 16, 2013 – Aug 20, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tang Chen

author
#0 lore raw

cover acpi: Fix and cleanup in acpi.

This patch-set fix the following problems:

1. Kill useless function save_add_info() which will block us from using numa when MEMORY_HOTPLUG is not configured.
2. acpi_table_parse() didn't check if @id is NULL.
3. Fix incorrect comment in acpi_table_parse(), and return -ENOENT if a table is not found.

And also did some cleanup.

Tang Chen (6):
acpi, numa, mem_hotplug: Kill save_add_info().
acpi, numa, mem_hotplug: Print Hot-Pluggable Field in SRAT. acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c acpi cleanup: Use pr_err() instead of printk() in arch/x86/mm/srat.c
acpi: Check if @id is NULL in acpi_table_parse()
acpi: Return -ENOENT in acpi_table_parse() and fix wrong comment.

 arch/x86/mm/srat.c    |   38 +++++++++++++++++---------------------
 drivers/acpi/tables.c |    9 +++++----
 2 files changed, 22 insertions(+), 25 deletions(-)
author
#1 lore raw

PATCH 1/6 acpi, numa, mem_hotplug: Kill save_add_info().

save_add_info() is defined as:

	#ifdef CONFIG_MEMORY_HOTPLUG
	static inline int save_add_info(void) {return 1;}
	#else
	static inline int save_add_info(void) {return 0;}
	#endif

which means it is true when memory hotplug is configured.

In acpi_numa_memory_affinity_init(), it checks the memory hotplug flag in SRAT memory affinity and save_add_info() like this:

	if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
		goto out_err;
	......
	node = setup_node(pxm);
	numa_add_memblk(node, start, end);
	......

which means if the memory range is hotpluggable, but memory hotplug is not configured, it won't add these memory to numa_meminfo.

After this, numa_meminfo_cover_memory() will fail, which will finally cause numa_init() to fail.

numa_init()
|->numa_register_memblks()

     |->numa_meminfo_cover_memory()

When numa_init() fails, it will fallback to numa_init(dummy_numa_init), and all numa architecture will not be setup.

This is nonsense. Even if memory hotplug is not configured, we can also use numa architecture.

Actually, save_add_info() is added by commit 71efa8fdc55e70ec6687c897a30759f0a2c2ad7e in 2006. And now it is useless.

So this patch kill save_add_info() and the nonsense checking.

---
 arch/x86/mm/srat.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
arch/x86/mm/srat.c +0 -8
index cdd0da9..1613c02 100644
@@ -135,12 +135,6 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 	       pxm, apic_id, node);
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG
-static inline int save_add_info(void) {return 1;}
-#else
-static inline int save_add_info(void) {return 0;}
-#endif
-
 /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
 int __init
 acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
@@ -154,8 +148,6 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 		goto out_err_bad_srat;
 	if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
 		goto out_err;
-	if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
-		goto out_err;
 
 	start = ma->base_address;
 	end = start + ma->length;
Signature · 1 line
1.7.1
author
#11 lore raw

PATCH 4/6 acpi cleanup: Use pr_err() instead of printk() in arch/x86/mm/srat.c

In reply to Tang Chen

Use pr_err() instead of printk() in arch/x86/mm/srat.c

---
 arch/x86/mm/srat.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/srat.c +4 -4
index 6286e89..32b9597 100644
@@ -33,7 +33,7 @@ static __init int setup_node(int pxm)
 
 static __init void bad_srat(void)
 {
-	printk(KERN_ERR "SRAT: SRAT not used.\n");
+	pr_err("SRAT: SRAT not used.\n");
 	acpi_numa = -1;
 }
 
@@ -77,7 +77,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	}
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("SRAT: Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
@@ -113,7 +113,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		pxm |= *((unsigned int*)pa->proximity_domain_hi) << 8;
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("SRAT: Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
@@ -160,7 +160,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains.\n");
+		pr_err("SRAT: Too many proximity domains.\n");
 		goto out_err_bad_srat;
 	}
 
Signature · 1 line
1.7.1
author
#12 lore raw

PATCH 5/6 acpi: Check if @id is NULL in acpi_table_parse()

In reply to Tang Chen

strncmp() does not check if the params are NULL. In acpi_table_parse(), if @id is NULL, the kernel will panic.

---
 drivers/acpi/tables.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/tables.c +1 -1
index d67a1fe..5a5263b 100644
@@ -293,7 +293,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!handler)
+	if (!id || !handler)
 		return -EINVAL;
 
 	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
Signature · 1 line
1.7.1
author
#14 lore raw

PATCH 6/6 acpi: Return -ENOENT in acpi_table_parse() and fix wrong comment.

In reply to Tang Chen

The comment about return value of acpi_table_parse() is incorrect. This patch fix it.

Furthermore, if the table is not found, return 1 means nothing, and make it difficult to write the comment. So return -ENOENT when the table is not found, and correct the comment.

---
 drivers/acpi/tables.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/acpi/tables.c +4 -3
index 5a5263b..e6de24f 100644
@@ -278,12 +278,13 @@ acpi_table_parse_madt(enum acpi_madt_type id,
 
 /**
  * acpi_table_parse - find table with @id, run @handler on it
- *
  * @id: table id to find
  * @handler: handler to run
  *
  * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
- * run @handler on it.  Return 0 if table found, return on if not.
+ * run @handler on it.
+ *
+ * Return 0 on success, -errno on failure.
  */
 int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
 {
@@ -306,7 +307,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
 		early_acpi_os_unmap_memory(table, tbl_size);
 		return 0;
 	} else
-		return 1;
+		return -ENOENT;
 }
 
 /* 
Signature · 1 line
1.7.1
author
#5 lore raw

PATCH 3/6 acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c

In reply to Tang Chen

Use pr_info() instead of printk() in arch/x86/mm/srat.c.

---
 arch/x86/mm/srat.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/mm/srat.c +6 -6
index 71411aa..6286e89 100644
@@ -71,8 +71,8 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	pxm = pa->proximity_domain;
 	apic_id = pa->apic_id;
 	if (!apic->apic_id_valid(apic_id)) {
-		printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
-			 pxm, apic_id);
+		pr_info("SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
+			pxm, apic_id);
 		return;
 	}
 	node = setup_node(pxm);
@@ -83,13 +83,13 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	}
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
 		return;
 	}
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u\n",
+	pr_info("SRAT: PXM %u -> APIC 0x%04x -> Node %u\n",
 	       pxm, apic_id, node);
 }
 
@@ -124,14 +124,14 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		apic_id = pa->apic_id;
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
 		return;
 	}
 
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u\n",
+	pr_info("SRAT: PXM %u -> APIC 0x%02x -> Node %u\n",
 	       pxm, apic_id, node);
 }
 
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 2/6 acpi, numa, mem_hotplug: Print Hot-Pluggable Field in SRAT.

In reply to Tang Chen

The Hot-Pluggable field in SRAT suggests if the memory could be hotplugged while the system is running. Print it as well when parsing SRAT will help users to know which memory is hotpluggable.

---
 arch/x86/mm/srat.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
arch/x86/mm/srat.c +7 -3
index 1613c02..71411aa 100644
@@ -141,6 +141,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 {
 	u64 start, end;
 	int node, pxm;
+	u32 hotpluggable;
 
 	if (srat_disabled())
 		goto out_err;
@@ -152,6 +153,8 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 	start = ma->base_address;
 	end = start + ma->length;
 	pxm = ma->proximity_domain;
+	hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE;
+
 	if (acpi_srat_revision <= 1)
 		pxm &= 0xff;
 
@@ -166,9 +169,10 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node_set(node, numa_nodes_parsed);
 
-	printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
-	       node, pxm,
-	       (unsigned long long) start, (unsigned long long) end - 1);
+	pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s\n",
+		node, pxm,
+		(unsigned long long) start, (unsigned long long) end - 1,
+		hotpluggable ? " hotplug" : "");
 
 	return 0;
 out_err_bad_srat:
Signature · 1 line
1.7.1
#6 lore raw

Re: [PATCH 3/6] acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c

In reply to Tang Chen
Quoted 1 line · Tang Chen

arch/x86/mm/srat.c

I think it'd be better to use pr_fmt
with the conversions to pr_info and pr_err.

pr_fmt can prefix the appropriate srat: and
so the format strings do not need it.

Something like:

---
 arch/x86/mm/srat.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
arch/x86/mm/srat.c +16 -15
index cdd0da9..350b4c5 100644
@@ -9,6 +9,8 @@
  * are in one chunk. Holes between them will be included in the node.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/acpi.h>
 #include <linux/mmzone.h>
@@ -33,7 +35,7 @@ static __init int setup_node(int pxm)
 
 static __init void bad_srat(void)
 {
-	printk(KERN_ERR "SRAT: SRAT not used.\n");
+	pr_err("SRAT not used\n");
 	acpi_numa = -1;
 }
 
@@ -71,26 +73,25 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	pxm = pa->proximity_domain;
 	apic_id = pa->apic_id;
 	if (!apic->apic_id_valid(apic_id)) {
-		printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
-			 pxm, apic_id);
+		pr_info("PXM %u -> X2APIC 0x%04x ignored\n", pxm, apic_id);
 		return;
 	}
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n",
+			pxm, apic_id, node);
 		return;
 	}
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u\n",
-	       pxm, apic_id, node);
+	pr_info("PXM %u -> APIC 0x%04x -> Node %u\n", pxm, apic_id, node);
 }
 
 /* Callback for Proximity Domain -> LAPIC mapping */
@@ -113,7 +114,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		pxm |= *((unsigned int*)pa->proximity_domain_hi) << 8;
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
@@ -124,15 +125,15 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		apic_id = pa->apic_id;
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n",
+			pxm, apic_id, node);
 		return;
 	}
 
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u\n",
-	       pxm, apic_id, node);
+	pr_info("PXM %u -> APIC 0x%02x -> Node %u\n", pxm, apic_id, node);
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
@@ -165,7 +166,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains.\n");
+		pr_err("Too many proximity domains\n");
 		goto out_err_bad_srat;
 	}
 
@@ -174,9 +175,9 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node_set(node, numa_nodes_parsed);
 
-	printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
-	       node, pxm,
-	       (unsigned long long) start, (unsigned long long) end - 1);
+	pr_info("Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
+		node, pxm,
+		(unsigned long long) start, (unsigned long long) end - 1);
 
 	return 0;
 out_err_bad_srat:
author
#7 lore raw

Re: [PATCH 3/6] acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c

Hi Joe,

Quoted 19 lines · Joe Perches
Quoted 1 line · Tang Chen

arch/x86/mm/srat.c

I think it'd be better to use pr_fmt
with the conversions to pr_info and pr_err.

pr_fmt can prefix the appropriate srat: and
so the format strings do not need it.

Something like:

---
  arch/x86/mm/srat.c | 31 ++++++++++++++++---------------
  1 file changed, 16 insertions(+), 15 deletions(-)
arch/x86/mm/srat.c +0 -0
index cdd0da9..350b4c5 100644

arch/x86/mm/srat.c line 12

Quoted 4 lines
arch/x86/mm/srat.c +1 -0
@@ -9,6 +9,8 @@
   * are in one chunk. Holes between them will be included in the node.
   */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

OK, will update the patches.

Thanks. :)

author
#8 lore raw

PATCH 3/6 acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c

In reply to Joe Perches

Use pr_info() instead of printk() in arch/x86/mm/srat.c.

As Joe suggested, define pr_fmt(fmt) as KBUILD_MODNAME ": " fmt to prefix message with "srat: ".

---
 arch/x86/mm/srat.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
arch/x86/mm/srat.c +9 -8
index 71411aa..591f4bb 100644
@@ -24,6 +24,8 @@
 #include <asm/apic.h>
 #include <asm/uv/uv.h>
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 int acpi_numa __initdata;
 
 static __init int setup_node(int pxm)
@@ -71,8 +73,8 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	pxm = pa->proximity_domain;
 	apic_id = pa->apic_id;
 	if (!apic->apic_id_valid(apic_id)) {
-		printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
-			 pxm, apic_id);
+		pr_info("PXM %u -> X2APIC 0x%04x ignored\n",
+			pxm, apic_id);
 		return;
 	}
 	node = setup_node(pxm);
@@ -83,13 +85,13 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	}
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
 		return;
 	}
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u\n",
+	pr_info("PXM %u -> APIC 0x%04x -> Node %u\n",
 	       pxm, apic_id, node);
 }
 
@@ -124,14 +126,14 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		apic_id = pa->apic_id;
 
 	if (apic_id >= MAX_LOCAL_APIC) {
-		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
+		pr_info("PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
 		return;
 	}
 
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
 	acpi_numa = 1;
-	printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u\n",
+	pr_info("PXM %u -> APIC 0x%02x -> Node %u\n",
 	       pxm, apic_id, node);
 }
 
@@ -169,8 +171,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node_set(node, numa_nodes_parsed);
 
-	pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s\n",
-		node, pxm,
+	pr_info("Node %u PXM %u [mem %#010Lx-%#010Lx]%s\n", node, pxm,
 		(unsigned long long) start, (unsigned long long) end - 1,
 		hotpluggable ? " hotplug" : "");
 
Signature · 1 line
1.7.1
author
#9 lore raw

PATCH 4/6 acpi cleanup: Use pr_err() instead of printk() in arch/x86/mm/srat.c

In reply to Joe Perches

Use pr_err() instead of printk() in arch/x86/mm/srat.c

---
 arch/x86/mm/srat.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/srat.c +4 -4
index 591f4bb..d1e3b95 100644
@@ -35,7 +35,7 @@ static __init int setup_node(int pxm)
 
 static __init void bad_srat(void)
 {
-	printk(KERN_ERR "SRAT: SRAT not used.\n");
+	pr_err("SRAT not used.\n");
 	acpi_numa = -1;
 }
 
@@ -79,7 +79,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
 	}
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
@@ -115,7 +115,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 		pxm |= *((unsigned int*)pa->proximity_domain_hi) << 8;
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
+		pr_err("Too many proximity domains %x\n", pxm);
 		bad_srat();
 		return;
 	}
@@ -162,7 +162,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
 
 	node = setup_node(pxm);
 	if (node < 0) {
-		printk(KERN_ERR "SRAT: Too many proximity domains.\n");
+		pr_err("Too many proximity domains.\n");
 		goto out_err_bad_srat;
 	}
 
Signature · 1 line
1.7.1
Acked-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] acpi, numa, mem_hotplug: Kill save_add_info().

In reply to Tang Chen
Quoted 36 lines · Tang Chen

save_add_info() is defined as:

	#ifdef CONFIG_MEMORY_HOTPLUG
	static inline int save_add_info(void) {return 1;}
	#else
	static inline int save_add_info(void) {return 0;}
	#endif

which means it is true when memory hotplug is configured.

In acpi_numa_memory_affinity_init(), it checks the memory hotplug flag in SRAT memory affinity and save_add_info() like this:

	if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
		goto out_err;
	......
	node = setup_node(pxm);
	numa_add_memblk(node, start, end);
	......

which means if the memory range is hotpluggable, but memory hotplug is not configured, it won't add these memory to numa_meminfo.

After this, numa_meminfo_cover_memory() will fail, which will finally cause numa_init() to fail.

numa_init()
|->numa_register_memblks()

     |->numa_meminfo_cover_memory()

When numa_init() fails, it will fallback to numa_init(dummy_numa_init), and all numa architecture will not be setup.

This is nonsense. Even if memory hotplug is not configured, we can also use numa architecture.

Quoted 6 lines

Actually, save_add_info() is added by commit 71efa8fdc55e70ec6687c897a30759f0a2c2ad7e in 2006. And now it is useless.

So this patch kill save_add_info() and the nonsense checking.

Good catch!

Thanks,
-Toshi

Acked-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] acpi, numa, mem_hotplug: Print Hot-Pluggable Field in SRAT.

In reply to Tang Chen
Quoted 8 lines · Tang Chen

The Hot-Pluggable field in SRAT suggests if the memory could be hotplugged while the system is running. Print it as well when parsing SRAT will help users to know which memory is hotpluggable.

Thanks,
-Toshi

Acked-by on v1 3/6
#10 lore raw

Re: [PATCH 3/6] acpi cleanup: Use pr_info() instead of printk() in arch/x86/mm/srat.c

In reply to Tang Chen
Quoted 3 lines · Tang Chen

Use pr_info() instead of printk() in arch/x86/mm/srat.c.

Please fold patch 4/6 into this patch 3/6 since they both are printk() cleanup on the same file. I do not see why they need to be separated. With that change,

Thanks,
-Toshi

Acked-by on v1 5/6
#13 lore raw

Re: [PATCH 5/6] acpi: Check if @id is NULL in acpi_table_parse()

In reply to Tang Chen
Quoted 4 lines · Tang Chen

strncmp() does not check if the params are NULL. In acpi_table_parse(), if @id is NULL, the kernel will panic.

-Toshi

Quoted 17 lines
---
 drivers/acpi/tables.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/tables.c +1 -1
index d67a1fe..5a5263b 100644
@@ -293,7 +293,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!handler)
+	if (!id || !handler)
 		return -EINVAL;
 
 	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
#15 lore raw

Re: [PATCH 6/6] acpi: Return -ENOENT in acpi_table_parse() and fix wrong comment.

In reply to Tang Chen
Quoted 6 lines · Tang Chen

The comment about return value of acpi_table_parse() is incorrect. This patch fix it.

Furthermore, if the table is not found, return 1 means nothing, and make it difficult to write the comment. So return -ENOENT when the table is not found, and correct the comment.

I am OK with the change, but the above description is not very clear. You should state that all callers only check if the function succeeded or not. So, you are simplifying the semantics by returning -errno for all failure cases.

Since you are making this change, I'd suggest you also update the stub function in linux/acpi.h to return -ENODEV as well.

Thanks,
-Toshi

author
#16 lore raw

Re: [PATCH 6/6] acpi: Return -ENOENT in acpi_table_parse() and fix wrong comment.

Quoted 8 lines · Toshi Kani
Quoted 6 lines · Tang Chen

The comment about return value of acpi_table_parse() is incorrect. This patch fix it.

Furthermore, if the table is not found, return 1 means nothing, and make it difficult to write the comment. So return -ENOENT when the table is not found, and correct the comment.

Quoted 7 lines

I am OK with the change, but the above description is not very clear. You should state that all callers only check if the function succeeded or not. So, you are simplifying the semantics by returning -errno for all failure cases.

Since you are making this change, I'd suggest you also update the stub function in linux/acpi.h to return -ENODEV as well.

OK, followed. And will merge patch 3 and 4 and resend them later.

Thanks for reviewing.