summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2025-01-24 13:01:38 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-17 09:40:32 +0100
commit7753ef5ba2a60033f6cc5bf19196d8d17b0fd120 (patch)
tree6a96decdaea674e5872dfe29ed6f5cdcf4bc542d /mm
parent0796fa13788c860eca4164857f07d41932e39ba6 (diff)
downloadlinux-7753ef5ba2a60033f6cc5bf19196d8d17b0fd120.tar.gz
linux-7753ef5ba2a60033f6cc5bf19196d8d17b0fd120.tar.bz2
linux-7753ef5ba2a60033f6cc5bf19196d8d17b0fd120.zip
kfence: skip __GFP_THISNODE allocations on NUMA systems
commit e64f81946adf68cd75e2207dd9a51668348a4af8 upstream. 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: 236e9f153852 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/kfence/core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 3872528d0963..937bbae2611f 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -21,6 +21,7 @@
#include <linux/log2.h>
#include <linux/memblock.h>
#include <linux/moduleparam.h>
+#include <linux/nodemask.h>
#include <linux/notifier.h>
#include <linux/panic_notifier.h>
#include <linux/random.h>
@@ -1065,6 +1066,7 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags)
* properties (e.g. reside in DMAable memory).
*/
if ((flags & GFP_ZONEMASK) ||
+ ((flags & __GFP_THISNODE) && num_online_nodes() > 1) ||
(s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) {
atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]);
return NULL;