• Gavin Shan's avatar
    KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL · cf87ac73
    Gavin Shan authored
    The VCPU isn't expected to be runnable when the dirty ring becomes soft
    full, until the dirty pages are harvested and the dirty ring is reset
    from userspace. So there is a check in each guest's entrace to see if
    the dirty ring is soft full or not. The VCPU is stopped from running if
    its dirty ring has been soft full. The similar check will be needed when
    the feature is going to be supported on ARM64. As Marc Zyngier suggested,
    a new event will avoid pointless overhead to check the size of the dirty
    ring ('vcpu->kvm->dirty_ring_size') in each guest's entrance.
    
    Add KVM_REQ_DIRTY_RING_SOFT_FULL. The event is raised when the dirty ring
    becomes soft full in kvm_dirty_ring_push(). The event is only cleared in
    the check, done in the newly added helper kvm_dirty_ring_check_request().
    Since the VCPU is not runnable when the dirty ring becomes soft full, the
    KVM_REQ_DIRTY_RING_SOFT_FULL event is always set to prevent the VCPU from
    running until the dirty pages are harvested and the dirty ring is reset by
    userspace.
    
    kvm_dirty_ring_soft_full() becomes a private function with the newly added
    helper kvm_dirty_ring_check_request(). The alignment for the various event
    definitions in kvm_host.h is changed to tab character by the way. In order
    to avoid using 'container_of()', the argument @ring is replaced by @vcpu
    in kvm_dirty_ring_push().
    
    Link: https://lore.kernel.org/kvmarm/87lerkwtm5.wl-maz@kernel.orgSuggested-by: default avatarMarc Zyngier <maz@kernel.org>
    Signed-off-by: default avatarGavin Shan <gshan@redhat.com>
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20221110104914.31280-2-gshan@redhat.com
    cf87ac73
dirty_ring.c 5.04 KB