objpool_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

hey bestie πŸ’– this is objpool_init(9) from the Kernel API Manual β€” the moment an object pool gets its pre-allocated objects situation fully set up ✨


πŸ’– NAME πŸ’–

objpool_init β€” initialize objpool and pre-allocated objects πŸŽ€

✨ SYNOPSIS ✨

the whole call, exactly as it is, no cap:

int objpool_init (struct objpool_head *pool , int nr_objs , int
object_size , gfp_t gfp , void *context , objpool_init_obj_cb objinit ,
objpool_fini_cb release );

πŸŽ€ ARGUMENTS πŸŽ€

  • pool β€” the object pool to be initialized, declared by caller. yes, you bring the pool 🫢
  • nr_objs β€” total objects to be pre-allocated by this object pool. the whole pre-allocation headcount πŸ’…
  • object_size β€” size of an object (should be > 0). lowkey important, bestie πŸ’€
  • gfp β€” flags for memory allocation (via kmalloc or vmalloc). the allocation vibe check 🌈
  • context β€” user context for object initialization callback. your little context handoff πŸŽ€
  • objinit β€” object initialization callback for extra setup. extra setup goes here ✨
  • release β€” cleanup callback for extra cleanup task. cleanup queen behavior 🧹

πŸ¦‹ DESCRIPTION πŸ¦‹

return value: 0 for success, otherwise error code. periodt.

All pre-allocated objects are to be zeroed after memory allocation. Caller could do extra initialization in objinit callback. objinit will be called just after slot allocation and called only once for each object. After that the objpool won't touch any content of the objects. It's caller's duty to perform reinitialization after each pop (object allocation) or do clearance before each push (object reclamation).

okay so the main-character rule: after objinit runs once per object, the pool stops touching object contents. reinit after each pop (object allocation) and clear before each push (object reclamation) is on the caller β€” not the pool πŸ’€

🌈 SEE ALSO 🌈

xoxo, objpool_init(9) πŸ’œ source: ./include/linux Β· date: October 2026

πŸ“¦ where this page comes from