kmalloc_size_roundup(9)
π kmalloc_size_roundup(9) π
okay bestie, welcome to the Kernel API Manual β todayβs main character is kmalloc_size_roundup, and itβs giving βsmall function, very useful bucket mathβ energy β¨
πΈ NAME πΈ
kmalloc_size_roundup β Report allocation bucket size for the given size. Thatβs the whole vibe, no cap.
β¨ SYNOPSIS β¨
size_t kmalloc_size_roundup (size_t size );
π ARGUMENTS π
sizeβ Number of bytes to round up from. Thatβs literally the assignment, bestie. π
π DESCRIPTION π
okay so this returns the number of bytes that would be available in a kmalloc allocation of size bytes. For example, a 126 byte request would be rounded up to the next sized kmalloc bucket, 128 bytes. Slay? Slay. π₯
This is strictly for the general-purposekmalloc-based allocations, and is not for the pre-sizedkmem_cache_alloc-based allocations. Important distinction β do not mix those up, bestie. π
Use this to kmalloc the full bucket size ahead of time instead of using ksize to query the size after an allocation. Itβs giving βplan ahead, iconβ energy. π«Ά
π¦ SEE ALSO π¦
Kernel file ./include/linux/slab.h β plus the whole squad, periodt:
SLAB_HWCACHE_ALIGN(9)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)
mwah π this little page comes from ./include/linux, is dated October 2026, and lives in the Kernel API Manual β kmalloc_size_roundup(9), signing off! π«Άβ¨
π¦ 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