folio_pte_batch_flags(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 with FPB_MERGE_WRITE β€” otherwise it can be NULL and 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 on flags if 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:


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