Re: [PATCH 6.12 289/337] mm/slab: prevent unbounded recursion in free path with new kmalloc type
Nathan Chancellor <[email protected]>
| Newsgroups | dev.linux.lists.patches,org.kernel.vger.stable |
|---|---|
| Message-ID | <20260807180245.GA4067747@ax162> |
On Fri, Aug 07, 2026 at 04:38:12PM +0200, Greg Kroah-Hartman wrote:
...
> - Mark need_kmalloc_no_objext() __always_inline to make sure
> the compiler does not generate a out-of-line function that could
> access mem_profiling_support (which is marked __init)
...
> diff --git a/mm/slab.h b/mm/slab.h
> index b65d2462b3fdb..34a3d65b4ef5f 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -557,6 +562,25 @@ bool slab_in_kunit_test(void);
> static inline bool slab_in_kunit_test(void) { return false; }
> #endif
>
> +/*
> + * Return true if KMALLOC_NORMAL caches may need obj_exts arrays.
> + *
> + * Memory allocation profiling requires obj_exts for all caches.
> + * Memcg usually doesn't need them for normal kmalloc caches, but kmalloc types
> + * with a priority higher than KMALLOC_CGROUP can be aliased with KMALLOC_NORMAL.
> + */
> +static __always_inline inline bool need_kmalloc_no_objext(void)
This adjustment causes a clang warning (or error with CONFIG_WERROR):
In file included from linux/mm/mempool.c:21:
linux/mm/slab.h:572:24: error: duplicate 'inline' declaration specifier [-Werror,-Wduplicate-decl-specifier]
572 | static __always_inline inline bool need_kmalloc_no_objext(void)
| ^
linux/include/linux/compiler_types.h:249:16: note: expanded from macro 'inline'
249 | #define inline inline __gnu_inline __inline_maybe_unused notrace
| ^
As originally reported by KernelCI at
https://lore.kernel.org/[email protected]/
The 'inline' should be dropped, as '__always_inline' includes 'inline'
already.
--
Cheers,
Nathan