kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] KVM: Fix tick-based accounting for x86 guests
@ 2021-04-15 22:20 Sean Christopherson
  2021-04-15 22:20 ` [PATCH v3 1/9] context_tracking: Move guest exit context tracking to separate helpers Sean Christopherson
                   ` (9 more replies)
  0 siblings, 10 replies; 25+ messages in thread
From: Sean Christopherson @ 2021-04-15 22:20 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Thomas Gleixner,
	Michael Tokarev, Christian Borntraeger

This is a continuation of Wanpeng's series[1] to fix tick-based CPU time
accounting on x86, with my cleanups[2] bolted on top.  The core premise of
Wanpeng's patches are preserved, but they are heavily stripped down.
Specifically, only the "guest exit" paths are split, and no code is
consolidated.  The intent is to do as little as possible in the three
patches that need to be backported.  Keeping those changes as small as
possible also meant that my cleanups did not need to unwind much 
refactoring.

On x86, tested CONFIG_VIRT_CPU_ACCOUNTING_GEN =y and =n, and with
CONFIG_DEBUG_ENTRY=y && CONFIG_VALIDATE_STACKS=y.  Compile tested arm64,
MIPS, PPC, and s390, the latter with CONFIG_DEBUG_ENTRY=y for giggles.

One last note: I elected to use vtime_account_guest_exit() in the x86 code
instead of open coding these equivalents:

	if (vtime_accounting_enabled_this_cpu())
		vtime_guest_exit(current);
...
	if (!vtime_accounting_enabled_this_cpu())
		current->flags &= ~PF_VCPU;

With CONFIG_VIRT_CPU_ACCOUNTING_GEN=n, this is a complete non-issue, but
for the =y case it means context_tracking_enabled_this_cpu() is being
checked back-to-back.  The redundant checks bug me, but open coding the
gory details in x86 or providing funky variants in vtime.h felt worse.

Delta from Wanpeng's v2:

  - s/context_guest/context_tracking_guest, purely to match the existing
    functions.  I have no strong opinion either way.
  - Split only the "exit" functions.
  - Partially open code vcpu_account_guest_exit() and
    __vtime_account_guest_exit() in x86 to avoid churn when segueing into
    my cleanups (see above).

[1] https://lkml.kernel.org/r/1618298169-3831-1-git-send-email-wanpengli@tencent.com
[2] https://lkml.kernel.org/r/20210413182933.1046389-1-seanjc@google.com

Sean Christopherson (6):
  sched/vtime: Move vtime accounting external declarations above inlines
  sched/vtime: Move guest enter/exit vtime accounting to vtime.h
  context_tracking: Consolidate guest enter/exit wrappers
  context_tracking: KVM: Move guest enter/exit wrappers to KVM's domain
  KVM: x86: Consolidate guest enter/exit logic to common helpers
  KVM: Move instrumentation-safe annotations for enter/exit to x86 code

Wanpeng Li (3):
  context_tracking: Move guest exit context tracking to separate helpers
  context_tracking: Move guest exit vtime accounting to separate helpers
  KVM: x86: Defer tick-based accounting 'til after IRQ handling

 arch/x86/kvm/svm/svm.c           |  39 +--------
 arch/x86/kvm/vmx/vmx.c           |  39 +--------
 arch/x86/kvm/x86.c               |   8 ++
 arch/x86/kvm/x86.h               |  52 ++++++++++++
 include/linux/context_tracking.h |  92 ++++-----------------
 include/linux/kvm_host.h         |  38 +++++++++
 include/linux/vtime.h            | 138 +++++++++++++++++++------------
 7 files changed, 204 insertions(+), 202 deletions(-)

-- 
2.31.1.368.gbe11c130af-goog


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

end of thread, other threads:[~2021-04-28 22:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 22:20 [PATCH v3 0/9] KVM: Fix tick-based accounting for x86 guests Sean Christopherson
2021-04-15 22:20 ` [PATCH v3 1/9] context_tracking: Move guest exit context tracking to separate helpers Sean Christopherson
2021-04-20 18:48   ` Christian Borntraeger
2021-04-21 10:57   ` Frederic Weisbecker
2021-04-15 22:20 ` [PATCH v3 2/9] context_tracking: Move guest exit vtime accounting " Sean Christopherson
2021-04-20 18:48   ` Christian Borntraeger
2021-04-15 22:21 ` [PATCH v3 3/9] KVM: x86: Defer tick-based accounting 'til after IRQ handling Sean Christopherson
2021-04-20 23:14   ` Frederic Weisbecker
2021-04-20 23:26     ` Sean Christopherson
2021-04-21 10:11       ` Frederic Weisbecker
2021-04-21 12:19       ` Frederic Weisbecker
2021-04-28 22:38         ` Sean Christopherson
2021-04-21 10:07   ` Frederic Weisbecker
2021-04-15 22:21 ` [PATCH v3 4/9] sched/vtime: Move vtime accounting external declarations above inlines Sean Christopherson
2021-04-21  7:02   ` Christian Borntraeger
2021-04-15 22:21 ` [PATCH v3 5/9] sched/vtime: Move guest enter/exit vtime accounting to vtime.h Sean Christopherson
2021-04-15 22:21 ` [PATCH v3 6/9] context_tracking: Consolidate guest enter/exit wrappers Sean Christopherson
2021-04-15 22:21 ` [PATCH v3 7/9] context_tracking: KVM: Move guest enter/exit wrappers to KVM's domain Sean Christopherson
2021-04-21  7:10   ` Christian Borntraeger
2021-04-15 22:21 ` [PATCH v3 8/9] KVM: x86: Consolidate guest enter/exit logic to common helpers Sean Christopherson
2021-04-15 22:21 ` [PATCH v3 9/9] KVM: Move instrumentation-safe annotations for enter/exit to x86 code Sean Christopherson
2021-04-21  8:09   ` Christian Borntraeger
2021-04-22 14:38     ` Sven Schnelle
2021-04-23  9:32       ` Vasily Gorbik
2021-04-20 23:33 ` [PATCH v3 0/9] KVM: Fix tick-based accounting for x86 guests Frederic Weisbecker

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).