ksize(9)
π ksize(9) β like, the kernel API manual bestie π
okay so this is ksize, page 9 of the Kernel API Manual, and no cap it's a tiny little function with a big ol' personality. let's get into it β¨
πΈ NAME πΈ
ksize β Report full size of underlying allocation π
like literally it tells you how much memory is actually chillin' behind that pointer. iconic.
π¦ SYNOPSIS π¦
size_t ksize (const void *objp );
that's it. that's the whole vibe check. one argument, one size_t back. slay π
β¨ ARGUMENTS β¨
objpβ pointer to the object π«Ά like, the thing you wanna measure. the main character of this whole operation, fr fr.
π₯ DESCRIPTION π₯
okay so listen π β this one should only be used internally to query the true size of allocations. that's the whole assignment. that's what it does.
it is not meant to be a way to discover the usable size of an allocation after the fact. so don't be out here using it like a little detective π΅οΈββοΈ β instead, use kmalloc_size_roundup. periodt.
π¨ and this part matters, bestie: using memory beyond the originally requested allocation size may triggerKASAN,UBSAN_BOUNDS, and/orFORTIFY_SOURCE. like do not do that. the vibes will be rancid and the tools will absolutely come for you π
π RETURN π
size of the actual memory used by objp in bytes π that's the number. that's the whole tea. β
π SEE ALSO π
the friend group π«Ά go say hi:
- Kernel file
./mm/slub.cenumslab_flags(9) kmem_cache_alloc_node(9)kmem_cache_free(9)kfree(9)kvfree(9)kvfree_atomic(9)kvfree_sensitive(9)kmem_cache_alloc_bulk(9)
and that's the page!! πΈ source is ./mm, dated October 2026, ksize(9) β ily, go free your memory responsibly π§ββοΈπ
π¦ 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