Skip to content

Commit e64f819

Browse files
melverakpm00
authored andcommitted
kfence: skip __GFP_THISNODE allocations on NUMA systems
On NUMA systems, __GFP_THISNODE indicates that an allocation _must_ be on a particular node, and failure to allocate on the desired node will result in a failed allocation. Skip __GFP_THISNODE allocations if we are running on a NUMA system, since KFENCE can't guarantee which node its pool pages are allocated on. Link: https://lkml.kernel.org/r/20250124120145.410066-1-elver@google.com Fixes: 236e9f1 ("kfence: skip all GFP_ZONEMASK allocations") Signed-off-by: Marco Elver <elver@google.com> Reported-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Christoph Lameter <cl@linux.com> Cc: Alexander Potapenko <glider@google.com> Cc: Chistoph Lameter <cl@linux.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 6438ef3 commit e64f819

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/kfence/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/log2.h>
2222
#include <linux/memblock.h>
2323
#include <linux/moduleparam.h>
24+
#include <linux/nodemask.h>
2425
#include <linux/notifier.h>
2526
#include <linux/panic_notifier.h>
2627
#include <linux/random.h>
@@ -1084,6 +1085,7 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags)
10841085
* properties (e.g. reside in DMAable memory).
10851086
*/
10861087
if ((flags & GFP_ZONEMASK) ||
1088+
((flags & __GFP_THISNODE) && num_online_nodes() > 1) ||
10871089
(s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) {
10881090
atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]);
10891091
return NULL;

0 commit comments

Comments
 (0)