Skip to content

Commit efa7df3

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] 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]> Cc: Christopher Lameter <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1803d0c commit efa7df3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/mmap.c

+3
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
18291829
*/
18301830
pgoff = 0;
18311831
get_area = shmem_get_unmapped_area;
1832+
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
1833+
/* Ensures that larger anonymous mappings are THP aligned. */
1834+
get_area = thp_get_unmapped_area;
18321835
}
18331836

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

0 commit comments

Comments
 (0)