[PATCH REPOST tip:x86/urgent] x86, NUMA: Fix empty memblkdetection in numa_cleanup_meminfo()

From: Tejun Heo
Date: Sun May 01 2011 - 13:12:15 EST


From: Yinghai Lu <yinghai@xxxxxxxxxx>

numa_cleanup_meminfo() trims each memblk between low (0) and high
(max_pfn) limits and discards empty ones. However, the emptiness
detection incorrectly used equality test. If the start of a memblk is
higher than max_pfn, it is empty but fails the equality test and
doesn't get discarded.

The condition triggers when max_pfn is lower than start of a NUMA node
and results in memory misconfiguration - leading to WARN_ON()s and
other funnies. The bug was discovered in devel branch where 32bit too
uses this code path for NUMA init. If a node is above the addressing
limit, max_pfn ends up lower than the node triggering this problem.

The failure hasn't been observed on x86-64 but is still possible with
broken hardware e820/NUMA info. As the fix is very low risk, it would
be better to apply it even for 64bit.

Fix it by using >= instead of ==.

tj: Extracted the actual fix from the original patch and rewrote patch
description.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
---
Here's the patch with updated description. Thank you.

arch/x86/mm/numa_64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: work/arch/x86/mm/numa_64.c
===================================================================
--- work.orig/arch/x86/mm/numa_64.c
+++ work/arch/x86/mm/numa_64.c
@@ -191,7 +191,7 @@ int __init numa_cleanup_meminfo(struct n
bi->end = min(bi->end, high);

/* and there's no empty block */
- if (bi->start == bi->end) {
+ if (bi->start >= bi->end) {
numa_remove_memblk_from(i--, mi);
continue;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/