@@ -27,6 +27,9 @@ int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
if (gfpflags & __GFP_NOFAIL)
return 0;
+ if (!gfpflags_allow_spinning(gfpflags))
+ return 0;
+
if (failslab.ignore_gfp_reclaim &&
(gfpflags & __GFP_DIRECT_RECLAIM))
return 0;
@@ -1096,6 +1096,10 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags)
if (s->flags & SLAB_SKIP_KFENCE)
return NULL;
+ /* Bailout, since kfence_guarded_alloc() needs to take a lock */
+ if (!gfpflags_allow_spinning(flags))
+ return NULL;
+
allocation_gate = atomic_inc_return(&kfence_allocation_gate);
if (allocation_gate > 1)
return NULL;
@@ -648,6 +648,9 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp)
{
struct kmemleak_object *object;
+ if (!gfpflags_allow_spinning(gfp))
+ return NULL;
+
object = mem_pool_alloc(gfp);
if (!object) {
pr_warn("Cannot allocate a kmemleak_object structure\n");