• L
    KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC · b35e5548
    Like Xu 提交于
    Currently, a host perf_event is created for a vPMC functionality emulation.
    It’s unpredictable to determine if a disabled perf_event will be reused.
    If they are disabled and are not reused for a considerable period of time,
    those obsolete perf_events would increase host context switch overhead that
    could have been avoided.
    
    If the guest doesn't WRMSR any of the vPMC's MSRs during an entire vcpu
    sched time slice, and its independent enable bit of the vPMC isn't set,
    we can predict that the guest has finished the use of this vPMC, and then
    do request KVM_REQ_PMU in kvm_arch_sched_in and release those perf_events
    in the first call of kvm_pmu_handle_event() after the vcpu is scheduled in.
    
    This lazy mechanism delays the event release time to the beginning of the
    next scheduled time slice if vPMC's MSRs aren't changed during this time
    slice. If guest comes back to use this vPMC in next time slice, a new perf
    event would be re-created via perf_event_create_kernel_counter() as usual.
    Suggested-by: NWei Wang <wei.w.wang@intel.com>
    Suggested-by: NPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: NLike Xu <like.xu@linux.intel.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    b35e5548
x86.c 265.8 KB