The ultimate goal of the folios project is to turn struct page into:
struct page { unsigned long memdesc; };
The memdesc contains a 4 bit field that describes what the remaining 60/28 bits are used for. Most memdescs use a pointer, but some memdescs can store all the extra information they need directly in the memdesc.
0 |
None, Reserved, Guard, ... |
1 |
File (struct folio pointer) |
2 |
Anon (struct anon_folio pointer) |
3 |
KSM (struct ksm pointer) |
4 |
Slab (struct slab pointer) |
5 |
Free (struct buddy pointer) |
6 |
Movable (struct movable pointer) |
7 |
VmallocMappable (struct pointer) |
8 |
|
9 |
PageTable (struct ptdesc pointer) |
10 |
NetPool (struct netpool pointer) |
11 |
HWPoison (struct hwpoison pointer) |
12-15 |
not yet assigned |
All structs pointed to from a memdesc must be allocated from a slab which has its alignment set to 16 bytes (in order to allow the bottom 4 bits to be used for the type). That implies that they are a multiple of 16 bytes in size. The slab must also have the TYPESAFE_BY_RCU flag set as some page walkers will attempt to look up the memdesc from the page while holding only the RCU read lock.