Blob Blame History Raw
From fd3e454366603c8e35b31c52195b1ea8798a8fff Mon Sep 17 00:00:00 2001
From: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Date: Wed, 15 Nov 2017 22:59:02 +0530
Subject: [PATCH] ACPI / NUMA: ia64: Parse all entries of SRAT memory affinity
 table
Git-commit: fd3e454366603c8e35b31c52195b1ea8798a8fff
Patch-mainline: v4.16-rc1
References: bnc#1088796, fate#325665

mhocko@suse.com:
this patch is not sufficient for x86 to work properly because there will still
be a discrepancy between numa_meminfo and memblocks. The primary reason to
merge to commit is to allow more memory ranges for arm64 and this one works
correctly because it doesn't depend on numa_meminfo and NR_NODE_MEMBLKS limit.

In current implementation, SRAT Memory Affinity Structure table
parsing is restricted to number of maximum memblocks allowed
(NR_NODE_MEMBLKS). However NR_NODE_MEMBLKS is defined individually
as per architecture requirements. Hence removing the restriction of
SRAT Memory Affinity Structure parsing in ACPI driver code and
let architecture code check for allowed memblocks count.

This check is already there in the x86 code, so do the same on ia64.

Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>

---
 arch/ia64/kernel/acpi.c | 5 +++++
 drivers/acpi/numa.c     | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 1d29b2f8726b..1dacbf5e9e09 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -504,6 +504,11 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 	if (!(ma->flags & ACPI_SRAT_MEM_ENABLED))
 		return -1;
 
+	if (num_node_memblks >= NR_NODE_MEMBLKS) {
+		pr_err("NUMA: too many memblk ranges\n");
+		return -EINVAL;
+	}
+
 	/* record this node in proximity bitmap */
 	pxm_bit_set(pxm);
 
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 917f1cc0fda4..8ccaae3550d2 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -460,8 +460,7 @@ int __init acpi_numa_init(void)
 					srat_proc, ARRAY_SIZE(srat_proc), 0);
 
 		cnt = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
-					    acpi_parse_memory_affinity,
-					    NR_NODE_MEMBLKS);
+					    acpi_parse_memory_affinity, 0);
 	}
 
 	/* SLIT: System Locality Information Table */
-- 
1.8.5.6