[pve-devel] [PATCH] kernel 3.10 : add kvm steal time fix

Alexandre Derumier aderumier at odiso.com
Tue Dec 8 00:35:36 CET 2015


Important fix which have been already applied on proxmox 4.0.

I thinked it was just comestic, but guest with kernel 3.16 really
slowdown when the bug is triggered.
(seem that cpu scheduler is working bad)

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 Makefile           |   1 +
 kvmstealtime.patch | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)
 create mode 100644 kvmstealtime.patch

diff --git a/Makefile b/Makefile
index 98ce403..f41ba0f 100644
--- a/Makefile
+++ b/Makefile
@@ -201,6 +201,7 @@ ${KERNEL_SRC}/README: ${KERNEL_SRC}.org/README
 	#cd ${KERNEL_SRC}; patch -p1 <../do-not-use-barrier-on-ext3.patch
 	cd ${KERNEL_SRC}; patch -p1 <../bridge-patch.diff
 	cd ${KERNEL_SRC}; patch -p1 <../bridge-forward-ipv6-neighbor-solicitation.patch
+	cd ${KERNEL_SRC}; patch -p1 <../kvmstealtime.patch
 	#cd ${KERNEL_SRC}; patch -p1 <../kvm-fix-invalid-secondary-exec-controls.patch
 	#cd ${KERNEL_SRC}; patch -p1 <../fix-aspm-policy.patch
 	#cd ${KERNEL_SRC}; patch -p1 <../kbuild-generate-mudules-builtin.patch
diff --git a/kvmstealtime.patch b/kvmstealtime.patch
new file mode 100644
index 0000000..ef1807a
--- /dev/null
+++ b/kvmstealtime.patch
@@ -0,0 +1,112 @@
+Return-Path: kvm-owner at vger.kernel.org
+Received: from mailpro.odiso.net (LHLO mailpro.odiso.net) (10.1.31.112) by
+ mailpro.odiso.net with LMTP; Thu, 15 Oct 2015 00:33:53 +0200 (CEST)
+Received: from localhost (localhost [127.0.0.1])
+	by mailpro.odiso.net (Postfix) with ESMTP id 1F3454439326A
+	for <aderumier at oxygem.tv>; Thu, 15 Oct 2015 00:33:53 +0200 (CEST)
+X-Virus-Scanned: amavisd-new at mailpro.odiso.com
+X-Spam-Flag: NO
+X-Spam-Score: 0.971
+X-Spam-Level:
+X-Spam-Status: No, score=0.971 tagged_above=-10 required=4
+	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001,
+	KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01,
+	RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01]
+	autolearn=no autolearn_force=no
+Received: from mailpro.odiso.net ([127.0.0.1])
+	by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10024)
+	with ESMTP id hMmmKVYj2S2m for <aderumier at oxygem.tv>;
+	Thu, 15 Oct 2015 00:33:47 +0200 (CEST)
+Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
+	by mailpro.odiso.net (Postfix) with ESMTP id 09D3D4439324A
+	for <aderumier at odiso.com>; Thu, 15 Oct 2015 00:33:46 +0200 (CEST)
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1754065AbbJNWdh (ORCPT <rfc822;aderumier at odiso.com>);
+	Wed, 14 Oct 2015 18:33:37 -0400
+Received: from mx1.redhat.com ([209.132.183.28]:48432 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1753882AbbJNWdg (ORCPT <rfc822;kvm at vger.kernel.org>);
+	Wed, 14 Oct 2015 18:33:36 -0400
+Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24])
+	by mx1.redhat.com (Postfix) with ESMTPS id 35096C0BFD02
+	for <kvm at vger.kernel.org>; Wed, 14 Oct 2015 22:33:36 +0000 (UTC)
+Received: from amt.cnet (vpn1-4-185.ams2.redhat.com [10.36.4.185])
+	by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9EMXYFs002263;
+	Wed, 14 Oct 2015 18:33:35 -0400
+Received: from amt.cnet (localhost [127.0.0.1])
+	by amt.cnet (Postfix) with ESMTP id ADFE61009C7;
+	Wed, 14 Oct 2015 19:33:15 -0300 (BRT)
+Received: (from marcelo at localhost)
+	by amt.cnet (8.14.7/8.14.7/Submit) id t9EMXCRq014112;
+	Wed, 14 Oct 2015 19:33:12 -0300
+Date:	Wed, 14 Oct 2015 19:33:09 -0300
+From:	Marcelo Tosatti <mtosatti at redhat.com>
+To:	kvm at vger.kernel.org
+Cc:	Rik van Riel <riel at redhat.com>,
+	"Dr. David Alan Gilbert" <dgilbert at redhat.com>,
+	Paolo Bonzini <pbonzini at redhat.com>,
+	Amit Shah <amit.shah at redhat.com>
+Subject: [PATCH] KVM: x86: move steal time initialization to vcpu entry time 
+Message-ID: <20151014223309.GA13900 at amt.cnet>
+MIME-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+User-Agent: Mutt/1.5.21 (2010-09-15)
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24
+Sender:	kvm-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <kvm.vger.kernel.org>
+X-Mailing-List:	kvm at vger.kernel.org
+
+
+As reported at https://bugs.launchpad.net/qemu/+bug/1494350, 
+it is possible to have vcpu->arch.st.last_steal initialized 
+from a thread other than vcpu thread, say the iothread, via 
+KVM_SET_MSRS.
+
+Which can cause an overflow later (when subtracting from vcpu threads
+sched_info.run_delay).
+
+To avoid that, move steal time accumulation to vcpu entry time, 
+before copying steal time data to guest.
+
+Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
+
+diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
+index 8f0f6ec..0e0332e 100644
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -2030,6 +2030,8 @@ static void accumulate_steal_time(struct kvm_vcpu *vcpu)
+ 
+ static void record_steal_time(struct kvm_vcpu *vcpu)
+ {
++	accumulate_steal_time(vcpu);
++
+ 	if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
+ 		return;
+ 
+@@ -2182,12 +2184,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
+ 		if (!(data & KVM_MSR_ENABLED))
+ 			break;
+ 
+-		vcpu->arch.st.last_steal = current->sched_info.run_delay;
+-
+-		preempt_disable();
+-		accumulate_steal_time(vcpu);
+-		preempt_enable();
+-
+ 		kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
+ 
+ 		break;
+@@ -2830,7 +2826,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
+ 		vcpu->cpu = cpu;
+ 	}
+ 
+-	accumulate_steal_time(vcpu);
+ 	kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
+ }
+ 
+--
+To unsubscribe from this list: send the line "unsubscribe kvm" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
2.1.4




More information about the pve-devel mailing list