[RFC v2 PATCH 16/17] mm: mmap: Align unhinted maps to highest anon folio order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When allocating large anonymous folios, we want to maximize our chances
of being able to use the highest order we support. Since one of the
constraints is that a folio has to be mapped naturally aligned, let's
have mmap default to that alignment when user space does not provide a
hint.

With this in place, an extra 2% of all allocated anonymous memory
belongs to a folio of the highest order, when compiling the kernel.

Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>
---
 mm/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index ff68a67a2a7c..e7652001a32e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1627,7 +1627,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr,
 	info.length = len;
 	info.low_limit = mm->mmap_base;
 	info.high_limit = mmap_end;
-	info.align_mask = 0;
+	info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1;
 	info.align_offset = 0;
 	return vm_unmapped_area(&info);
 }
@@ -1677,7 +1677,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
 	info.length = len;
 	info.low_limit = max(PAGE_SIZE, mmap_min_addr);
 	info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
-	info.align_mask = 0;
+	info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1;
 	info.align_offset = 0;
 	addr = vm_unmapped_area(&info);

--
2.25.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux