VM_PAGE_AFLAG(9)
β¨ VM_PAGE_AFLAG(9) β¨
okay so bestie, this is a page from the Kernel Developer's Manual β it's VM_PAGE_AFLAG, and it's all about poking at a page's atomic flags. no cap, it's short and it's sweet and it's lowkey iconic. let's get into it π
π NAME π
vm_page_aflag_clear, vm_page_aflag_set, vm_page_reference β change page atomic flags
like... that's literally the whole vibe. we're changing page atomic flags. periodt.
πΈ SYNOPSIS πΈ
first you gotta pull in the headers, obvi:
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
and then here are the three functions, exactly as they live:
void
vm_page_aflag_clear(vm_page_t m, uint8_t bits);
void
vm_page_aflag_set(vm_page_t m, uint8_t bits);
void
vm_page_reference(vm_page_t m);
three little functions, all returning void, all taking a vm_page_t. it's giving "small but mighty" π¦
π DESCRIPTION π
okay bestie, here's the tea on each one:
vm_page_aflag_clear()β atomically clears the specified bits on the page's aflags. bye bits πvm_page_aflag_set()β atomically sets the specified bits on the page's aflags. hello bits β¨vm_page_reference(m)β this one is literally the exact same thing as
vm_page_aflag_set(m, PGA_REFERENCED);
and fr fr, it's the recommended way to mark the page as referenced from third-party kernel modules. so if you're a third-party kernel module, use this one, don't be doing it the long way, iykyk π«Ά
now the part that's genuinely so good: these functions neither block nor require any locks to be held around the calls for correctness. like, no locking drama, no blocking, just vibes. main character energy honestly π₯
the function arguments are:
mβ the page whose aflags are updated. that's your girl.bitsβ the bits that are set or cleared on the page's flags.
and here are the aflags you can set or clear, bestie:
PGA_REFERENCEDβ this bit may be set to indicate that the page has been recently accessed. for instance,pmap(9)sets this bit to reflect the accessed attribute of the page mapping, which is typically updated by the processor's memory management unit on the page access. so like, the MMU clocked her visiting, and this bit is the receipt π§PGA_WRITEABLEβ a writeable mapping for the page may exist. that's it, that's the whole description.
β οΈ heads up bestie: bothPGA_REFERENCEDandPGA_WRITEABLEbits are only valid for the managed pages. not managed? not valid. don't come for me, that's just what the page says π
π AUTHORS π
this manual page was written by Chad David <davidc@acns.ab.ca>. giving credit where credit is due, we love to see it π
and that's the whole page, bestie! this lil cutie came from Debian, dated August 31, 2011 πβ¨ go forth and set your atomic flags, you've absolutely got this π
π¦ 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