diff --git a/mm/mmap.c b/mm/mmap.c index 5f53849fc828..68396a707a35 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1835,6 +1835,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, */ get_area = shmem_get_unmapped_area; } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) + && !addr /* no hint */ && IS_ALIGNED(len, PMD_SIZE)) { /* Ensures that larger anonymous mappings are THP aligned. */ get_area = thp_get_unmapped_area;