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: both PGA_REFERENCED and PGA_WRITEABLE bits 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