|
|
Log in / Subscribe / Register

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

Ooh, ooh, I know this one! Hope you like horror films ...

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.


to post comments

Pulling slabs out of struct page

Posted Oct 8, 2021 23:55 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

Ah. I suspected as much. Thanks for the night-time alignment horror story!

Pulling slabs out of struct page

Posted Oct 10, 2021 0:54 UTC (Sun) by vivo (subscriber, #48315) [Link]

this one deserve a place in the weekly "Brief items" page


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds