Re: [RFC PATCH 0/4] mm: Add PG_zero support

From: Dave Hansen
Date: Mon Apr 13 2020 - 12:43:47 EST


On 4/13/20 8:47 AM, Alex Williamson wrote:
>> You can delay pinning until the device is actually used. That should be
>> late enough for the host to figure out whether a paravirtualized IOMMU
>> is in place.
> So the guest enables the bus master bit in the command register and at
> that point we'd stall the VM for an indeterminate length of time while
> we potentially pin all memory, and hope that both the user and the host
> has the resources to account and allocate that memory, otherwise the
> VM suddenly crashes? All of this potentially taking place in the
> pre-boot environment to support option ROMs as well. A delay starting
> the VM seems a lot more predictable. Thanks,

BTW, there are a million ways to speed up VM startup without both
complicating the core VM *and* slowing down everybody that gets a
speedup from cache-hot pages coming out of the allocator.

Use ramfs or hugetlbfs files. Have a bunch of them sitting around,
preallocated (and zeroed) and dole them out as VMs start up.

Instead of complicating the core VM, do the pre-zeroing in hugetlbfs.
Zeroing at the time the pages get added to the pool wouldn't be the
worst thing and wouldn't touch the core VM.