Re: [PATCH v2 05/53] selftests/mm: merge map_hugetlb into hugepage-mmap

Mike Rapoport
2026-04-21T07:25:12Z

Hi Donet,

On Mon, Apr 20, 2026 at 02:50:49PM +0530, Donet Tom wrote:
> On 4/18/26 4:24 PM, Mike Rapoport wrote:
> >
> > +static void test_file_mmap(size_t length, int shift)
> > +{
> > + const char *test_name = "hugetlb file mmap";
> > + int mmap_flags = MAP_SHARED;
> > + bool passed;
> > + int fd;
> > +
> > + if (shift)
> > + mmap_flags |= (shift & MAP_HUGE_MASK) << MAP_HUGE_SHIFT;
>
> From what I understand, selecting an alternative huge page size using mmap
> flags is typically used along with MAP_HUGETLB. Since we are not using
> MAP_HUGETLB, would this code still be necessary? please let me know if I
> might be missing something.
>
>
>
> > - fd = memfd_create("hugepage-mmap", MFD_HUGETLB);
> > + fd = memfd_create("hugetlb-mmap", MFD_HUGETLB);
> >
> In my test, the default huge page size is 2MB. I passed a shift value of 30
> (for 1GB huge pages), but the mmap call failed — To support 1GB huge page
> sizes on a system with a 2MB default huge page size, I used MFD_HUGETLB |
> MFD_HUGE_1GB. With this change, file-backed mmap using 1GB huge pages
> started working. Do you think this change would be needed?

Yes, I'll update the test to use proper MFD_ flags. Then mmap_flags change
won't be needed.

Thanks for spotting this!

> -Donet
>

--
Sincerely yours,
Mike.