[PATCH v4 2/3] mm/memfd: Reserve hugetlb folios before allocation
Kasireddy, Vivek
vivek.kasireddy at intel.com
Thu Jun 19 05:34:23 UTC 2025
Hi Oscar,
> Subject: Re: [PATCH v4 2/3] mm/memfd: Reserve hugetlb folios before
> allocation
>
> On Tue, Jun 17, 2025 at 10:30:54PM -0700, Vivek Kasireddy wrote:
> > When we try to allocate a folio via alloc_hugetlb_folio_reserve(),
> > we need to ensure that there is an active reservation associated
> > with the allocation. Otherwise, our allocation request would fail
> > if there are no active reservations made at that moment against any
> > other allocations. This is because alloc_hugetlb_folio_reserve()
> > checks h->resv_huge_pages before proceeding with the allocation.
> >
> > Therefore, to address this issue, we just need to make a reservation
> > (by calling hugetlb_reserve_pages()) before we try to allocate the
> > folio. This will also ensure that proper region/subpool accounting is
> > done associated with our allocation.
>
> I'm not really familiar with memfd code, but can't you make such
> reservation when you create the file in alloc_file?
> I see that you explicitly pass VM_NORESERVE. What's the reason for
> that?
AFAICT, there are at-least two reasons:
- The initial size of memfd is 0 when it gets created. So, there is nothing
to reserve when hugetlb_file_setup() gets called from memfd_create().
- And, I think reservations are typically associated with allocations. In
other words, they are made on-demand, when a user is about to write
to a file (after calling mmap()).
Thanks,
Vivek
>
>
> --
> Oscar Salvador
> SUSE Labs
More information about the dri-devel
mailing list