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