From: Ye Bin Date: Sat, 1 Mar 2025 08:37:20 +0000 (+0800) Subject: mm/slab: call kmalloc_noprof() unconditionally in kmalloc_array_noprof() X-Git-Tag: io_uring-6.15-20250403~152^2~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=939c5de3c70d145d7388db1b04d75cda79297c23;p=linux-block.git mm/slab: call kmalloc_noprof() unconditionally in kmalloc_array_noprof() If 'n' or 'size' isn't builtin constant, we used to call __kmalloc() before commit 7bd230a26648 ("mm/slab: enable slab allocation tagging for kmalloc and friends"), which inadvertedly changed both paths to kmalloc_noprof(). As Harry Yoo points out we can just call kmalloc_noprof() unconditionally. If the compiler knows n and size are constants it doesn't guarantee that bytes will be also seen as constant, and that is the important test in kmalloc_noprof() anyway, so we can just defer to it always. [ vbabka@suse.cz: change as Harry suggested and adjust commit log ] Fixes: 7bd230a26648 ("mm/slab: enable slab allocation tagging for kmalloc and friends") Signed-off-by: Ye Bin Reviewed-by: Harry Yoo Signed-off-by: Vlastimil Babka --- diff --git a/include/linux/slab.h b/include/linux/slab.h index 09eedaecf120..ab05a143d09a 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -941,8 +941,6 @@ static inline __alloc_size(1, 2) void *kmalloc_array_noprof(size_t n, size_t siz if (unlikely(check_mul_overflow(n, size, &bytes))) return NULL; - if (__builtin_constant_p(n) && __builtin_constant_p(size)) - return kmalloc_noprof(bytes, flags); return kmalloc_noprof(bytes, flags); } #define kmalloc_array(...) alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))