Skip to contentSkip to conversation

x86/numa: fix c/s 20120 (Fix SRAT check for discontig memory)

PATCH In review Jan Beulich 2 participants 3 messages Aug 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/numa: fix c/s 20120 (Fix SRAT check for discontig memory)

That change converted the (wrong) assumption of contiguous nodes' memory to a similarly wrong one of assuming discontiguous memory (i.e. each node having separate E820 table entries). The code ought to be able to deal with both, though, and I hope this change makes it so.

xen/arch/x86/srat.c +16 -8
@@ -249,15 +249,23 @@ static int nodes_cover_memory(void)
 		start = e820.map[i].addr;
 		end = e820.map[i].addr + e820.map[i].size - 1;
 
-		found = 0;
-		for_each_node_mask(j, nodes_parsed) {
-			if (start >= nodes[j].start && end <= nodes[j].end) {
-				found = 1;
-				break;
-			}
-		}
+		do {
+			found = 0;
+			for_each_node_mask(j, nodes_parsed)
+				if (start < nodes[j].end
+				    && end > nodes[j].start) {
+					if (start >= nodes[j].start) {
+						start = nodes[j].end;
+						found = 1;
+					}
+					if (end <= nodes[j].end) {
+						end = nodes[j].start;
+						found = 1;
+					}
+				}
+		} while (found && start < end);
 
-		if (!found) {
+		if (start < end) {
 			printk(KERN_ERR "SRAT: No PXM for e820 range: "
 				"%016Lx - %016Lx\n", start, end);
 			return 0;
#1 lore raw
Quoted 4 lines · Jan Beulich

That change converted the (wrong) assumption of contiguous nodes' memory to a similarly wrong one of assuming discontiguous memory (i.e. each node having separate E820 table entries). The code ought to be able to deal with both, though, and I hope this change makes it so.

Ah, of course. Thanks Jan, I'll test it out on my end.

Alex

Acked-by on v1 1/1
#2 lore raw
In reply to Jan Beulich
Quoted 6 lines · Jan Beulich

That change converted the (wrong) assumption of contiguous nodes' memory to a similarly wrong one of assuming discontiguous memory (i.e. each node having separate E820 table entries). The code ought to be able to deal with both, though, and I hope this change makes it so.

Works for me.

Quoted 37 lines
xen/arch/x86/srat.c +16 -8
@@ -249,15 +249,23 @@ static int nodes_cover_memory(void)
 		start = e820.map[i].addr;
 		end = e820.map[i].addr + e820.map[i].size - 1;
 
-		found = 0;
-		for_each_node_mask(j, nodes_parsed) {
-			if (start >= nodes[j].start && end <= nodes[j].end) {
-				found = 1;
-				break;
-			}
-		}
+		do {
+			found = 0;
+			for_each_node_mask(j, nodes_parsed)
+				if (start < nodes[j].end
+				    && end > nodes[j].start) {
+					if (start >= nodes[j].start) {
+						start = nodes[j].end;
+						found = 1;
+					}
+					if (end <= nodes[j].end) {
+						end = nodes[j].start;
+						found = 1;
+					}
+				}
+		} while (found && start < end);
 
-		if (!found) {
+		if (start < end) {
 			printk(KERN_ERR "SRAT: No PXM for e820 range: "
 				"%016Lx - %016Lx\n", start, end);
 			return 0;