SLAB_HWCACHE_ALIGN(9)
π SLAB_HWCACHE_ALIGN β like, the Linux kernel API manual, bestie β¨
okay so real talk, this is a page from the Kernel API Manual and honestly? it's a little baby page but it's doing a LOT. let's get into it π«Ά
β¨ NAME β¨
SLAB_HWCACHE_ALIGN β aligns your objects on cache line boundaries. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
SLAB_HWCACHE_ALIGN
no args, no drama, she's just a flag. periodt. π
π¦ DESCRIPTION π¦
okay so here's the tea β β sufficiently large objects get aligned on a cache line boundary. iconic behavior, no notes.
but it gets cuter. if your object size is smaller than a half of the cache line size, then the alignment drops down to half of the cache line size. she's being flexible, she's matching your energy π
and it's a whole general rule, not just a one-off: if the object size is smaller than 1/2^n of the cache line size, the alignment gets adjusted to 1/2^n. like, she keeps halving until it fits. the way she just knows the math πβ¨
and if you ALSO ask for explicit alignment through the respective struct kmem_cache_args field? no fighting, no beef β the greater of both alignments is the one that gets applied. biggest wins, queen behavior ππ₯
π SEE ALSO π
grab a snack, this list is long and she's thriving π
- Kernel file
./include/linux/slab.h SLAB_TYPESAFE_BY_RCU(9)SLAB_ACCOUNT(9)SLAB_RECLAIM_ACCOUNT(9)struct kmem_cache_args(9)kmem_cache_create_usercopy(9)kmem_cache_create(9)krealloc_node_align(9)kmem_cache_alloc(9)kmem_cache_charge(9)kmalloc(9)kmalloc_nolock(9)__alloc_objs(9)__alloc_flex(9)kmalloc_obj(9)kmalloc_objs(9)kmalloc_flex(9)kmalloc_array(9)krealloc_array(9)kcalloc(9)kzalloc(9)kvmalloc_node(9)kvrealloc_node_align(9)kmalloc_size_roundup(9)
like, go read literally all of them, iykyk ππ§
lowkey a flex that this whole thing lives in ./include/linux, if you were wondering where to find her π
and that's the whole page bestie!! mwah π this one came straight out of ./include/linux, dated October 2026, and it's filed under SLAB_HWCACHE_ALIGN(9) β slay, go align something πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms