drm_gpusvm_hmm_pfn_to_order(9)
π
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 currenthmm_pfn. that's the one you're looking at right now, bestie, the pfn of the moment πhmm_pfn_indexβ the index of thehmm_pfnwithin 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
- 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