• Li RongQing's avatar
    KVM: x86: Support the vCPU preemption check with nopvspin and realtime hint · d063de55
    Li RongQing authored
    If guest kernel is configured with nopvspin, or CONFIG_PARAVIRT_SPINLOCK
    is disabled, or guest find its has dedicated pCPUs from realtime hint
    feature, the pvspinlock will be disabled, and vCPU preemption check
    is disabled too.
    
    Hoever, KVM still can emulating HLT for vCPU for both cases.  Checking if a vCPU
    is preempted or not can still boost performance in IPI-heavy scenarios such as
    unixbench file copy and pipe-based context switching tests:  Here the vCPU is
    running with a dedicated pCPU, so the guest kernel has nopvspin but is
    emulating HLT for the vCPU:
    
    Testcase                                  Base    with patch
    System Benchmarks Index Values            INDEX     INDEX
    Dhrystone 2 using register variables     3278.4    3277.7
    Double-Precision Whetstone                822.8     825.8
    Execl Throughput                         1296.5     941.1
    File Copy 1024 bufsize 2000 maxblocks    2124.2    2142.7
    File Copy 256 bufsize 500 maxblocks      1335.9    1353.6
    File Copy 4096 bufsize 8000 maxblocks    4256.3    4760.3
    Pipe Throughput                          1050.1    1054.0
    Pipe-based Context Switching              243.3     352.0
    Process Creation                          820.1     814.4
    Shell Scripts (1 concurrent)             2169.0    2086.0
    Shell Scripts (8 concurrent)             7710.3    7576.3
    System Call Overhead                      672.4     673.9
                                          ========    =======
    System Benchmarks Index Score             1467.2   1483.0
    
    Move the setting of pv_ops.lock.vcpu_is_preempted to kvm_guest_init, so
    that it does not depend on pvspinlock.
    Signed-off-by: default avatarLi RongQing <lirongqing@baidu.com>
    Message-Id: <1646815610-43315-1-git-send-email-lirongqing@baidu.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    d063de55
kvm.c 27.1 KB