folio_pte_batch(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… folio_pte_batch(9) β€” a Kernel API Manual moment

okay so bestie, welcome to the Kernel API Manual page for folio_pte_batch, and honestly? it's giving "small function, big responsibility" and i'm kind of obsessed πŸŽ€


✨ NAME ✨

folio_pte_batch β€” detect a PTE batch for a large folio πŸ’–


🌸 SYNOPSIS 🌸

unsigned int folio_pte_batch (struct folio *folio , pte_t *ptep , pte_t
pte , unsigned int max_nr );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • folio β€” the large folio you're detecting a PTE batch for, queen πŸ‘‘
  • ptep β€” page table pointer for the first entry, like your pointer to the starting line 🫢
  • pte β€” the page table entry for the first page, fr fr
  • max_nr β€” the maximum number of table entries to consider. it's the limit, the boundary, the "don't get carried away" energy πŸ’€

πŸ’œ DESCRIPTION πŸ’œ

so this one is a simplified variant of folio_pte_batch_flags β€” like, it's the lowkey version of its sibling, no cap ✨

what it does: it detects a PTE batch β€” that means consecutive (present) PTEs that map consecutive pages of the same large folio, all within a single VMA and a single page table. one folio, one VMA, one page table, all in a cute little row 🌈

and here's the vibe check on the bits: all PTEs inside a PTE batch have the same PTE bits set, excluding the PFN, the accessed bit, the writable bit, the dirt-bit and the soft-dirty bit. so those ones are the exceptions, everyone else matches πŸ’…

now the rules, and they matter:

ptep must map any page of the folio. max_nr must be at least one, and it must be limited by the caller so that scanning cannot exceed a single VMA and a single page table. don't let it wander off into other VMAs, bestie, that's not the move 😭

⭐ RETURN ⭐

it returns the number of table entries in the batch β€” i.e. how many entries slayed their way into this group πŸŽ‰


πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./mm/util.c, plus the whole friend group:

kfree_const(9), __kmemdup_nul(9), kstrdup(9), kstrdup_const(9), kstrndup(9), kmemdup(9), kmemdup_array(9), kvmemdup(9), kmemdup_nul(9), memdup_user(9), vmemdup_user(9), strndup_user(9), memdup_user_nul(9), randomize_page(9), __account_locked_vm(9), account_locked_vm(9), __vmalloc_array(9), vmalloc_array(9), __vcalloc(9), vcalloc(9), folio_mapping(9), folio_copy(9), get_cmdline(9), mem_dump_obj(9), compat_set_desc_from_vma(9), __compat_vma_mmap(9), compat_vma_mmap(9), snapshot_page(9), mmap_action_prepare(9), mmap_action_complete(9), page_range_contiguous(9)


and that's the page, bestie 🫢 this one came from ./mm in October 2026 β€” so if you ever need to cite it, that's the receipt, periodt πŸ’–πŸŽ€

πŸ“¦ where this page comes from