migrate_device_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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