VM_PAGE_FREE(9)
π VM_PAGE_FREE(9) π
okay bestie, welcome to the Kernel Developer's Manual β¨ this one's all about freeing a page, and it's lowkey iconic.
πΈ NAME πΈ
vm_page_free, vm_page_free_toq, vm_page_free_zero, vm_page_try_to_free β free a page π¦
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
void
vm_page_free(vm_page_t m);
void
vm_page_free_toq(vm_page_t m);
void
vm_page_free_zero(vm_page_t m);
int
vm_page_try_to_free(vm_page_t m);
π DESCRIPTION π
so the way this works is: vm_page_free_toq() moves a page into the free queue and disassociates it from its object. simple. but bestie, if the page is held, wired, already free, or its busy count is not zero, the system will panic π like, full-on panic. not the vibe.
also, if the PG_ZERO flag is set on the page, it gets placed at the end of the free queue; otherwise it goes at the front. front row seats for the non-zero ones ig β¨
and here's a fun one: if the page's object is of type OBJT_VNODE and it's the last page associated with the object, the underlying vnode may be freed. not me freeing the vnode as a lil treat π
now, vm_page_free() and vm_page_free_zero() both call vm_page_free_toq() to actually do the freeing β but they don't roll up looking the same. vm_page_free_zero() sets the PG_ZERO flag and vm_page_free() clears the PG_ZERO flag prior to the call to vm_page_free_toq(). two girlies, two paths, one destination π
and then there's vm_page_try_to_free(), which is the careful one. it verifies that the page is not held, wired, busy or dirty, and if all that checks out, it marks the page as busy, drops any protection that may be set on the page, and frees it. vibe check passed, page deleted, periodt π₯
π RETURN VALUES π
vm_page_try_to_free() returns 1 if it is able to free the page; otherwise, 0 is returned. yes/no, slay/flop, that's the whole story π
π«Ά SEE ALSO π«Ά
π AUTHORS π
This manual page was written by Chad David <davidc@acns.ab.ca>. ty bestie π«Ά
okay that's the whole page, no notes, you're gonna do great π
and that's a wrap, angel π§ this cutie came to you from the Debian distribution, dated July 24, 2001 β yeah it's vintage but it still ate, fr fr. VM_PAGE_FREE(9), signing off π
β¨
π¦ 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms