[PATCH 5/8] arch/loongarch: Stop special-casing hugetlb in arch_get_unmapped_area_common

From: Oscar Salvador

Date: Fri Jun 05 2026 - 23:51:05 EST


arch_get_unmapped_* sets info.align_mask to make room for extra alignment,
so that is added on top of the length we request in unmapped_area{_topdown}.
hugetlb_get_unmapped_area() already adds this extra padding in the 'len'
parameter, and it masks off the address it gets to properly align it to
the huge_page_size we are using.

Stop special-casing hugetlb in arch_get_unmapped_area_common.
The only caveat is that we might get extra align_mask in case we do coloring,
but that should only make us allocate a larger(ish) gap in unmapped_area{_topdown}.

Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>
---
arch/loongarch/mm/mmap.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c
index 1df9e99582cc..8f0af181f902 100644
--- a/arch/loongarch/mm/mmap.c
+++ b/arch/loongarch/mm/mmap.c
@@ -3,7 +3,6 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/
#include <linux/export.h>
-#include <linux/hugetlb.h>
#include <linux/io.h>
#include <linux/kfence.h>
#include <linux/memblock.h>
@@ -65,10 +64,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,

info.length = len;
info.align_offset = pgoff << PAGE_SHIFT;
- if (filp && is_file_hugepages(filp))
- info.align_mask = huge_page_mask_align(filp);
- else
- info.align_mask = do_color_align ? (PAGE_MASK & SHM_ALIGN_MASK) : 0;
+ info.align_mask = do_color_align ? (PAGE_MASK & SHM_ALIGN_MASK) : 0;

if (dir == DOWN) {
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
--
2.35.3