]> git.proxmox.com Git - pve-kernel-3.10.0.git/blob - kvmstealtime.patch
ef1807a876b180f3920221570eb414c2207eb7a6
[pve-kernel-3.10.0.git] / kvmstealtime.patch
1 Return-Path: kvm-owner@vger.kernel.org
2 Received: from mailpro.odiso.net (LHLO mailpro.odiso.net) (10.1.31.112) by
3 mailpro.odiso.net with LMTP; Thu, 15 Oct 2015 00:33:53 +0200 (CEST)
4 Received: from localhost (localhost [127.0.0.1])
5 by mailpro.odiso.net (Postfix) with ESMTP id 1F3454439326A
6 for <aderumier@oxygem.tv>; Thu, 15 Oct 2015 00:33:53 +0200 (CEST)
7 X-Virus-Scanned: amavisd-new at mailpro.odiso.com
8 X-Spam-Flag: NO
9 X-Spam-Score: 0.971
10 X-Spam-Level:
11 X-Spam-Status: No, score=0.971 tagged_above=-10 required=4
12 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001,
13 KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01,
14 RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01]
15 autolearn=no autolearn_force=no
16 Received: from mailpro.odiso.net ([127.0.0.1])
17 by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10024)
18 with ESMTP id hMmmKVYj2S2m for <aderumier@oxygem.tv>;
19 Thu, 15 Oct 2015 00:33:47 +0200 (CEST)
20 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
21 by mailpro.odiso.net (Postfix) with ESMTP id 09D3D4439324A
22 for <aderumier@odiso.com>; Thu, 15 Oct 2015 00:33:46 +0200 (CEST)
23 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
24 id S1754065AbbJNWdh (ORCPT <rfc822;aderumier@odiso.com>);
25 Wed, 14 Oct 2015 18:33:37 -0400
26 Received: from mx1.redhat.com ([209.132.183.28]:48432 "EHLO mx1.redhat.com"
27 rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
28 id S1753882AbbJNWdg (ORCPT <rfc822;kvm@vger.kernel.org>);
29 Wed, 14 Oct 2015 18:33:36 -0400
30 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24])
31 by mx1.redhat.com (Postfix) with ESMTPS id 35096C0BFD02
32 for <kvm@vger.kernel.org>; Wed, 14 Oct 2015 22:33:36 +0000 (UTC)
33 Received: from amt.cnet (vpn1-4-185.ams2.redhat.com [10.36.4.185])
34 by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9EMXYFs002263;
35 Wed, 14 Oct 2015 18:33:35 -0400
36 Received: from amt.cnet (localhost [127.0.0.1])
37 by amt.cnet (Postfix) with ESMTP id ADFE61009C7;
38 Wed, 14 Oct 2015 19:33:15 -0300 (BRT)
39 Received: (from marcelo@localhost)
40 by amt.cnet (8.14.7/8.14.7/Submit) id t9EMXCRq014112;
41 Wed, 14 Oct 2015 19:33:12 -0300
42 Date: Wed, 14 Oct 2015 19:33:09 -0300
43 From: Marcelo Tosatti <mtosatti@redhat.com>
44 To: kvm@vger.kernel.org
45 Cc: Rik van Riel <riel@redhat.com>,
46 "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
47 Paolo Bonzini <pbonzini@redhat.com>,
48 Amit Shah <amit.shah@redhat.com>
49 Subject: [PATCH] KVM: x86: move steal time initialization to vcpu entry time
50 Message-ID: <20151014223309.GA13900@amt.cnet>
51 MIME-Version: 1.0
52 Content-Type: text/plain; charset=us-ascii
53 Content-Disposition: inline
54 User-Agent: Mutt/1.5.21 (2010-09-15)
55 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24
56 Sender: kvm-owner@vger.kernel.org
57 Precedence: bulk
58 List-ID: <kvm.vger.kernel.org>
59 X-Mailing-List: kvm@vger.kernel.org
60
61
62 As reported at https://bugs.launchpad.net/qemu/+bug/1494350,
63 it is possible to have vcpu->arch.st.last_steal initialized
64 from a thread other than vcpu thread, say the iothread, via
65 KVM_SET_MSRS.
66
67 Which can cause an overflow later (when subtracting from vcpu threads
68 sched_info.run_delay).
69
70 To avoid that, move steal time accumulation to vcpu entry time,
71 before copying steal time data to guest.
72
73 Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
74
75 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
76 index 8f0f6ec..0e0332e 100644
77 --- a/arch/x86/kvm/x86.c
78 +++ b/arch/x86/kvm/x86.c
79 @@ -2030,6 +2030,8 @@ static void accumulate_steal_time(struct kvm_vcpu *vcpu)
80
81 static void record_steal_time(struct kvm_vcpu *vcpu)
82 {
83 + accumulate_steal_time(vcpu);
84 +
85 if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
86 return;
87
88 @@ -2182,12 +2184,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
89 if (!(data & KVM_MSR_ENABLED))
90 break;
91
92 - vcpu->arch.st.last_steal = current->sched_info.run_delay;
93 -
94 - preempt_disable();
95 - accumulate_steal_time(vcpu);
96 - preempt_enable();
97 -
98 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
99
100 break;
101 @@ -2830,7 +2826,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
102 vcpu->cpu = cpu;
103 }
104
105 - accumulate_steal_time(vcpu);
106 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
107 }
108
109 --
110 To unsubscribe from this list: send the line "unsubscribe kvm" in
111 the body of a message to majordomo@vger.kernel.org
112 More majordomo info at http://vger.kernel.org/majordomo-info.html