On Tue, 25 Nov 2025 at 10:56, Vlastimil Babka <[email protected]> wrote:
>
> >     #define kmalloc_verify(type) \
> >         BUILD_BUG_ON_ZERO(__alignof__(type) > ARCH_KMALLOC_MINALIGN)
>
> So AFAIU this would be too pessimistic. I'm not sure if the alignment rules
> can be sensibly encoded in build time checks. Perhaps yes, in a similar way
> that we have compile-time size bucket selection via __kmalloc_index().

So I wouldn't worry about it over-much: it's actually pretty unusual
that we have any odd alignment rules for anything that we would
allocate with kmalloc.

And I don't think a 'kmalloc_obj()' case needs to necessarily *handle*
such unusual cases, I just want this to be *detected*.

IOW, what I worry about would be people who use the simple object
allocator mistakenly on auto-pilot.

So if it errors out about "you're trying to use the simple model for
an object that requires non-simple alignment", that is perfectly fine.
Those cases can - and do - use more specialized allocators.

Yes, yes, in a perfect world we'd just handle that case automatically,
but it really is fairly rare, so forcing people to then use some more
involved interface for those cases is maybe not optimal, but it's
perfectly ok.

              Linus

Reply via email to