Fuad Tabba wrote: > Hi, > > On Thu, 3 Jul 2025 at 05:12, Michael Roth <michael.roth@xxxxxxx> wrote: > > > > On Wed, Jul 02, 2025 at 05:46:23PM -0700, Vishal Annapurve wrote: > > > On Wed, Jul 2, 2025 at 4:25 PM Michael Roth <michael.roth@xxxxxxx> wrote: > > > > > > > > On Wed, Jun 11, 2025 at 02:51:38PM -0700, Ackerley Tng wrote: > > > > > Michael Roth <michael.roth@xxxxxxx> writes: > > > > > > > > > > > On Wed, May 14, 2025 at 04:41:41PM -0700, Ackerley Tng wrote: [snip] > > > > > > The mtree contents seems to get stored in the same manner in either case so > > > > > > performance-wise only the overhead of a few userspace<->kernel switches > > > > > > would be saved. Are there any other reasons? > > > > > > > > > > > > Otherwise, maybe just settle on SHARED as a documented default (since at > > > > > > least non-CoCo VMs would be able to reliably benefit) and let > > > > > > CoCo/GUEST_MEMFD_FLAG_SUPPORT_SHARED VMs set PRIVATE at whatever > > > > > > granularity makes sense for the architecture/guest configuration. > > > > > > > > > > > > > > > > Because shared pages are split once any memory is allocated, having a > > > > > way to INIT_PRIVATE could avoid the split and then merge on > > > > > conversion. I feel that is enough value to have this config flag, what > > > > > do you think? > > > > > > > > > > I guess we could also have userspace be careful not to do any allocation > > > > > before converting. > > > > (Re-visiting this with the assumption that we *don't* intend to use mmap() to > > populate memory (in which case you can pretty much ignore my previous > > response)) > > > > I'm still not sure where the INIT_PRIVATE flag comes into play. For SNP, > > userspace already defaults to marking everything private pretty close to > > guest_memfd creation time, so the potential for allocations to occur > > in-between seems small, but worth confirming. > > > > But I know in the past there was a desire to ensure TDX/SNP could > > support pre-allocating guest_memfd memory (and even pre-faulting via > > KVM_PRE_FAULT_MEMORY), but I think that could still work right? The > > fallocate() handling could still avoid the split if the whole hugepage > > is private, though there is a bit more potential for that fallocate() > > to happen before userspace does the "manually" shared->private > > conversion. I'll double-check on that aspect, but otherwise, is there > > still any other need for it? > > It's not just about performance. I think that the need is more a > matter of having a consistent API with the hypervisors guest_memfd is > going to support. Memory in guest_memfd is shared by default, but in > pKVM for example, it's private by default. Therefore, it would be good ^^^^^^^^^^^^^^^^ And Coco's as well right? Ira > to have a way to ensure that all guest_memfd allocations can be made > private from the get-go. > > Cheers, > /fuad > [snip]