]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: skip might_alloc() warnings when PF_MEMALLOC is set
authorUladzislau Rezki (Sony) <urezki@gmail.com>
Tue, 7 Oct 2025 12:20:33 +0000 (14:20 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 15 Oct 2025 04:28:29 +0000 (21:28 -0700)
might_alloc() catches invalid blocking allocations in contexts where
sleeping is not allowed.

However when PF_MEMALLOC is set, the page allocator already skips reclaim
and other blocking paths.  In such cases, a blocking gfp_mask does not
actually lead to blocking, so triggering might_alloc() splats is
misleading.

Adjust might_alloc() to skip warnings when the current task has
PF_MEMALLOC set, matching the allocator's actual blocking behaviour.

Link: https://lkml.kernel.org/r/20251007122035.56347-9-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Baoquan He <bhe@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Marco Elver <elver@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/sched/mm.h

index 0232d983b71539534d2680ec688f817db656fb56..a74582aed7473af77bb72d76ca04c06f48159c2a 100644 (file)
@@ -318,6 +318,9 @@ static inline void might_alloc(gfp_t gfp_mask)
        fs_reclaim_acquire(gfp_mask);
        fs_reclaim_release(gfp_mask);
 
+       if (current->flags & PF_MEMALLOC)
+               return;
+
        might_sleep_if(gfpflags_allow_blocking(gfp_mask));
 }