kmalloc_nolock(9)
π kmalloc_nolock(9) π
okay bestie so we're in the kernel API manual, section 9, and today's main character is kmalloc_nolock β she's the allocation girlie who does not care what context you're in. like, at all. no cap.
β¨ NAME β¨
kmalloc_nolock β allocate an object of given size from any context. yes queen, any. π
πΈ SYNOPSIS πΈ
void * kmalloc_nolock (size_t size , gfp_t gfp_flags , int node );
that's it. three lil args and you get a pointer. slay.
π ARGUMENTS π
sizeβ the size you wanna allocate. how much memory, babe? that's the whole vibe here. β¨gfp_flagsβ the GFP flags. and listen, this is the strict part: only__GFP_ACCOUNTand__GFP_ZEROare allowed.__GFP_NOWARNand__GFP_NOMEMALLOCare also allowed but ngl they get added internally, so you don't actually need to pass them yourself. iykyk π«Άnodeβ the node number of the target node. which node? that node. the target one. π«
π¦ RETURN π¦
you get back a pointer to the new object, or NULL if something went wrong. π
and here's the part where i need you to listen: NULL does not mean EBUSY or EAGAIN. it means ENOMEM. periodt. so there is no reason to call it again and expect !NULL β like, it's not gonna magically work the second time, bestie. that's not the vibe check it's giving. π
fr fr: if you gotNULL, it'sENOMEM. retrying is not the move. don't do it. π
π SEE ALSO π
okay this is the part where i introduce you to the whole friend group. they're all iconic, all in section 9, and they all hang out in the kernel file ./include/linux/slab.h:
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)__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)
(and obviously the Kernel file ./include/linux/slab.h itself, because that's where they all live π )
that's the whole page, bestie. go allocate something. responsibly. π
β with love from ./include/linux, dated October 2026, page kmalloc_nolock(9) πβ¨π¦
π¦ 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