objpool_init(9)
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 (viakmallocorvmalloc). 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 π
- Kernel file
./include/linux/objpool.hβ plusstruct objpool_slot(9),struct objpool_head(9),objpool_pop(9),objpool_push(9),objpool_drop(9),objpool_free(9),objpool_fini(9)π
xoxo, objpool_init(9) π source: ./include/linux Β· date: October 2026
π¦ 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