VM_MAP_SYNC(9)

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

πŸ’– VM_MAP_SYNC(9) πŸ’–

okay so bestie, this is a page from the Kernel Developer's Manual β€” yes, that one β€” and it's all about vm_map_sync, the little function that pushes your dirty pages home to their pager. ngl it's a short one but it's giving very important ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

first things first, you gotta include these, no skipping:

#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>

int
vm_map_sync(vm_map_t map, vm_offset_t start, vm_offset_t end,
    boolean_t syncio, boolean_t invalidate);

look at that signature. six whole arguments. main character energy fr πŸ’…


🌸 DESCRIPTION 🌸

so vm_map_sync() does The Thing: it forces any dirty cached pages in the range from start to end inside the map to get pushed to their underlying pager. like, go on, get out of the cache, your pager is waiting 🫢

if syncio is TRUE, those dirty pages get written synchronously. no vibes-based fire-and-forget, they go now.

if invalidate is TRUE, any cached pages are also freed. bye bestie πŸ‘‹

okay this is the serious part, pay attention: the range you pass in must be contiguous β€” it MUST NOT contain holes. and it MUST NOT contain any sub-map entries. like, not even one. periodt. πŸ’€

πŸ‘‘ RETURN VALUES πŸ‘‘

vm_map_sync() returns KERN_SUCCESS if it worked. slay. πŸŽ€

otherwise, here's the breakdown:

  • KERN_INVALID_ADDRESS β€” returned if the function hit a sub-map entry. rude of it, honestly 😭
  • KERN_INVALID_ARGUMENT β€” returned if the function found a hole in the region you gave it, or if an entry couldn't be found for the given start address. like it literally could not find it, no cap.

🌈 SEE ALSO 🌈

go read that one too, iykyk ✨


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Bruce M Simpson <bms@spc.org> β€” absolute icon, we stan πŸ‘‘


that's the whole page bestie πŸ§šπŸ’– this beauty came from the Debian edition of the Kernel Developer's Manual, dated July 9, 2011 β€” a vintage. and yes, the header says VM_MAP_SYNC(9) and the footer says VM_MAP_SYNC(9) again because consistency is a vibe β­πŸ“

πŸ“¦ where this page comes from