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
- 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) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved
- Copyright (c) 2013 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms