VM_MAP_FINDSPACE(9)

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

✨ VM_MAP_FINDSPACE(9) ✨

okay bestie, so this is a kernel developer's manual page β€” it's filed under VM_MAP_FINDSPACE(9) in section 9, which is where all the kernel-functions live. Sit down, grab a strawberry πŸ“, and let's get into it.


πŸ’– NAME πŸ’–

vm_map_findspace β€” literally just find a free region within a map, no cap


πŸŽ€ SYNOPSIS πŸŽ€

first, include the vibe:

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

then the actual function:

int
vm_map_findspace(vm_map_t map, vm_offset_t start, vm_size_t length,
    vm_offset_t *addr);

🌸 DESCRIPTION 🌸

so vm_map_findspace() is out here doing the absolute most: it attempts to find a region inside map that's got enough room for an object of size length at the address addr. that's it. that's the whole job. she's a finder. an icon. πŸ‘‘


πŸ¦‹ IMPLEMENTATION NOTES πŸ¦‹

okay this part matters, bestie β€” listen up:

  • it is the caller's responsibility to get a lock on the map first, using vm_map_lock(9), before calling this function. do not skip this. the lock is not a vibe, it's a requirement. πŸ”’

also:

  • this routine may call pmap_growkernel(9) to grow the kernel's address space β€” but if and only if the mapping is being made within the kernel address space, and if insufficient space remains in the kernel_map.

like, both conditions. it's giving "conditional queen". πŸ’…


πŸ”₯ RETURN VALUES πŸ”₯

  • returns the value 0 if it works out β€” slay β€” and in that case *addr will contain the first virtual address in the found region
  • otherwise, the value 1 is returned πŸ’€ (no *addr prize for you)

🌈 SEE ALSO 🌈

a whole little friend group fr fr 🫢


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Bruce M Simpson <bms@spc.org> β€” ty king 🫑


ngl the one thing to remember: lock the map first with vm_map_lock(9). everything else is just finding space and returning 0 or 1. periodt. πŸ’œ

and that's the whole page, bestie β€” from the Debian crew, dated July 19, 2003, living in section 9 as VM_MAP_FINDSPACE(9). mwah πŸ’‹ go find some space πŸ¦‹βœ¨

πŸ“¦ where this page comes from