Re: [GIT PULL] kmalloc_obj treewide refactor for v7.0-rc1

Kees Cook
2026-02-21T22:46:02Z

On Sat, Feb 21, 2026 at 11:49:19AM -0800, Linus Torvalds wrote:
> IOW, how about doing something like this:
>
> #define pick_first(a, ...) a
> #define GFP(...) pick_first(__VA_ARGS__ __VA_OPT__(,) GFP_KERNEL)
>
> #define kmalloc_obj(VAR_OR_TYPE, ...) \
> __alloc_objs(kmalloc, GFP(__VA_ARGS__), typeof(VAR_OR_TYPE), 1)
>
> and now you can just do
>
> a = kmalloc_obj(type);
>
> if you just want the default GFP_KERNEL?

Yeah, I'd really like to do this, though I was trying to reduce the
macro shenanigans for this first phase, as you had correctly been
bothered about their proposed complexity. (And even their current
complexity is still creating problems for this series...) :|

--
Kees Cook