git: d738ed04dbff - stable/14 - LinuxKPI: alloc_pages(): Don't reclaim on __GFP_NORETRY
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Jul 2025 13:31:47 UTC
The branch stable/14 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=d738ed04dbff78243617ac341486b86486e9c8be
commit d738ed04dbff78243617ac341486b86486e9c8be
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-07-07 12:27:48 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-07-28 13:28:49 +0000
LinuxKPI: alloc_pages(): Don't reclaim on __GFP_NORETRY
Pass VM_ALLOC_NORECLAIM to vm_page_alloc_noobj_contig() so that it
avoids reclaiming (currently, calling vm_reserv_reclaim_contig()).
According to Linux's documentation, __GFP_NORETRY should not cause any
"disruptive reclaim". alloc_pages() is called a lot from the amdgpu DRM
driver via ttm_pool_alloc(), which tries to allocate pages of the
highest order first and fallback to lower order pages (as allocating
contiguous physical pages is in fact not a requirement). This process
relies on failing fast, as requested by __GFP_NORETRY. See also related
commit 718d1928f874 ("LinuxKPI: make linux_alloc_pages() honor
__GFP_NORETRY").
Reviewed by: jeffpc_josefsipek.net, bz
MFC after: 10 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51246
(cherry picked from commit 4ca9190251bbd00c928a3cba54712c3ec25e9e26)
Forgotten on commit to main/-CURRENT:
PR: 277476
---
sys/compat/linuxkpi/common/src/linux_page.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 99b63e8d5680..bb5a1411eeec 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -107,6 +107,7 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
if ((flags & M_ZERO) != 0)
req |= VM_ALLOC_ZERO;
+
if (order == 0 && (flags & GFP_DMA32) == 0) {
page = vm_page_alloc_noobj(req);
if (page == NULL)
@@ -114,6 +115,10 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
} else {
vm_paddr_t pmax = (flags & GFP_DMA32) ?
BUS_SPACE_MAXADDR_32BIT : BUS_SPACE_MAXADDR;
+
+ if ((flags & __GFP_NORETRY) != 0)
+ req |= VM_ALLOC_NORECLAIM;
+
retry:
page = vm_page_alloc_noobj_contig(req, npages, 0, pmax,
PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);