Skip to contentSkip to conversation

x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo()

PATCH In review Tejun Heo 3 participants 4 messages May 1, 2011

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo()

From: Yinghai Lu <[email protected]>

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.

Fix it by using >= instead of ==.

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

---
Ingo, can you please push this to mainline? Once it hits x86/urgent, I'll regenerate the 32bit NUMA unification branch on top of it with Yinghai's other patches and send pull request for x86/mm.

Thank you.

 arch/x86/mm/numa_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/numa_64.c +1 -1
Index: 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;
 		}
#1 lore raw
Quoted 8 lines · Tejun Heo

From: Yinghai Lu <[email protected]>

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.

Quoted 4 lines

Fix it by using >= instead of ==.

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

Well, the bit still missing from the description is why this fix matters for x86/urgent: under what scenarios does this cause problems, how frequent is it, how severe are the prolems, etc. etc. Would be nice to have something about that in the changelog as well.

Thanks,

Ingo

author
#2 lore raw

PATCH 1/1 x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo()

From: Yinghai Lu <[email protected]>

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.

---
Here's the patch with updated description. Thank you.

 arch/x86/mm/numa_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/numa_64.c +1 -1
Index: 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;
 		}
#3 lore raw
Commit-ID:  2be19102b71c1a45d37fec50303791daa1a06869
Gitweb:     http://git.kernel.org/tip/2be19102b71c1a45d37fec50303791daa1a06869
Author:     Yinghai Lu <[email protected]>
AuthorDate: Sun, 1 May 2011 19:12:04 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 1 May 2011 19:15:11 +0200

x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo()

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 ==.

[ Extracted the actual fix from the original patch and rewrote patch description. ]
---
 arch/x86/mm/numa_64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/mm/numa_64.c +1 -1
index e8c00cc..85b52fc 100644
@@ -306,7 +306,7 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
 		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;
 		}