aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2025-07-07 12:27:48 +0000
committerOlivier Certner <olce@FreeBSD.org>2025-07-13 06:41:19 +0000
commit4ca9190251bbd00c928a3cba54712c3ec25e9e26 (patch)
tree4145ef4cfea3400c64b3df38a88a4984ff40fa8a
parentbf4d2a45b9913bbd4720423288f4bdb2f0afc970 (diff)
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
-rw-r--r--sys/compat/linuxkpi/common/src/linux_page.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index ebb92eacbf9a..628af17df853 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -106,6 +106,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)
@@ -113,6 +114,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);