pfnmap_setup_cachemode(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– pfnmap_setup_cachemode(9) πŸ’–

okay bestie, welcome to the Kernel API Manual β€” this one's from the <linux/pgtable.h> girlies and it's lowkey so useful. sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

pfnmap_setup_cachemode β€” sets up the cachemode in the pgprot for a pfn range. that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

int pfnmap_setup_cachemode (unsigned long pfn , unsigned long size ,
pgprot_t *prot );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • pfn β€” the start of the pfn range. like, where the range begins, bestie. πŸ“
  • size β€” the size of the pfn range, and this one's in bytes so don't come at it with pages. ngl this trips people up.
  • prot β€” the pgprot to modify. it's a pointer, so yeah, we're editing it in place. πŸ’…

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea: this function looks up the cachemode for the pfn range starting at pfn with the size size, and stores it in prot β€” leaving the other data in prot unchanged. literally just the cachemode part. don't panic. 🫢

what that means is: a hardware implementation gets fine-grained control of memory cache behavior down to page level granularity. iconic. and if there's no hardware implementation? this function does nothing. yeah. it's a whole ✨no-op✨ moment. πŸ’€

currently there's only one implementation for this β€” the x86 Page Attribute Table (PAT). see Documentation/arch/x86/pat.rst for more details. iykyk. πŸ“š

⚠️ also she can fail β€” specifically if the pfn range spans pfns that require differing cachemodes. so heads up. 😭

if the pfn range was previously verified to have a single cachemode, it's sufficient to query only a single pfn. the assumption is that this is the case for drivers using the vmf_insert_pfn*() interface. fr fr, that's the intended use case.

Returns 0 on success and -EINVAL on error. that's it, that's the whole return value situation. 🌈


⭐ SEE ALSO ⭐

Kernel file ./include/linux/pgtable.h plus this whole bestie lineup:


mwah πŸ’‹ that's the page! big slay to the <purple>./include/linux</purple> crew, this one's dated October 2026, and remember β€” cache behavior is a lifestyle, not a phase. πŸ§šπŸ’œ

πŸ“¦ where this page comes from