* [PATCH] kfence: skip __GFP_THISNODE allocations on NUMA systems
@ 2025-01-24 12:01 Marco Elver
2025-01-24 14:05 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Marco Elver @ 2025-01-24 12:01 UTC (permalink / raw)
To: elver, Andrew Morton
Cc: Alexander Potapenko, Dmitry Vyukov, kasan-dev, linux-mm,
linux-kernel, Vlastimil Babka, Christoph Lameter
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.
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Fixes: 236e9f153852 ("kfence: skip all GFP_ZONEMASK allocations")
Signed-off-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 67fc321db79b..102048821c22 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>
@@ -1084,6 +1085,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;
--
2.48.1.262.g85cc9f2d1e-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] kfence: skip __GFP_THISNODE allocations on NUMA systems
2025-01-24 12:01 [PATCH] kfence: skip __GFP_THISNODE allocations on NUMA systems Marco Elver
@ 2025-01-24 14:05 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2025-01-24 14:05 UTC (permalink / raw)
To: Marco Elver, Andrew Morton
Cc: Alexander Potapenko, Dmitry Vyukov, kasan-dev, linux-mm,
linux-kernel, Christoph Lameter
On 1/24/25 13:01, Marco Elver wrote:
> 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.
>
> Reported-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Christoph Lameter <cl@linux.com>
> Fixes: 236e9f153852 ("kfence: skip all GFP_ZONEMASK allocations")
> Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Thanks.
> ---
> mm/kfence/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
> index 67fc321db79b..102048821c22 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>
> @@ -1084,6 +1085,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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-24 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-24 12:01 [PATCH] kfence: skip __GFP_THISNODE allocations on NUMA systems Marco Elver
2025-01-24 14:05 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox