From: Muchun Song <muchun.song@linux.dev>
To: Hongfu Li <hongfu.li@linux.dev>
Cc: Hugh Dickins <hughd@google.com>,
David Hildenbrand <david@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hongfu Li <lihongfu@kylinos.cn>
Subject: Re: [PATCH 1/2] mm/memfd: drop redundant hugetlb allocation mask narrowing
Date: Wed, 18 Nov 2026 19:47:21 +0800 [thread overview]
Message-ID: <87A66860-C0E1-42CF-AFF7-671D19B82E16@linux.dev> (raw)
In-Reply-To: <20261117-for-memfd-v1-1-fa68f433171e@kylinos.cn>
> On Nov 17, 2026, at 18:53, Hongfu Li <hongfu.li@linux.dev> wrote:
>
> From: Hongfu Li <lihongfu@kylinos.cn>
>
> memfd_alloc_folio() derives its allocation mask from htlb_alloc_mask()
> and then clears __GFP_HIGHMEM and __GFP_MOVABLE. This mask handling was
> introduced by commit 89c1905d9c14 ("mm/gup: introduce memfd_pin_folios()
> for pinning memfd folios"), when the fallback path in
> alloc_hugetlb_folio_nodemask() could still call
> alloc_migrate_hugetlb_folio() and reach the buddy allocator, so the mask
> decided the zone and migratetype of freshly allocated pages.
>
> Since commit 26a8ea80929c ("mm/hugetlb: fix memfd_pin_folios
> resv_huge_pages leak"), this call site uses alloc_hugetlb_folio_reserve(),
> which only dequeues folios from the existing hugetlb pool and never falls
> back to the buddy allocator. The mask therefore no longer decides where
> any page comes from.
>
> Long-term pinning safety no longer depends on the mask either:
> memfd_pin_folios() obtains its folios (dequeued from the pool, or freshly
> allocated) under memalloc_pin_save(), so PF_MEMALLOC_PIN makes
> dequeue_hugetlb_folio_node_exact() skip any folio that fails
> folio_is_longterm_pinnable(), and current_gfp_context() already clears
> __GFP_MOVABLE from any page allocator request made under PF_MEMALLOC_PIN.
>
> Drop the narrowing, which has had no effect since 26a8ea80929c.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
> ---
> mm/memfd.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/mm/memfd.c b/mm/memfd.c
> index 0e3ff3eebfa8..8905e3e9efc8 100644
> --- a/mm/memfd.c
> +++ b/mm/memfd.c
> @@ -85,7 +85,6 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
> u32 hash;
>
> gfp_mask = htlb_alloc_mask(h);
> - gfp_mask &= ~(__GFP_HIGHMEM | __GFP_MOVABLE);
You didn't mention why __GFP_HIGHMEM can be removed safely. I have to
investigate the reason myself.
During review, __GFP_HIGHMEM was cleared because "these pages might need
to be accessible by some DMA driver, so you have HIGHMEM constraints.",
refer to https://lore.kernel.org/all/ZmvNLSUgUgFETR0M@localhost.localdomain/
I think that restriction is unnecessary now: DMA and existing memfd_pin_folios()
users operate on pages or scatterlists and support highmem, while the
shmem path already permits highmem folios. The hugetlb path therefore
does not need a separate lowmem constraint.
Because you have removed the constrains, why you didn't remove the comment
along the way?
/*
* The folio would most likely be accessed by a DMA driver,
* therefore, we have zone memory constraints where we can
* alloc from. Also, the folio will be pinned for an indefinite
* amount of time, so it is not expected to be migrated away.
*/
Thanks,
Muchun
> idx >>= huge_page_order(h);
>
> /*
>
> --
> 2.54.0
>
next prev parent reply other threads:[~2026-11-18 11:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 10:53 [PATCH 0/2] mm/memfd: drop stale hugetlb allocation mask handling Hongfu Li
2026-11-17 10:53 ` [PATCH 1/2] mm/memfd: drop redundant hugetlb allocation mask narrowing Hongfu Li
2026-11-18 11:47 ` Muchun Song [this message]
2026-11-17 10:53 ` [PATCH 2/2] mm/hugetlb: remove the gfp_mask argument from alloc_hugetlb_folio_reserve() Hongfu Li
2026-11-17 11:15 ` Muchun Song
2026-11-18 1:48 ` Hongfu Li
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=87A66860-C0E1-42CF-AFF7-671D19B82E16@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=hongfu.li@linux.dev \
--cc=hughd@google.com \
--cc=lihongfu@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
/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
all inboxes | Powered by JetHome®