DragonFly commits List (threaded) for 2012-10
Re: git: kmalloc: Use 'fls' to round up the size to the nearest power of 2
On Tue, Oct 9, 2012 at 12:45 AM, Matthew Dillon
> For cache alignment any allocation that is already a power of 2 will be
> at least that specific power-of-2 aligned. Any allocation that is not
> a power of 2 will be aligned to the slab chunking:
> * Alloc Size Chunking Number of zones
> * 0-127 8 16
> * 128-255 16 8
> * 256-511 32 8
> * 512-1023 64 8
> What this means is that in order to cache align an allocation you only
> need to do it for allocations < 256 bytes (if the cache line size is
> 32 bytes). Any allocation >= 256 bytes will be at least 32-byte aligned
> even if it is not a power of 2.
> So we don't necessarily need to enforce a power-of-2 size in all cases,
> only in cases where the allocation size < 256 bytes.
Ah, ok, I see. However, I think the cache line size is 64bytes on
x86, so as far as I understand from the above table, allocation >=512
will be at least 64bytes aligned?
> Matthew Dillon
Tomorrow Will Never Die