pfnmap_setup_cachemode(9)
π 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:
lazy_mmu_mode_enable(9)lazy_mmu_mode_disable(9)__task_lazy_mmu_mode_pause(9)lazy_mmu_mode_pause(9)__task_lazy_mmu_mode_resume(9)lazy_mmu_mode_resume(9)pte_batch_hint(9)set_ptes(9)clear_young_dirty_ptes(9)get_and_clear_full_ptes(9)get_and_clear_ptes(9)clear_full_ptes(9)clear_ptes(9)clear_nonpresent_ptes(9)ptep_try_set(9)flush_tlb_before_set(9)wrprotect_ptes(9)clear_flush_young_ptes(9)test_and_clear_young_ptes(9)modify_prot_start_ptes(9)modify_prot_commit_ptes(9)pfnmap_track(9)pfnmap_untrack(9)pfnmap_setup_cachemode_pfn(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms