VM_PAGE_INSERT(9)
π VM_PAGE_INSERT(9) β add/remove page from an object π
okay so bestie, this is a page from the Kernel Developer's Manual β section 9, the kernel-dev corner of the universe β and it's literally about vm_page_insert and vm_page_remove. no cap, it's giving βpage bookkeeping main character energy.β π
πΈ NAME πΈ
vm_page_insert,vm_page_removeβ add/remove page from an object
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
void
vm_page_insert(vm_page_t m, vm_object_t object, vm_pindex_t pindex);
void
vm_page_remove(vm_page_t m);
π¦ DESCRIPTION π¦
vm_page_insert() adds a page to the given object at the given index. lowkey important: the page gets added to both the VM page hash table and the object's list of pages, but the hardware page tables are not updated. if it's a user page, it will be faulted in when it's accessed. if the page is a kernel page, the caller is expected to handle adding the page to the kernel's pmap. iykyk. β¨
If PG_WRITEABLE is set in the page's flags, then OBJ_WRITEABLE and OBJ_MIGHTBEDIRTY are set in the object's flags. the way that flag propagation is doing its thing. π
vm_page_remove() removes the given page from its object, and from the VM page hash table. But bestie, listen: the page must be busy prior to this call, or the system will panic. π
no cap, that panic warning is real β page busy first, or it's giving kernel meltdown. π
The pmap entry for the page is not removed by this function. not me expecting it to clean up everything β it literally doesn't. π
The arguments to vm_page_insert() are:
mβ the page to add to the object.objectβ the object the page should be added to.pindexβ the index into the object the page should be at.
The arguments to vm_page_remove() are:
mβ the page to remove.
πΈ IMPLEMENTATION NOTES πΈ
The index of a page in a VM object is the byte index into the same object truncated to a page boundary. so it's literally the byte index, but chopped down to the page boundary. π
For example, if the page size is 4096 bytes, and the address in the object is 81944, the page index is 20. yes, bestie, that math is the vibe. β¨
π AUTHORS π
This manual page was written by Chad David <davidc@acns.ab.ca>. iconic. π
π cute sign-off: this page is Debian, dated July 17, 2001, and it's literally VM_PAGE_INSERT(9). mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms