Skip to content

Commit 5d62a2c

Browse files
committed
kfence: skip __GFP_THISNODE allocations on NUMA systems
commit e64f819 Author: Marco Elver <[email protected]> Date: Fri Jan 24 13:01:38 2025 +0100 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/[email protected] Fixes: 236e9f1 ("kfence: skip all GFP_ZONEMASK allocations") Signed-off-by: Marco Elver <[email protected]> Reported-by: Vlastimil Babka <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Chistoph Lameter <[email protected]> Cc: Dmitriy Vyukov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <[email protected]>
1 parent 638ca1d commit 5d62a2c

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)