On Fri, Sep 8, 2023 at 3:30 PM Anish Moorthy <amoorthy@xxxxxxxxxx> wrote: > > Add documentation, memslot flags, useful helper functions, and the > definition of the capability. Implementation is provided in a subsequent > commit. > > Memory fault exits on absent mappings are particularly useful for > userfaultfd-based postcopy live migration, where contention within uffd > can lead to slowness When many vCPUs fault on a single uffd/vma. > Bypassing the uffd entirely by returning information directly to the > vCPU via an exit avoids contention and can greatly improves the fault > rate. > > Suggested-by: James Houghton <jthoughton@xxxxxxxxxx> > Signed-off-by: Anish Moorthy <amoorthy@xxxxxxxxxx> > --- > Documentation/virt/kvm/api.rst | 28 +++++++++++++++++++++++++--- > include/linux/kvm_host.h | 9 +++++++++ > include/uapi/linux/kvm.h | 2 ++ > tools/include/uapi/linux/kvm.h | 1 + > virt/kvm/Kconfig | 3 +++ > virt/kvm/kvm_main.c | 5 +++++ > 6 files changed, 45 insertions(+), 3 deletions(-) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 92fd3faa6bab..c2eaacb6dc63 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -1312,6 +1312,7 @@ yet and must be cleared on entry. > /* for kvm_userspace_memory_region::flags */ > #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) > #define KVM_MEM_READONLY (1UL << 1) > + #define KVM_MEM_USERFAULT_ON_MISSING (1UL << 2) Bike Shedding! Maybe KVM_MEM_EXIT_ON_MISSING? "Exiting" has concrete meaning in the KVM UAPI whereas "userfault" doesn't and could suggest going through userfaultfd, which is the opposite of what this capability is doing.