folio_pte_batch_flags(9)
π folio_pte_batch_flags β a Kernel API Manual moment π
okay so bestie, buckle up, because we're diving into folio_pte_batch_flags(9) from the Kernel API Manual and honestly? it's giving "niche but iconic." π
β¨ NAME β¨
folio_pte_batch_flags β detect a PTE batch for a large folio π¦
πΈ SYNOPSIS πΈ
unsigned int folio_pte_batch_flags (struct folio *folio , struct
vm_area_struct *vma , pte_t *ptep , pte_t *ptentp , unsigned int max_nr
, fpb_t flags );
like, that's the whole vibe. six args. she's thorough. π
π ARGUMENTS π
folioβ the large folio we're detecting a PTE batch for. the main character, lowkey. πvmaβ the VMA. heads up bestie: this is only relevant withFPB_MERGE_WRITEβ otherwise it can beNULLand nobody will be mad. πptepβ page table pointer for the first entry. βthe starting point, the origin story. βptentpβ pointer to a COPY of the first page table entry, and this function updates its flags based onflagsif appropriate. please note the bold COPY, this matters so much. πmax_nrβ the maximum number of table entries to consider. the limit, the boundary, the "bestie no further." πflagsβ flags that modify the PTE batch semantics. the personality settings, fr fr. π
π¦ DESCRIPTION π¦
So what does she actually do? Detect a PTE batch: consecutive (present) PTEs that map consecutive pages of the same large folio in a single VMA and a single page table. that's the whole assignment and she ate. π₯
Every PTE inside a PTE batch has the same PTE bits set β excluding the PFN, the accessed bit, the writable bit, the dirty bit (unless FPB_RESPECT_DIRTY is set) and the soft-dirty bit (unless FPB_RESPECT_SOFT_DIRTY is set). so like, those bits are the exceptions, not the rule. π
ptep must map any page of the folio. max_nr must be at least one, and it must be limited by the caller so scanning can't exceed a single VMA and a single page table. no crossing the line, we stay in our lane. β¨
Depending on the FPB_MERGE_* flags, the pte stored at ptentp will be updated β and it is crucial that a pointer to a COPY of the first page table entry, obtained through ptep_get, is provided as ptentp. crucial! capital-C crucial! don't skip this step, i'm literally begging. π
This function will be inlined to optimize based on the input parameters; consider using folio_pte_batch instead if applicable. she's inline-flexible like that. π§
π RETURN π
the number of table entries in the batch. that's it, that's the answer. π«Ά
β SEE ALSO β
Kernel file ./mm/internal.h and the whole friend group:
pte_move_swp_offset(9)pte_next_swp_offset(9)swap_pte_batch(9)sync_with_folio_pmd_zap(9)folio_evictable(9)vma_filebacked_address(9)vma_anon_address(9)
ok real talk bestie: get the ptentp COPY right. it's the one thing this page yells at you about, and honestly? she's right. π
and that's the page!! source/version is ./mm and the date on this beauty is October 2026 β so yeah, she's from the future and she's thriving. mwah, go read your page tables. ππβ¨
π¦ 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