On Thu, Dec 5, 2024 at 11:04 PM Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> wrote: > > Commit ed48e87c7df3 ("thp: add thp_get_unmapped_area_vmflags()") > changes thp_get_unmapped_area() to thp_get_unmapped_area_vmflags() > in __get_unmapped_area(), which won't setup get_area for anonymous > mappings, but it leads to always try THP align when file ops without > '.get_unmapped_area' callback too as the get_area is NULL. > > Since commit efa7df3e3bb5 ("mm: align larger anonymous mappings on > THP boundaries") only want to enable THP align for anonymous, adding > !file check to fix it. Good catch. Reviewed-by: Yang Shi <shy828301@xxxxxxxxx> > > Fixes: ed48e87c7df3 ("thp: add thp_get_unmapped_area_vmflags()") > Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> > --- > mm/mmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index 1c6bdffa13dd..b373486bd1c6 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -782,7 +782,7 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, > > if (get_area) { > addr = get_area(file, addr, len, pgoff, flags); > - } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) > + } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && !file > && !addr /* no hint */ > && IS_ALIGNED(len, PMD_SIZE)) { > /* Ensures that larger anonymous mappings are THP aligned. */ > -- > 2.27.0 >