dmem_cgroup_try_charge(9)
π dmem_cgroup_try_charge(9) π
okay so bestie, welcome to the Kernel API Manual β this one's about the kernel's dmem cgroup stuff, and honestly it's giving "let me try to charge this allocation and see if the region says yes" energy. sit down, grab a matcha π, we're doing this.
β¨ NAME β¨
dmem_cgroup_try_charge β try charging a new allocation to a region. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
int dmem_cgroup_try_charge (struct dmem_cgroup_region *region , u64 size
, struct dmem_cgroup_pool_state **ret_pool , struct
dmem_cgroup_pool_state **ret_limit_pool );
like, copy this exactly pls, no cap, the compiler is not forgiving π
π¦ ARGUMENTS π¦
regionβ the dmem region you're charging. your main character π«Άsizeβ how many bytes you're charging. in bytes, bestie, bytes. π₯ret_poolβ on a successful allocation, this gets set to the pool that actually got charged. so you know who took the tab πret_limit_poolβ on a failed allocation, this is the limiting pool. the one that said "not today" π
π DESCRIPTION π
so this function charges the region region for a size of size bytes. that's the whole bit. β
if the function succeeds, ret_pool is set β and here's the important part, so listen up: that pool must be passed to dmem_cgroup_uncharge when you're undoing the allocation. don't just vibe off into the sunset and forget it, fr fr π§
when this function fails with -EAGAIN and ret_limit_pool is non-null, it gets set to the pool for which the limit is hit. like, it literally tells you which pool is the problem π€ super useful β you can use it for eviction as the argument to dmem_cgroup_evict_valuable. this reference must be freed with dmem_cgroup_pool_state_put. yes, must. not "should". we said what we said. π―
okay quick recap because I know you're multitasking: success =ret_pool, and please actually uncharge it later.-EAGAIN+ non-nullret_limit_pool= the limiting pool, and please actually put it later. two different refs, two different cleanups. iykyk π
π RETURN π
0on success β iconic, we love a zero β¨-EAGAINon hitting a limit β the limit said nah π- or a negative errno on failure β some other little gremlin went wrong π
π SEE ALSO π
- kernel file
./kernel/cgroup/dmem.cβ go read the source, it's right there π dmem_cgroup_state_evict_valuable(9)dmem_cgroup_unregister_region(9)dmem_cgroup_register_region(9)dmem_cgroup_pool_state_put(9)dmem_cgroup_uncharge(9)dmem_cgroup_below_min(9)dmem_cgroup_below_low(9)dmem_cgroup_get_common_ancestor(9)
aaaand that's the page, bestie! this one lives over in ./kernel/cgroup and the version we're looking at is dated October 2026 β so like, cosy little kernel-api-manual moment from the future. slay ππβ¨
π¦ 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