From: Aaron Lewis <aaronlewis@google.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com,
Aaron Lewis <aaronlewis@google.com>
Subject: [PATCH] KVM: x86: Fix a stall when KVM_SET_MSRS is called on the pmu counters
Date: Fri, 28 Oct 2022 13:00:36 +0000 [thread overview]
Message-ID: <20221028130035.1550068-1-aaronlewis@google.com> (raw)
When the host initiates a wrmsr through KVM_SET_MSRS don't print an
error if the PMU is disabled, doing so can cause a noticeable stall
while printing the error message.
The profile below was taken while calling KVM_SET_MSRS on the pmu
counters while the PMU was disabled in KVM. Even though the print is
rate limited it still manages to consume by far the majority of the
time.
- 99.75% 0.00% [.] __ioctl
- __ioctl
- 99.74% entry_SYSCALL_64_after_hwframe
do_syscall_64
sys_ioctl
- do_vfs_ioctl
- 92.48% kvm_vcpu_ioctl
- kvm_arch_vcpu_ioctl
- 85.12% kvm_set_msr_ignored_check
svm_set_msr
kvm_set_msr_common
printk
vprintk_func
vprintk_default
vprintk_emit
console_unlock
call_console_drivers
univ8250_console_write
serial8250_console_write
uart_console_write
A stall in this situation could have an impact on live migration. So,
to avoid that disable the print if the write is initiated by the host.
Fixes: 5753785fa977 ("KVM: do not #GP on perf MSR writes when vPMU is disabled")
Signed-off-by: Aaron Lewis <aaronlewis@google.com>
---
arch/x86/kvm/x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9cf1ba865562..a3b842467bd2 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3778,7 +3778,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
case MSR_K7_PERFCTR0 ... MSR_K7_PERFCTR3:
case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR1:
- pr = true;
+ pr = !msr_info->host_initiated;
fallthrough;
case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL1:
--
2.38.1.273.g43a17bfeac-goog
next reply other threads:[~2022-10-28 13:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 13:00 Aaron Lewis [this message]
2022-10-28 16:26 ` [PATCH] KVM: x86: Fix a stall when KVM_SET_MSRS is called on the pmu counters Sean Christopherson
2022-10-28 20:47 ` Aaron Lewis
2022-10-28 21:50 ` Sean Christopherson
2022-10-28 22:01 ` Jim Mattson
2022-10-28 22:43 ` Sean Christopherson
2022-11-02 17:55 ` Paolo Bonzini
2022-11-02 23:15 ` Aaron Lewis
2022-10-29 0:34 ` Aaron Lewis
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=20221028130035.1550068-1-aaronlewis@google.com \
--to=aaronlewis@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox