Skip to contentSkip to conversation

x86-64: fix combining of regions in init_memory_mapping()

PATCH Applied Jan Beulich 3 participants 5 messages Sep 12, 2008 – Sep 15, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64: fix combining of regions in init_memory_mapping()

When nr_range gets decremented, the same slot must be considered for coalescing with its new successor again.

---
 arch/x86/mm/init_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/init_64.c +1 -1
@@ -636,7 +636,7 @@ unsigned long __init_refok init_memory_m
 		old_start = mr[i].start;
 		memmove(&mr[i], &mr[i+1],
 			 (nr_range - 1 - i) * sizeof (struct map_range));
-		mr[i].start = old_start;
+		mr[i--].start = old_start;
 		nr_range--;
 	}
 
#1 lore raw
Quoted 12 lines · Jan Beulich

When nr_range gets decremented, the same slot must be considered for coalescing with its new successor again.

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

arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 unsigned long __init_refok init_memory_m · line 642

Quoted 8 lines
arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 renamed from arch/x86/mm/init_64.c 2008-08-29 10:53:00.000000000 +0200 +1 -1
@@ -636,7 +636,7 @@ unsigned long __init_refok init_memory_m
               old_start = mr[i].start;
               memmove(&mr[i], &mr[i+1],
                        (nr_range - 1 - i) * sizeof (struct map_range));
-               mr[i].start = old_start;
+               mr[i--].start = old_start;
               nr_range--;
       }
 

this patch seems not right.
Ingo, please don't apply it.

original code:

        /* try to merge same page size and continuous */
        for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
                unsigned long old_start;
                if (mr[i].end != mr[i+1].start ||
                    mr[i].page_size_mask != mr[i+1].page_size_mask)
                        continue;
                /* move it */
                old_start = mr[i].start;
                memmove(&mr[i], &mr[i+1],
                         (nr_range - 1 - i) * sizeof (struct map_range));
                mr[i].start = old_start;
                nr_range--;
        }

so it save old_start and first, and move entries forward (so old one is overwriten), and put back old_start ...

YH

#2 lore raw
Quoted 41 lines
Quoted 1 line
Quoted 1 line

"Yinghai Lu" <[email protected]> 14.09.08 20:20 >>>

Quoted 12 lines · Jan Beulich

When nr_range gets decremented, the same slot must be considered for coalescing with its new successor again.

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

arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 unsigned long __init_refok init_memory_m · line 642

Quoted 8 lines
arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 renamed from arch/x86/mm/init_64.c 2008-08-29 10:53:00.000000000 +0200 +1 -1
@@ -636,7 +636,7 @@ unsigned long __init_refok init_memory_m
               old_start = mr[i].start;
               memmove(&mr[i], &mr[i+1],
                        (nr_range - 1 - i) * sizeof (struct map_range));
-               mr[i].start = old_start;
+               mr[i--].start = old_start;
               nr_range--;
       }
 

this patch seems not right.
Ingo, please don't apply it.

original code:

       /* try to merge same page size and continuous */
       for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
               unsigned long old_start;
               if (mr[i].end != mr[i+1].start ||
                   mr[i].page_size_mask != mr[i+1].page_size_mask)
                       continue;
               /* move it */
               old_start = mr[i].start;
               memmove(&mr[i], &mr[i+1],
                        (nr_range - 1 - i) * sizeof (struct map_range));
               mr[i].start = old_start;
               nr_range--;
       }
Quoted 2 lines

so it save old_start and first, and move entries forward (so old one is overwriten), and put back old_start ...

Old and new code are not different in any way in this respect - both overwrite the old entry at index i with the entry at index i+1 and then set the start of the i-th entry back to what it was before the overwrite, effectively combining them. The patch just makes sure that the index isn't being updated at the same time as nr_range (because if you update both you effectively skip one).

The issue is apparently pretty benign to native code, but surfaces as a boot time crash in our forward ported Xen tree (where the page table setup overall works differently than in native). Since the underlying issue was present in native (and since I assume if there is an attempt to merge subsequent regions, then it should work right), I nevertheless submitted the patch for native inclusion.

Jan

Acked-by
#3 lore raw
Quoted 51 lines · Jan Beulich
Quoted 41 lines
Quoted 1 line
Quoted 1 line

"Yinghai Lu" <[email protected]> 14.09.08 20:20 >>>

Quoted 12 lines · Jan Beulich

When nr_range gets decremented, the same slot must be considered for coalescing with its new successor again.

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

arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 unsigned long __init_refok init_memory_m · line 642

Quoted 8 lines
arch/x86/mm/init_64.c 2008-09-12 11:58:45.000000000 +0200 renamed from arch/x86/mm/init_64.c 2008-08-29 10:53:00.000000000 +0200 +1 -1
@@ -636,7 +636,7 @@ unsigned long __init_refok init_memory_m
               old_start = mr[i].start;
               memmove(&mr[i], &mr[i+1],
                        (nr_range - 1 - i) * sizeof (struct map_range));
-               mr[i].start = old_start;
+               mr[i--].start = old_start;
               nr_range--;
       }
 

this patch seems not right.
Ingo, please don't apply it.

original code:

       /* try to merge same page size and continuous */
       for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
               unsigned long old_start;
               if (mr[i].end != mr[i+1].start ||
                   mr[i].page_size_mask != mr[i+1].page_size_mask)
                       continue;
               /* move it */
               old_start = mr[i].start;
               memmove(&mr[i], &mr[i+1],
                        (nr_range - 1 - i) * sizeof (struct map_range));
               mr[i].start = old_start;
               nr_range--;
       }
Quoted 2 lines

so it save old_start and first, and move entries forward (so old one is overwriten), and put back old_start ...

Old and new code are not different in any way in this respect - both overwrite the old entry at index i with the entry at index i+1 and then set the start of the i-th entry back to what it was before the overwrite, effectively combining them. The patch just makes sure that the index isn't being updated at the same time as nr_range (because if you update both you effectively skip one).

Quoted 6 lines

The issue is apparently pretty benign to native code, but surfaces as a boot time crash in our forward ported Xen tree (where the page table setup overall works differently than in native). Since the underlying issue was present in native (and since I assume if there is an attempt to merge subsequent regions, then it should work right), I nevertheless submitted the patch for native inclusion.

yes. your patch fixed the skip...

YH

Applied
#4 lore raw
Quoted 10 lines · Yinghai Lu
Quoted 6 lines

The issue is apparently pretty benign to native code, but surfaces as a boot time crash in our forward ported Xen tree (where the page table setup overall works differently than in native). Since the underlying issue was present in native (and since I assume if there is an attempt to merge subsequent regions, then it should work right), I nevertheless submitted the patch for native inclusion.

yes. your patch fixed the skip...

applied to tip/x86/core, thanks!

Ingo