On 30.11.24 13:48, Wei Chen wrote:
 > That doesn't explain the full story about MIGRATE_UNMOVABLE. I assume
 > one precondition is missing in your explanation.

I have double-checked the source code. My initial description of the
process seems somewhat imprecise. vIOMMU does not convert pages to
UNMOVABLE during pinning, it is that pinning causes page faults, and the
fault handler allocates UNMOVABLE pages. (vaddr_get_pfns() calls
__gup_longterm_locked(), who then calls memalloc_pin_save(), and it
implicitly removes the __GFP_MOVABLE flag.)

Ah, that makes sense! I forgot about memalloc_pin_save(), which we primarily added to avoid allocation+immediate migration during longterm pinning IIRC.


Therefore, there is no requirement of ZONE_MOVABLE and MIGRATE_CMA.

Indeed. On systems without that, one workaround would be driving virtio-mem in "prealloc" mode (prealloc=on in QEMU on the device), whereby we first preallocate the memory using MADV_POPULATW_WRITE, to then longterm pin it.

--
Cheers,

David / dhildenb


Reply via email to