VM_PAGE_ALLOC(9)
okay so bestie, welcome to vm_page_alloc(9) from the Kernel Developer's Manual π. this page is literally about allocating a page for a vm_object, and it's giving main character energy in the VM subsystem. no cap, every flag matters, so let's get into it. β¨
β¨ NAME β¨
vm_page_alloc β allocate a page for a vm_object
π¦ SYNOPSIS π¦
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
vm_page_t
vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req);
πΈ DESCRIPTION πΈ
so the vm_page_alloc() function allocates a page at pindex within object. it's assumed that a page has not already been allocated at pindex. the page that comes back is inserted into the object, unless VM_ALLOC_NOOBJ is specified in the req. periodt. π
also, huge vibe check: vm_page_alloc() will not sleep. like, it's not gonna catch feelings or block, it just does its thing. iconic. π
its arguments are:
objectβ the VM object to allocate the page for. bestie, the object must be locked ifVM_ALLOC_NOOBJis not specified. no lock, no talk. πpindexβ the index into the object at which the page should be inserted. it's literally the spot in the lineup. πreqβ the bitwise-inclusive OR of a class and any optional flags indicating how the page should be allocated. so you're mixing and matching, but there are rules.
exactly one of the following classes must be specified:
VM_ALLOC_NORMALβ the page should be allocated with no special treatment. just a regular degular page, no drama. β¨VM_ALLOC_SYSTEMβ the page can be allocated if the cache is empty and the free page count is above the interrupt reserved water mark. this flag should be used only when the system really needs the page. like, emergency-level need, not just a want. π¨VM_ALLOC_INTERRUPTβvm_page_alloc()is being called during an interrupt. a page will be returned successfully if the free page count is greater than zero. interrupt mode activated, no cap. β‘
the optional flags are:
VM_ALLOC_NOBUSYβ the returned page will not be exclusive busy.VM_ALLOC_NODUMPβ the returned page will not be included in any kernel core dumps regardless of whether or not it is mapped in to KVA. so it's lowkey invisible to dumps. πVM_ALLOC_NOOBJβ do not associate the allocated page with a vm object. theobjectargument is ignored. it's giving independent page energy. π¦VM_ALLOC_SBUSYβ the returned page will be shared busy.VM_ALLOC_WIREDβ the returned page will be wired. it's locked in, literally. πVM_ALLOC_ZEROβ indicate a preference for a pre-zeroed page. there is no guarantee that the returned page will be zeroed, but it will have thePG_ZEROflag set if it is zeroed. so like, manifesting a zeroed page, but the universe might say no. π―οΈ
π RETURN VALUES π
the vm_page_t that was allocated is returned if successful; otherwise, NULL is returned. so either you get your page or you get nothing, and honestly that's the risk you take. π
π NOTES π
the pager process is always upgraded to VM_ALLOC_SYSTEM unless VM_ALLOC_INTERRUPT is set. so yeah, pager stays getting promoted, iykyk. π
π AUTHORS π
this manual page was written by Chad David <davidc@acns.ab.ca>. iconic of him, fr fr. π«Ά
and that's the whole vibe. this page came from Debian, dated November 16, 2016 β so it's a classic, but still slaying. bye bestie! ππ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms