git: 06a51a510a60 - main - linuxkpi: Implement __GFP_THISNODE in alloc_pages()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Apr 2026 23:11:02 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=06a51a510a60ca29193b2cdb8120b630ea9ef18c
commit 06a51a510a60ca29193b2cdb8120b630ea9ef18c
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-22 16:27:32 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 23:10:41 +0000
linuxkpi: Implement __GFP_THISNODE in alloc_pages()
It indicates to `alloc_pages()` to allocate the pages from the current
NUMA domain. If it couldn't, it should not retry elsewhere and return
failure.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56590
---
sys/compat/linuxkpi/common/include/linux/gfp.h | 2 +-
sys/compat/linuxkpi/common/src/linux_page.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h
index b94cbada0435..5c638be92beb 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -59,7 +59,7 @@
#define __GFP_WAIT M_WAITOK
#define __GFP_DMA32 (1U << 24) /* LinuxKPI only */
#define __GFP_NORETRY (1U << 25) /* LinuxKPI only */
-#define __GFP_THISNODE (1U << 26) /* Unimplemented */
+#define __GFP_THISNODE (1U << 26)
#define __GFP_BITS_SHIFT 27
#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1)
#define __GFP_NOFAIL M_WAITOK
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 82f3a2a4639f..d8b65a12dc67 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -119,10 +119,19 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
req |= VM_ALLOC_NORECLAIM;
retry:
- page = vm_page_alloc_noobj_contig(req, npages, 0, pmax,
- PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+ if ((flags & __GFP_THISNODE) != 0) {
+ int curdomain = PCPU_GET(domain);
+ page = vm_page_alloc_noobj_contig_domain(
+ curdomain, req, npages, 0, pmax,
+ PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+ } else {
+ page = vm_page_alloc_noobj_contig(
+ req, npages, 0, pmax,
+ PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+ }
+
if (page == NULL) {
- if ((flags & (M_WAITOK | __GFP_NORETRY)) ==
+ if ((flags & (M_WAITOK | __GFP_NORETRY | __GFP_THISNODE)) ==
M_WAITOK) {
int err = vm_page_reclaim_contig(req,
npages, 0, pmax, PAGE_SIZE, 0);