migrate_device_range(9)
π migrate_device_range(9) β the kernel API glow-up
okay so bestie, welcome to the Kernel API Manual page for migrate_device_range β yes that's the whole manual name, we're being official today π
β¨ NAME β¨
migrate_device_range β migrate device private pfns to normal memory. literally moving your pages back to the CPU side of the house, no cap π
πΈ SYNOPSIS πΈ
int migrate_device_range (unsigned long *src_pfns , unsigned long start
, unsigned long npages );
π¦ ARGUMENTS π¦
src_pfnsβ an array big enough to hold the migrating source device private pfns. like, big enough, bestie, pls don't skimp on the sizing πstartβ the starting pfn in the range to migrate. where the party starts πnpagesβ how many pages we're migrating. the headcount, if you will π
π₯ DESCRIPTION π₯
migrate_vma_setup is similar in concept to migrate_vma_setup except that instead of looking up pages based on virtual address mappings, a range of device pfns that should be migrated to system memory is used instead. (yes, the original says migrate_vma_setup twice β icon behaviour, we don't question it π)
So this is the moment when a driver needs to free device memory but genuinely doesn't know the virtual mappings of every page that might be sitting in device memory. the struggle. for example, this is often the case when a driver is being unloaded or unbound from a device β main character driver is leaving, and it has no idea where it left its stuff π«Ά
Like migrate_vma_setup, this function will take a reference and lock any migrating pages that aren't free before unmapping them. locked and loaded, periodt π₯
Drivers may then allocate destination pages and start copying data from the device to CPU memory before calling migrate_device_pages. that's the order of operations, don't skip steps, iykyk β¨
π SEE ALSO π
Kernel file ./mm/migrate_device.c plus all these iconic little friends:
migrate_vma_split_folio(9)migrate_vma_setup(9)migrate_vma_insert_huge_pmd_page(9)migrate_device_pages(9)migrate_vma_pages(9)migrate_vma_finalize(9)migrate_device_pfns(9)
ngl bestie, read the SEE ALSO list before you start migrating anything β the whole squad is relevant here π
mwah π that's the page β brought to you by ./mm (the source), dated October 2026 (the version/date flex), and this very same migrate_device_range(9) header we folded in up top. slay, go migrate some pages responsibly πβ
π¦ 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