From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Rik van Riel <riel@redhat.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
Peter Zijlstra <peterz@infradead.org>,
Avi Kivity <avi@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Eric B Munson <emunson@mgebm.net>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH v3 5/9] KVM-HV: use schedstats to calculate steal time
Date: Wed, 29 Jun 2011 11:29:44 -0400 [thread overview]
Message-ID: <1309361388-30163-6-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1309361388-30163-1-git-send-email-glommer@redhat.com>
SCHEDSTATS provide a precise source of information about time tasks
spent on a runqueue, but not running (among other things). It is
specially useful for the steal time implementation, because it doesn't
record halt time at all.
To avoid a hard dependency on schedstats, since it is possible one won't
want to record statistics about all processes running, the previous method
of time measurement on put/load vcpu is kept for !SCHEDSTATS.
Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Rik van Riel <riel@redhat.com>
CC: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Avi Kivity <avi@redhat.com>
CC: Anthony Liguori <aliguori@us.ibm.com>
CC: Eric B Munson <emunson@mgebm.net>
CC: Marcelo Tosatti <mtosatti@redhat.com>
---
arch/x86/kvm/x86.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index df9d274..7e87159 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1502,7 +1502,13 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
&vcpu->arch.st.steal, sizeof(struct kvm_steal_time))))
return;
- delta = (get_kernel_ns() - vcpu->arch.st.this_time_out);
+#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+ if (likely(sched_info_on())) {
+ delta = current->sched_info.run_delay - vcpu->arch.st.this_time_out;
+ vcpu->arch.st.this_time_out = current->sched_info.run_delay;
+ } else
+#endif
+ delta = (get_kernel_ns() - vcpu->arch.st.this_time_out);
vcpu->arch.st.steal.steal += delta;
vcpu->arch.st.steal.version += 2;
@@ -1607,9 +1613,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
data & KVM_STEAL_VALID_BITS))
return 1;
- vcpu->arch.st.this_time_out = get_kernel_ns();
- record_steal_time(vcpu);
+#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+ if (likely(sched_info_on()))
+ vcpu->arch.st.this_time_out = current->sched_info.run_delay;
+ else
+#endif
+ vcpu->arch.st.this_time_out = get_kernel_ns();
+ record_steal_time(vcpu);
break;
case MSR_IA32_MCG_CTL:
@@ -2220,7 +2231,10 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
kvm_x86_ops->vcpu_put(vcpu);
kvm_put_guest_fpu(vcpu);
kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
- vcpu->arch.st.this_time_out = get_kernel_ns();
+#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+ if (unlikely(!sched_info_on()))
+#endif
+ vcpu->arch.st.this_time_out = get_kernel_ns();
}
static int is_efer_nx(void)
--
1.7.3.4
next prev parent reply other threads:[~2011-06-29 15:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-29 15:29 [PATCH v3 0/9] Steal time for KVM Glauber Costa
2011-06-29 15:29 ` [PATCH v3 1/9] introduce kvm_read_guest_cached Glauber Costa
2011-06-29 15:29 ` [PATCH v3 2/9] KVM-HDR Add constant to represent KVM MSRs enabled bit Glauber Costa
2011-06-29 21:56 ` Eric B Munson
2011-06-30 8:31 ` Avi Kivity
2011-06-30 12:59 ` Eric B Munson
2011-06-30 13:21 ` Glauber Costa
2011-06-30 14:13 ` Eric B Munson
2011-06-29 15:29 ` [PATCH v3 3/9] KVM-HDR: KVM Steal time implementation Glauber Costa
2011-06-29 21:56 ` Eric B Munson
2011-06-30 21:54 ` Peter Zijlstra
2011-06-29 15:29 ` [PATCH v3 4/9] KVM-HV: " Glauber Costa
2011-06-29 21:56 ` Eric B Munson
2011-06-29 15:29 ` Glauber Costa [this message]
2011-06-29 21:56 ` [PATCH v3 5/9] KVM-HV: use schedstats to calculate steal time Eric B Munson
2011-06-29 15:29 ` [PATCH v3 6/9] KVM-GST: Add a pv_ops stub for " Glauber Costa
2011-06-29 21:56 ` Eric B Munson
2011-06-29 15:29 ` [PATCH v3 7/9] KVM-GST: KVM Steal time accounting Glauber Costa
2011-06-29 21:57 ` Eric B Munson
2011-06-30 21:54 ` Peter Zijlstra
2011-07-01 2:53 ` Glauber Costa
2011-07-01 8:26 ` Peter Zijlstra
2011-06-30 21:54 ` Peter Zijlstra
2011-07-01 2:50 ` Glauber Costa
2011-06-30 21:54 ` Peter Zijlstra
2011-07-01 2:50 ` Glauber Costa
2011-07-01 8:25 ` Peter Zijlstra
2011-06-30 21:54 ` Peter Zijlstra
2011-06-29 15:29 ` [PATCH v3 8/9] KVM-GST: adjust scheduler cpu power Glauber Costa
2011-06-29 21:57 ` Eric B Munson
2011-06-30 21:54 ` Peter Zijlstra
2011-06-30 21:54 ` Peter Zijlstra
2011-06-30 21:54 ` Peter Zijlstra
2011-06-29 15:29 ` [PATCH v3 9/9] KVM-GST: KVM Steal time registration Glauber Costa
2011-06-29 21:57 ` Eric B Munson
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=1309361388-30163-6-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=emunson@mgebm.net \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.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
all inboxes | Powered by JetHome®