VM_PAGE_BITS(9)

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

πŸ’« vm_page_bits πŸ’«

okay so bestie, this is the VM_PAGE_BITS(9) manual page β€” Kernel Developer's Manual energy fr fr, and it's literally all about managing page clean and dirty bits ✨ it's giving low-level filesystem realness, and i'm obsessed 🫢


πŸ’– NAME πŸ’–

vm_page_bits, vm_page_set_validclean, vm_page_clear_dirty, vm_page_set_invalid, vm_page_zero_invalid, vm_page_is_valid, vm_page_test_dirty, vm_page_dirty, vm_page_undirty β€” manage page clean and dirty bits, periodt πŸ’…


✨ SYNOPSIS ✨

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

int
vm_page_bits(int base, int size);

void
vm_page_set_validclean(vm_page_t m, int base, int size);

void
vm_page_clear_dirty(vm_page_t m, int base, int size);

void
vm_page_set_invalid(vm_page_t m, int base, int size);

void
vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);

int
vm_page_is_valid(vm_page_t m, int base, int size);

void
vm_page_test_dirty(vm_page_t m);

void
vm_page_dirty(vm_page_t m);

void
vm_page_undirty(vm_page_t m);

like, these are the includes you need first πŸ‘† no cap, don't skip them πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so let's break these down one by one, bestie β€” each function is iconic in its own way 🌸

  • vm_page_bits() β€” calculates the bits representing the DEV_BSIZE range of bytes between base and size. the byte range is supposed to be within a single page, and if size is zero, no bits get set. that's it, that's the function πŸ’–
  • vm_page_set_validclean() β€” flags the byte range between base and size as <green>valid</green> and <mint>clean</mint>. the range is expected to be DEV_BSIZE aligned and no larger than PAGE_SIZE. heads up tho πŸ’€ if it's not properly aligned, any unaligned chunks of the DEV_BSIZE blocks at the beginning and end of the range get zeroed.

alsooo β€” if base is zero and size is one page, the modified bit in the page map is cleared, and the VPO_NOSYNC flag is cleared too. two for one, slay πŸŽ€

  • vm_page_clear_dirty() β€” clears the dirty bits within a page in the range between base and size. the bits representing the range are calculated by calling vm_page_bits(). so it's giving teamwork, love that for them 🫢
  • vm_page_set_invalid() β€” clears the bits in both the valid and dirty flags representing the DEV_BSIZE blocks between base and size in the page. the bits are calculated by calling vm_page_bits(). and as well as clearing the bits within the page, the generation number within the object holding the page gets incremented. main character energy, fr fr πŸ‘‘
  • vm_page_zero_invalid() β€” zeroes all of the blocks within the page that are currently flagged as invalid. if setvalid is TRUE, all of the valid bits within the page are set. easy peasy ✨
ngl in some cases β€” like NFS β€” the valid bits can't be set, because cache consistency has to be maintained 🧚 so like, it's not always a free-for-all, iykyk.
  • vm_page_is_valid() β€” checks to determine if all of the DEV_BSIZE blocks between base and size of the page are valid. lowkey a little quirky with the edge case: if size is zero and the page is entirely invalid, vm_page_is_valid() will return TRUE. in all other cases, a size of zero will return FALSE. so watch out for that πŸ’€
  • vm_page_test_dirty() β€” checks if a page has been modified via any of its physical maps, and if so, flags the entire page as dirty. vm_page_dirty() is called to modify the dirty bits. detective work but make it kernel 🌈
  • vm_page_dirty() β€” flags the entire page as dirty. it's expected that the page is not currently on the cache queue. like, don't do that, okay? πŸ™ˆ
  • vm_page_undirty() β€” clears all of the dirty bits in a page. clean slate, fresh start, we love a reset πŸ¦‹

πŸ’œ NOTES πŸ’œ

none of these functions are allowed to block. like, at all. blocking is not the vibe here, periodt πŸ›‘


πŸŽ€ AUTHORS πŸŽ€

this manual page was written by Chad David <davidc@acns.ab.ca>. slay, Chad πŸ’–


and that's the whole manual, bestie! this page is from the Debian distribution, dated December 1, 2001 πŸŽ€ so yeah, it's a little vintage but the facts are still facts πŸ’… ✨

πŸ“¦ where this page comes from