Pulling slabs out of struct page
Pulling slabs out of struct page
Posted Oct 8, 2021 21:10 UTC (Fri) by willy (subscriber, #9762)In reply to: Pulling slabs out of struct page by Cyberax
Parent article: Pulling slabs out of struct page
Slub needs to cmpxchg_double() freelist & counters. That means that freelist has to be dword aligned on both 32 and 64 bit. _refcount is word sized on 32-bit and half-word sized on 64-bit. For compactness, we pair it with _mapcount. Now the pair are either one or two words, depending on 32/64 bit. So _refcount has to be after freelist+counters in order for them to be dword aligned on both 32 and 64 bit. It's advantageous to make the main union as large as possible, so _refcount has to go towards the end of the struct.
There are other considerations in the layout of struct page, but these are the ones that pertain to the location of _refcount.
