folio_pte_batch(9)
π 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 frmax_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:
ptepmust map any page of the folio.max_nrmust 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
- 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