kmalloc_nolock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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_ACCOUNT and __GFP_ZERO are allowed. __GFP_NOWARN and __GFP_NOMEMALLOC are 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 got NULL, it's ENOMEM. 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:

(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