drm_gpusvm_hmm_pfn_to_order(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gpusvm_hmm_pfn_to_order β€” drm_gpusvm_hmm_pfn_to_order(9) πŸ’…

okay so bestie, you're in the Kernel API Manual and today's main character is drm_gpusvm_hmm_pfn_to_order(9). she's a little function with one (1) job and she does it flawlessly. let's get into it 🫢


✨ NAME ✨

drm_gpusvm_hmm_pfn_to_order β€” literally just "Get the largest CPU mapping order." that's her whole brand. πŸŽ€


🌸 SYNOPSIS 🌸

unsigned int drm_gpusvm_hmm_pfn_to_order (unsigned long hmm_pfn ,
       unsigned long hmm_pfn_index , unsigned long npages );

look at her go. three args, one unsigned int back. iconic behavior tbh ⭐


πŸ¦‹ ARGUMENTS πŸ¦‹

  • hmm_pfn β€” the current hmm_pfn. that's the one you're looking at right now, bestie, the pfn of the moment πŸ’…
  • hmm_pfn_index β€” the index of the hmm_pfn within the pfn array. so like… where she sits in the lineup πŸ‘‘
  • npages β€” number of pages within the pfn array, i.e. the hmm range size. the whole squad's headcount fr fr πŸ”₯

πŸ’– DESCRIPTION πŸ’–

okay so here's the vibe. when you're looping over the pfn array, you want to be able to skip PFNs that have the same flags β€” like, say, when they belong to the same huge PTE β€” instead of crawling through them one by one like some kind of loser 😭

so what this function does: you hand her a given hmm_pfn, and she returns the largest order that will fit inside the CPU PTE. but β€” and this is the crucial part, do not skip this β€” she also accounts for the original hmm range boundaries. not me being thorough πŸ’…βœ¨

so the order she gives you is the biggest one that's still safe. no cap. no overstepping, no vibes-based off-by-one, just the correct alignment of "big as possible" and "still inside the range." 🧚


πŸŽ€ RETURN πŸŽ€

the largest order that will safely fit within the size of the hmm_pfn CPU PTE. that's it, that's the return value. safe, large, order. slay. 🌈


πŸ“ SEE ALSO πŸ“

so many friends!! the whole gpusvm friend group showed up for her 🫢 let's do the roll call:

Kernel file ./drivers/gpu/drm/drm_gpusvm.c Overview(9), Locking(9), Partial Unmapping of Ranges(9), Examples(9), npages_in_range(9), drm_gpusvm_notifier_find(9), drm_gpusvm_range_find(9), drm_gpusvm_notifier_invalidate(9), drm_gpusvm_init(9), to_drm_gpusvm_notifier(9), drm_gpusvm_notifier_insert(9), drm_gpusvm_notifier_remove(9), drm_gpusvm_fini(9), drm_gpusvm_notifier_alloc(9), drm_gpusvm_notifier_free(9), to_drm_gpusvm_range(9), drm_gpusvm_range_insert(9), __drm_gpusvm_range_remove(9), drm_gpusvm_range_alloc(9), drm_gpusvm_check_pages(9), drm_gpusvm_scan_mm(9), drm_gpusvm_range_chunk_size(9), drm_gpusvm_driver_lock_held(9), drm_gpusvm_find_vma_start(9), drm_gpusvm_range_find_or_insert(9), __drm_gpusvm_unmap_pages(9), __drm_gpusvm_free_pages(9), drm_gpusvm_free_pages(9), drm_gpusvm_range_remove(9), drm_gpusvm_range_get(9), drm_gpusvm_range_destroy(9), drm_gpusvm_range_put(9), drm_gpusvm_pages_valid(9), drm_gpusvm_pages_valid_unlocked(9), drm_gpusvm_get_pages(9), drm_gpusvm_unmap_pages(9), drm_gpusvm_range_evict(9), drm_gpusvm_has_mapping(9), drm_gpusvm_range_set_unmapped(9)

like I said. the whole friend group. πŸ’€


ngl bestie the SEE ALSO list alone is giving "group project where everyone actually showed up." proud of them. πŸ₯Ή

and that's the page!! she lives in ./drivers/gpu/drm, dated October 2026, and her name is drm_gpusvm_hmm_pfn_to_order(9) β€” go forth, skip those same-flag PFNs, and stay inside your range boundaries 😘✨🌸

πŸ“¦ where this page comes from