VM_PAGE_INSERT(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– 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