Re: [PATCH v4 2/7] mm/slab: Give bucket caches the alignment of the caches they mirror

From: Harry Yoo

Date: Thu Sep 24 2026 - 14:29:17 EST


On Mon, Sep 21, 2026 at 04:25:25PM -0700, Kees Cook wrote:
> On Mon, Sep 21, 2026 at 02:17:21PM +0100, Harry Yoo wrote:
> > On Mon, Sep 21, 2026 at 12:58:13AM -0700, Kees Cook wrote:
> > > if (WARN_ON(!cache_name))
> > > goto fail;
> > > (*b)[aligned_idx] = kmem_cache_create_usercopy(cache_name, size,
> > > - 0, flags, cache_useroffset,
> > > + kmalloc_caches[KMALLOC_NORMAL][idx]->align,
> > > + flags, cache_useroffset,
> > > cache_usersize, ctor);
> > > kfree(cache_name);
> > > if (WARN_ON(!(*b)[aligned_idx]))
>
> It looks "obviously correct", but I probably failed to correctly
> describe it. I'm happy to do whatever here.

That is correct, but is there any reason why kmem_buckets users should
not specify their own alignment requirement and inherit the alignment
from kmalloc?

For DMA yeah it might be confusing for every user to figure out that
the alignment should be __kmalloc_minalign(), but otherwise there isn't
really a good enough reason to inherit the alignment from kmalloc, no?

--
Cheers,
Harry / Hyeonggon