The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=4ca9190251bbd00c928a3cba54712c3ec25e9e26
commit 4ca9190251bbd00c928a3cba54712c3ec25e9e26 Author: Olivier Certner <o...@freebsd.org> AuthorDate: 2025-07-07 12:27:48 +0000 Commit: Olivier Certner <o...@freebsd.org> CommitDate: 2025-07-13 06:41:19 +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 --- 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 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);