pt_compute_best_pgsize(9)
π pt_compute_best_pgsize(9) β a Kernel API Manual moment β¨
okay so bestie, we're diving into the kernel API manual and honestly this one is a little gem π it lives in the Kernel API Manual and it's about picking the perfect page size for leaf entries. yes, we're matchmaking addresses now, it's giving main character energy π
β¨ NAME β¨
pt_compute_best_pgsize β Determine the best page size for leaf entries π¦
like literally, it's the function that looks at your addresses and goes "this is the page size for you, bestie" π
πΈ SYNOPSIS πΈ
unsigned int pt_compute_best_pgsize (pt_vaddr_t pgsz_bitmap , pt_vaddr_t
va , pt_vaddr_t last_va , pt_oaddr_t oa );
that's the whole signature, no cap, copy it exactly if you're typing it out π
π§ ARGUMENTS π§
pgsz_bitmapβ Permitted page sizes π« the little bitmap of what you're actually allowed to use, the vibe check for sizesvaβ Starting virtual address for the leaf entry π like where the leaf entry begins on the virtual sidelast_vaβ Last virtual address for the leaf entry, sets the max page size π₯ it's the upper bound bestie, it literally caps how big you can gooaβ Starting output address for the leaf entry π where the leaf entry starts on the output side
π DESCRIPTION π
So the whole gig: compute the largest page size for va, last_va, and oa together and return it in lg2 β¨
The largest page size depends on two things, and you gotta respect both:
- the format's supported page sizes at this level π (what the format will actually let you do)
- the relative alignment of the VA and OA addresses π¦ (whether these two are lined up enough for it to work)
and here's the important bit, so listen up π β 0 means the OA cannot be stored with the provided pgsz_bitmap. like, zero is the "nope, can't do it with these sizes" answer. it's the "not me, not today" of return values π
π SEE ALSO π
Kernel file ./drivers/iommu/generic_pt/pt_iter.h and its little friend group π«Ά:
pt_check_range(9)pt_index_to_va(9)pt_entry_fully_covered(9)pt_range_to_index(9)pt_range_to_end_index(9)pt_next_entry(9)for_each_pt_level_entry(9)pt_load_single_entry(9)pt_top_range(9)pt_all_range(9)pt_upper_range(9)pt_make_range(9)pt_init(9)pt_init_top(9)pt_descend(9)pt_walk_range(9)pt_range_slice(9)pt_top_memsize_lg2(9)PT_MAKE_LEVELS(9)
iykyk, that's the whole squad π
aaaand that's the page!! πΈ ily for reading all the way to the end, mwah π«Ά this iconic little number ships out of ./drivers/iommu/generic_pt, dated October 2026, and it answers to pt_compute_best_pgsize(9) β 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