VM_MAP_WIRE(9)
π vm_map_wire β bestie's guide to pinning pages down (kernel developer's manual, section 9)
okay so real talk, this page is vm_map_wire and vm_map_unwire β the two functions that manage page wiring inside a virtual memory map. it's giving "i'm gonna make sure these pages cannot leave" energy and honestly? iconic. β¨
πΈ NAME πΈ
vm_map_wire, vm_map_unwire β manage page wiring within a virtual memory map π«Ά
π SYNOPSIS π
like always, you gotta bring the right headers to the party first, no cap:
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
then the functions themselves, here's the whole fit:
int
vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
int flags);
int
vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
int flags);
π¦ DESCRIPTION π¦
so vm_map_wire() is the main character here π
β its whole job is wiring up the pages in the range between start and end inside the map map. and what does "wired" even mean? it means those pages are locked into physical memory, and they may not be paged out as long as their wire count stays above zero. periodt. π
then vm_map_unwire() does the corresponding unwire operation β the reverse vibe, the undoing, the "okay you can breathe now" moment. π§
the flags argument is a bit mask, made of these flags right here:
- if the
VM_MAP_WIRE_USERflag is set, the function operates within user address space π - if the
VM_MAP_WIRE_HOLESOKflag is set, it may operate upon an arbitrary range within the address space of map π³οΈβ¨ - if you actually want a contiguous range, you should explicitly express your intent by specifying the
VM_MAP_WIRE_NOHOLESflag β say it with your chest, bestie π£
π IMPLEMENTATION NOTES π
both functions are gonna try to grab a lock on the map using vm_map_lock(9), and they hold onto it for the whole duration of the call. like, the entire time. π«°
and if they detect MAP_ENTRY_IN_TRANSITION, they'll call vm_map_unlock_and_wait(9) until the map becomes available again β just politely waiting in the group chat until it's their turn π
β οΈ important vibe check: the map could have changed during that window, because somebody else was holding it. so if you're consuming this interface, you should be checking for that condition using the return values down below. don't skip this, fr fr π
β RETURN VALUES β
vm_map_wire() and vm_map_unwire() have identical return values β twins, matching outfits, the whole thing π―
KERN_SUCCESSβ returned if all the pages within the range were [un]wired successfully π slayKERN_INVALID_ADDRESSβ returned otherwise: if the specified range was not valid, or if the map changed while theMAP_ENTRY_IN_TRANSITIONflag was set π©
π₯ SEE ALSO π₯
go read those too, iykyk π
π AUTHORS π
this manual page was written by Bruce M Simpson <bms@spc.org> β ty for your service king π«‘π
and that's the whole page bestie, no notes π
sign-off szn: this one came from Debian, dated July 19, 2003 β a whole vintage moment, honestly kinda nostalgic πβ¨ mwah, go wire some pages responsibly π¦π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms