Re: [RFC PATCH 0/4] KVM: ioctl for populating guest_memfd

From: David Hildenbrand
Date: Wed Nov 20 2024 - 10:17:47 EST



The questions are:
- Is this a well-known behaviour?
- Is there a way to mitigate that, ie make shared memory (including
guest_memfd) population faster/comparable to private memory?

Likely. But your experiment measures above something different than what
guest_memfd vs. anon does: guest_memfd doesn't update page tables, so I
would assume guest_memfd will be faster than MAP_POPULATE.

How do you end up allocating memory for guest_memfd? Using simple
fallocate()?

Heh, now I spot that your comment was as reply to a series.

If your ioctl is supposed to to more than "allocating memory" like MAP_POPULATE/MADV_POPULATE+* ... then POPULATE is a suboptimal choice. Because for allocating memory, we would want to use fallocate() instead. I assume you want to "allocate+copy"?

I'll note that, as we're moving into the direction of moving guest_memfd.c into mm/guestmem.c, we'll likely want to avoid "KVM_*" ioctls, and think about something generic.

Any clue how your new ioctl will interact with the WIP to have shared memory as part of guest_memfd? For example, could it be reasonable to "populate" the shared memory first (via VMA) and then convert that "allocated+filled" memory to private?

--
Cheers,

David / dhildenb