account_locked_vm(9)
π account_locked_vm(9) β from the Kernel API Manual, bestie π«Ά
okay so bestie, real talk: this is account_locked_vm(9) out of the Linux Kernel API Manual, and it's lowkey one of those tiny functions that does one thing and does it slay. it's the little bookkeeper that keeps an mm's locked_vm counter honest. let me walk you through it π
β¨ NAME β¨
account_locked_vm β the girlie that accounts locked pages to an mm's locked_vm π
πΈ SYNOPSIS πΈ
int account_locked_vm (struct mm_struct *mm , unsigned long pages , bool inc );
like, that's the whole glow-up right there. three args, one int return, periodt π
π ARGUMENTS π
mmβ the mm you're accounting against, and bestie she may beNULL. yes,NULLis a valid vibe here.pagesβ how many pages we're accounting. the number. the amount. the quantity.incβtrueif the pages should be considered positive,falseif not. so like, are we adding to the counter or taking away from it? that's the whole question π¦
π DESCRIPTION π
okay so the one thing you NEED to know: this function assumes a non-NULL mm is valid β meaning it's got at least one reference on it. no cap, that's the contract. if mm is non-NULL and you handed it garbage, that's on you, not on her π
π₯ RETURN π₯
0β on success, or ifmmisNULL. icon behaviour honestly.NULLmm just gets a chill0and nobody's upset β¨-ENOMEMβ ifRLIMIT_MEMLOCKwould be exceeded. that's the limit saying "ma'am, no" π
π¦ SEE ALSO π¦
kernel file: ./mm/util.c
and the whole friend group y'all should check out:
kfree_const(9)__kmemdup_nul(9)kstrdup(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kmemdup_array(9)kvmemdup(9)kmemdup_nul(9)memdup_user(9)vmemdup_user(9)strndup_user(9)memdup_user_nul(9)randomize_page(9)__account_locked_vm(9)__vmalloc_array(9)vmalloc_array(9)__vcalloc(9)vcalloc(9)folio_mapping(9)folio_copy(9)get_cmdline(9)mem_dump_obj(9)compat_set_desc_from_vma(9)__compat_vma_mmap(9)compat_vma_mmap(9)snapshot_page(9)mmap_action_prepare(9)mmap_action_complete(9)folio_pte_batch(9)page_range_contiguous(9)
lowkey reminder bestie:-ENOMEMisn't a bug, it'sRLIMIT_MEMLOCKdoing its job. respect the limit π«Ά
and that's the tea β this one lives in ./mm and it's dated October 2026 β catch you in the next release, mwah ππβ¨
π¦ 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