Skip to contentSkip to conversation

mmap topdown fix for large stack limit, large allocation

PATCH New Chris Wright 1 participant 1 message May 23, 2005

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

PATCH 1/1 mmap topdown fix for large stack limit, large allocation

The topdown changes in 2.6.12-rc1 can cause large allocations with large stack limit to fail, despite there being space available. The mmap_base-len is only valid when len >= mmap_base. However, nothing in topdown allocator checks this. It's only (now) caught at higher level, which will cause allocation to simply fail. The following change restores the fallback to bottom-up path, which will allow large allocations with large stack limit to potentially still succeed.

---

 mm/mmap.c |    4 ++++
 1 files changed, 4 insertions(+)

mm/mmap.c: de54acd9942f9929004921042721df5cdfe2b6c7

mm/mmap.c +4 -0
@@ -1251,6 +1251,9 @@ arch_get_unmapped_area_topdown(struct fi
 			return (mm->free_area_cache = addr-len);
 	}
 
+	if (mm->mmap_base < len)
+		goto bottomup;
+
 	addr = mm->mmap_base-len;
 
 	do {
@@ -1268,6 +1271,7 @@ arch_get_unmapped_area_topdown(struct fi
 		addr = vma->vm_start-len;
 	} while (len < vma->vm_start);
 
+bottomup:
 	/*
 	 * A failed mmap() very likely causes application failure,
 	 * so fall back to the bottom-up function here. This scenario