kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] KVM: Properly account for guest CPU time
@ 2021-04-13  7:16 Wanpeng Li
  2021-04-13  7:16 ` [PATCH v2 1/3] context_tracking: Split guest_enter/exit_irqoff Wanpeng Li
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Wanpeng Li @ 2021-04-13  7:16 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Michael Tokarev

The bugzilla https://bugzilla.kernel.org/show_bug.cgi?id=209831
reported that the guest time remains 0 when running a while true
loop in the guest.

The commit 87fa7f3e98a131 ("x86/kvm: Move context tracking where it
belongs") moves guest_exit_irqoff() close to vmexit breaks the
tick-based time accouting when the ticks that happen after IRQs are
disabled are incorrectly accounted to the host/system time. This is
because we exit the guest state too early.

This patchset splits both context tracking logic and the time accounting 
logic from guest_enter/exit_irqoff(), keep context tracking around the 
actual vmentry/exit code, have the virt time specific helpers which 
can be placed at the proper spots in kvm. In addition, it will not 
break the world outside of x86.

v1 -> v2:
 * split context_tracking from guest_enter/exit_irqoff
 * provide separate vtime accounting functions for consistent
 * place the virt time specific helpers at the proper splot 

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Michael Tokarev <mjt@tls.msk.ru>

Wanpeng Li (3):
  context_tracking: Split guest_enter/exit_irqoff
  context_tracking: Provide separate vtime accounting functions
  x86/kvm: Fix vtime accounting

 arch/x86/kvm/svm/svm.c           |  6 ++-
 arch/x86/kvm/vmx/vmx.c           |  6 ++-
 arch/x86/kvm/x86.c               |  1 +
 include/linux/context_tracking.h | 84 +++++++++++++++++++++++++++++++---------
 4 files changed, 74 insertions(+), 23 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-04-15 19:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  7:16 [PATCH v2 0/3] KVM: Properly account for guest CPU time Wanpeng Li
2021-04-13  7:16 ` [PATCH v2 1/3] context_tracking: Split guest_enter/exit_irqoff Wanpeng Li
2021-04-13  7:35   ` Christian Borntraeger
2021-04-13  7:38     ` Wanpeng Li
2021-04-13  7:48       ` Christian Borntraeger
2021-04-13  7:52         ` Wanpeng Li
2021-04-13  8:07           ` Christian Borntraeger
2021-04-13  7:16 ` [PATCH v2 2/3] context_tracking: Provide separate vtime accounting functions Wanpeng Li
2021-04-13  7:16 ` [PATCH v2 3/3] x86/kvm: Fix vtime accounting Wanpeng Li
2021-04-13  8:32 ` [PATCH v2 0/3] KVM: Properly account for guest CPU time Christian Borntraeger
2021-04-13 17:25 ` Sean Christopherson
2021-04-14  9:36   ` Wanpeng Li
2021-04-15  0:49     ` Sean Christopherson
2021-04-15  1:23       ` Wanpeng Li
2021-04-15 19:02         ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).