From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Steve Sistare <steven.sistare@oracle.com>,
Muchun Song <muchun.song@linux.dev>,
"David Hildenbrand" <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: RE: [PATCH v4 2/3] mm/memfd: Reserve hugetlb folios before allocation
Date: Thu, 19 Jun 2025 05:34:23 +0000 [thread overview]
Message-ID: <IA0PR11MB7185700685CEE03EB5A920E8F87DA@IA0PR11MB7185.namprd11.prod.outlook.com> (raw)
In-Reply-To: <aFJuzKPG-7t_oflN@localhost.localdomain>
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
next prev parent reply other threads:[~2025-06-19 5:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 5:30 [PATCH v4 0/3] " Vivek Kasireddy
2025-06-18 5:30 ` [PATCH v4 1/3] mm/hugetlb: Make hugetlb_reserve_pages() return nr of entries updated Vivek Kasireddy
2025-06-18 5:30 ` [PATCH v4 2/3] mm/memfd: Reserve hugetlb folios before allocation Vivek Kasireddy
2025-06-18 7:46 ` Oscar Salvador
2025-06-19 5:34 ` Kasireddy, Vivek [this message]
2025-06-18 5:30 ` [PATCH v4 3/3] selftests/udmabuf: Add a test to pin first before writing to memfd Vivek Kasireddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=IA0PR11MB7185700685CEE03EB5A920E8F87DA@IA0PR11MB7185.namprd11.prod.outlook.com \
--to=vivek.kasireddy@intel.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=steven.sistare@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox