* Re: [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing
2026-11-19 9:49 [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing Hongfu Li
@ 2026-11-19 13:34 ` Muchun Song
2026-11-19 14:06 ` Oscar Salvador (SUSE)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Muchun Song @ 2026-11-19 13:34 UTC (permalink / raw)
To: Hongfu Li
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Andrew Morton,
Oscar Salvador, linux-mm, linux-kernel, Hongfu Li
> On Nov 19, 2026, at 17:49, 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.
>
> Clearing __GFP_HIGHMEM was a lowmem constraint for these folios, which
> were meant to be accessed by a DMA driver. It is not required any more:
> the users of memfd_pin_folios() work on pages and scatterlists, which
> support highmem, as does the shmem path with its default
> GFP_HIGHUSER_MOVABLE mask.
>
> Drop the narrowing, which has had no effect since 26a8ea80929c.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing
2026-11-19 9:49 [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing Hongfu Li
2026-11-19 13:34 ` Muchun Song
@ 2026-11-19 14:06 ` Oscar Salvador (SUSE)
2026-11-19 16:47 ` David Hildenbrand (Arm)
2026-11-19 16:49 ` David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-11-19 14:06 UTC (permalink / raw)
To: Hongfu Li
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Andrew Morton,
Muchun Song, Oscar Salvador, linux-mm, linux-kernel, Hongfu Li
On Thu, Nov 19, 2026 at 05:49:45PM +0800, Hongfu Li 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.
>
> Clearing __GFP_HIGHMEM was a lowmem constraint for these folios, which
> were meant to be accessed by a DMA driver. It is not required any more:
> the users of memfd_pin_folios() work on pages and scatterlists, which
> support highmem, as does the shmem path with its default
> GFP_HIGHUSER_MOVABLE mask.
>
> Drop the narrowing, which has had no effect since 26a8ea80929c.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing
2026-11-19 9:49 [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing Hongfu Li
2026-11-19 13:34 ` Muchun Song
2026-11-19 14:06 ` Oscar Salvador (SUSE)
@ 2026-11-19 16:47 ` David Hildenbrand (Arm)
2026-11-19 16:49 ` David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-19 16:47 UTC (permalink / raw)
To: Hongfu Li, Hugh Dickins, Baolin Wang, Andrew Morton, Muchun Song,
Oscar Salvador
Cc: linux-mm, linux-kernel, Hongfu Li
On 11/19/26 10:49, Hongfu Li 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.
>
> Clearing __GFP_HIGHMEM was a lowmem constraint for these folios, which
> were meant to be accessed by a DMA driver. It is not required any more:
> the users of memfd_pin_folios() work on pages and scatterlists, which
> support highmem, as does the shmem path with its default
> GFP_HIGHUSER_MOVABLE mask.
>
> Drop the narrowing, which has had no effect since 26a8ea80929c.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
> ---
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing
2026-11-19 9:49 [PATCH v2] mm/memfd: drop redundant hugetlb allocation mask narrowing Hongfu Li
` (2 preceding siblings ...)
2026-11-19 16:47 ` David Hildenbrand (Arm)
@ 2026-11-19 16:49 ` David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2026-11-19 16:49 UTC (permalink / raw)
To: Hugh Dickins, David Hildenbrand, Baolin Wang, Andrew Morton,
Muchun Song, Oscar Salvador, Hongfu Li
Cc: linux-mm, linux-kernel, Hongfu Li
On Thu, 19 Nov 2026 17:49:45 +0800, Hongfu Li wrote:
> 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.
>
> [...]
Applied, thanks!
tree: mm/core.git
branch: shmem-7.5.misc
Applied patches will appear soon in mm-next, followed by linux-next.
Please report any outstanding bugs that were missed during review, so we
can either drop the patch series or decide how to fix it up.
It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even
though the patches have already been applied. If possible, patch trailers
will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. Further, this is not a guarantee that the
patches will go upstream. If in doubt, please check the listed branch.
[1/1] mm/memfd: drop redundant hugetlb allocation mask narrowing
https://git.kernel.org/mm/core/c/b2f133fb
--
Cheers,
David
^ permalink raw reply [flat|nested] 5+ messages in thread