Skip to content

Commit f35b5d7

Browse files
rikvanrielakpm00
authored andcommitted
mm: align larger anonymous mappings on THP boundaries
Align larger anonymous memory mappings on THP boundaries by going through thp_get_unmapped_area if THPs are enabled for the current process. With this patch, larger anonymous mappings are now THP aligned. When a malloc library allocates a 2MB or larger arena, that arena can now be mapped with THPs right from the start, which can result in better TLB hit rates and execution time. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Rik van Riel <[email protected]> Reviewed-by: Yang Shi <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7b5a0b6 commit f35b5d7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/mmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
22322232
*/
22332233
pgoff = 0;
22342234
get_area = shmem_get_unmapped_area;
2235+
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
2236+
/* Ensures that larger anonymous mappings are THP aligned. */
2237+
get_area = thp_get_unmapped_area;
22352238
}
22362239

22372240
addr = get_area(file, addr, len, pgoff, flags);

0 commit comments

Comments
 (0)