On Wed, Jul 03, 2024 at 09:25:21AM +0200, Vlastimil Babka wrote: > - if (is_power_of_2(size)) > - align = max(align, size); > + if (flags & SLAB_KMALLOC) > + align = max(align, 1U << (ffs(size) - 1)); hmm ... maybe this would be faster: if (flags & SLAB_KMALLOC) { u32 tmp = size & (size - 1); align = max(align, size - tmp); } (if size is 2^n, tmp is 0. otherwise, tmp is size with the lowest bit clear, so size-tmp is the largest POT that divides size evenly)