All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Wanpeng Li <wanpengli@tencent.com>,
	Sean Christopherson <seanjc@google.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCH 5.10 5/9] context_tracking: Move guest exit vtime accounting to separate helpers
Date: Thu, 27 May 2021 17:12:57 +0200	[thread overview]
Message-ID: <20210527151139.409960757@linuxfoundation.org> (raw)
In-Reply-To: <20210527151139.242182390@linuxfoundation.org>

From: Wanpeng Li <wanpengli@tencent.com>

commit 88d8220bbf06dd8045b2ac4be1046290eaa7773a upstream.

Provide separate vtime accounting functions for guest exit instead of
open coding the logic within the context tracking code.  This will allow
KVM x86 to handle vtime accounting slightly differently when using
tick-based accounting.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Link: https://lore.kernel.org/r/20210505002735.1684165-3-seanjc@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/context_tracking.h |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -135,15 +135,20 @@ static __always_inline void context_trac
 		__context_tracking_exit(CONTEXT_GUEST);
 }
 
-static __always_inline void guest_exit_irqoff(void)
+static __always_inline void vtime_account_guest_exit(void)
 {
-	context_tracking_guest_exit();
-
-	instrumentation_begin();
 	if (vtime_accounting_enabled_this_cpu())
 		vtime_guest_exit(current);
 	else
 		current->flags &= ~PF_VCPU;
+}
+
+static __always_inline void guest_exit_irqoff(void)
+{
+	context_tracking_guest_exit();
+
+	instrumentation_begin();
+	vtime_account_guest_exit();
 	instrumentation_end();
 }
 
@@ -164,12 +169,17 @@ static __always_inline void guest_enter_
 
 static __always_inline void context_tracking_guest_exit(void) { }
 
+static __always_inline void vtime_account_guest_exit(void)
+{
+	vtime_account_kernel(current);
+	current->flags &= ~PF_VCPU;
+}
+
 static __always_inline void guest_exit_irqoff(void)
 {
 	instrumentation_begin();
 	/* Flush the guest cputime we spent on the guest */
-	vtime_account_kernel(current);
-	current->flags &= ~PF_VCPU;
+	vtime_account_guest_exit();
 	instrumentation_end();
 }
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */



  parent reply	other threads:[~2021-05-27 15:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 15:12 [PATCH 5.10 0/9] 5.10.41-rc1 review Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 1/9] bpf: Wrap aux data inside bpf_sanitize_info container Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 2/9] bpf: Fix mask direction swap upon off reg sign change Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 3/9] bpf: No need to simulate speculative domain for immediates Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 4/9] context_tracking: Move guest exit context tracking to separate helpers Greg Kroah-Hartman
2021-05-27 15:12 ` Greg Kroah-Hartman [this message]
2021-05-27 15:12 ` [PATCH 5.10 6/9] KVM: x86: Defer vtime accounting til after IRQ handling Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 7/9] perf unwind: Fix separate debug info files when using elfutils libdws unwinder Greg Kroah-Hartman
2021-05-27 15:13 ` [PATCH 5.10 8/9] perf unwind: Set userdata for all __report_module() paths Greg Kroah-Hartman
2021-05-27 15:13 ` [PATCH 5.10 9/9] NFC: nci: fix memory leak in nci_allocate_device Greg Kroah-Hartman
2021-05-27 19:03 ` [PATCH 5.10 0/9] 5.10.41-rc1 review Jon Hunter
2021-05-27 19:57 ` Fox Chen
2021-05-27 20:34 ` Pavel Machek
2021-05-28  0:01 ` Shuah Khan
2021-05-28  3:08 ` Florian Fainelli
2021-05-28  6:00 ` Guenter Roeck
2021-05-28  6:22 ` Naresh Kamboju
2021-05-28 16:51 ` Sudip Mukherjee
2021-05-29  0:42 ` Samuel Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210527151139.409960757@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=borntraeger@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.