VM_PAGE_GRAB(9)

πŸ’– vm_page_grab β€” returns a page from an object πŸ’–

okay bestie, so we're in the Kernel Developer's Manual, section 9, and the star of the show is vm_page_grab. she's giving page-fetching main character energy and honestly? obsessed. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

first you gotta include the goods, no skipping:

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

vm_page_t
vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags);

🌸 DESCRIPTION 🌸

so like. the vm_page_grab() function hands you back the page sitting at pindex inside the given object. that's the whole vibe. πŸŽ€

now the plot twist: if that page already exists and it's busy, vm_page_grab() will literally sleep while it waits for the page to free up. no cap, it just naps. 😴 and if the page doesn't exist at all? don't worry bestie, it gets allocated for you. either way the function sleeps until the allocation request can actually be satisfied. she's patient like that.

the way this works though β€” > the function requires the object to be locked on entry, and it returns with the object locked. πŸ”’

and if vm_page_grab() sleeps for any reason? the object lock gets temporarily dropped. just a heads up so you're not out here surprised. πŸ™ˆ

vm_page_grab() supports all of the flags that vm_page_alloc(9) supports β€” yes, all of them, she's generous. plus, on top of those, she adds one extra special flag:

  • VM_ALLOC_IGN_SBUSY β€” when you're waiting for the busy state of the existing page to drain, this makes it only test for exclusive busy. it ignores the shared busy counter entirely. periodt. πŸ’…

πŸ”₯ RETURN VALUES πŸ”₯

the vm_page_grab() always returns the page. always. she's not out here ghosting you, she shows up every single time. πŸ’–


🌈 SEE ALSO 🌈


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Chad David <davidc@acns.ab.ca>. thank you chad, icon behaviour fr fr 🫢


okay that's the whole thing bestie, you're basically a kernel dev now, no big deal πŸ’…βœ¨

this page came from the Debian crew, dated August 23, 2013 β€” so it's a lil vintage but still absolutely slaying. mwah. πŸ’œ

πŸ“¦ where this page comes from