diff options
| author | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-22 16:27:32 +0000 |
|---|---|---|
| committer | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-22 23:10:41 +0000 |
| commit | 06a51a510a60ca29193b2cdb8120b630ea9ef18c (patch) | |
| tree | 58a58f56bfd0f71f733ed305f3b18847bc1c6e59 | |
| parent | bc537e970d7e52d278952915b0b1842dfbb03afc (diff) | |
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
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/gfp.h | 2 | ||||
| -rw-r--r-- | 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); |
