pt_compute_best_pgsize(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 sizes
  • va β€” Starting virtual address for the leaf entry 🌈 like where the leaf entry begins on the virtual side
  • last_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 go
  • oa β€” 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:

  1. the format's supported page sizes at this level πŸŽ€ (what the format will actually let you do)
  2. 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 🫢:

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