VM_MAP_WIRE(9)
β¨ VM_MAP_WIRE β kernel dev manual, section 9 β¨
okay bestie, welcome to the kernel developer's manual for VM_MAP_WIRE π
this is the page about managing page wiring inside a virtual memory map, and yes it's giving very serious grown-up energy, but we're gonna get through it together π«Ά
πΈ NAME πΈ
vm_map_wire, vm_map_unwire β manage page wiring within a virtual memory map π
π SYNOPSIS π
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
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);
like, there they are. two little functions. iconic behavior honestly π¦
β¨ DESCRIPTION β¨
okay so. vm_map_wire() is the function in charge of wiring pages in the range between start and end inside the map map. and what does "wiring" even mean, you ask? it means those pages get locked into physical memory π and they may not be paged out for as long as their wire count stays above zero. no cap. they're staying put.
vm_map_unwire() does the corresponding unwire operation β it's the undo button, the "okay you can go now bestie" of the pair π
the flags argument is a bit mask, and it's made up of the following flags:
- 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 ofmapπ³οΈ - If a contiguous range is desired, callers should explicitly express their intent by specifying the
VM_MAP_WIRE_NOHOLESflag β
π§ IMPLEMENTATION NOTES π§
both functions will attempt to acquire a lock on the map using vm_map_lock(9) and hold it for the duration of the call. and if they detect MAP_ENTRY_IN_TRANSITION, they will call vm_map_unlock_and_wait(9) until the map becomes available again. like they're just patiently waiting their turn in the group chat, no drama π
but here's the thing β the map could have changed during this window, because it was held by another consumer π so consumers of this interface should check for this condition using the return values below. please check them. don't be that person.
π RETURN VALUES π
vm_map_wire() and vm_map_unwire() have identical return values, they're matching, they're twins, they ate π―
- the functions return
KERN_SUCCESSif all pages within the range were [un]wired successfully π - otherwise, if the specified range was not valid, or if the map changed while the
MAP_ENTRY_IN_TRANSITIONflag was set,KERN_INVALID_ADDRESSis returned π
π SEE ALSO π
π AUTHORS π
this manual page was written by Bruce M Simpson <bms@spc.org>. shoutout to Bruce, fr fr π«Ά
and that's the whole page bestie!! this one shipped with Debian and it's dated July 19, 2003 β vintage, lowkey a classic, and we love that for it πΈβ¨π
π¦ 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) 2003 Bruce M Simpson <bms@spc.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms