From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hollis Blanchard Subject: Re: [kvm-devel] Use virtual cpu accounting if available for guest times. Date: Fri, 19 Oct 2007 11:57:36 -0500 Message-ID: <1192813056.10451.6.camel@basalt> References: <47135D1B.1060004@bull.net> <11926264852739-git-send-email-Laurent.Vivier@bull.net> <200710181439.10390.borntraeger@de.ibm.com> Reply-To: Hollis Blanchard Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm-devel , Laurent Vivier , linux-kernel@vger.kernel.org To: Christian Borntraeger Return-path: In-Reply-To: <200710181439.10390.borntraeger@de.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, 2007-10-18 at 14:39 +0200, Christian Borntraeger wrote: > Avi, > > ppc and s390 offer the possibility to track process times precisely > by looking at cpu timer on every context switch, irq, softirq etc. > We can use that infrastructure as well for guest time accounting. > We need to account the used time before we change the state. > This patch adds a call to account_system_vtime to kvm_guest_enter > and kvm_guest exit. If CONFIG_VIRT_CPU_ACCOUNTING is not set, > account_system_vtime is defined in hardirq.h as an empty function, > which means this patch does not change the behaviour on other > platforms. > > I compile tested this patch on x86 and function tested the patch on > s390. > > Avi, please apply. > > > Signed-off-by: Christian Borntraeger > > --- > drivers/kvm/kvm.h | 3 +++ > 1 file changed, 3 insertions(+) > > Index: kvm/drivers/kvm/kvm.h > =================================================================== > --- kvm.orig/drivers/kvm/kvm.h > +++ kvm/drivers/kvm/kvm.h > @@ -7,6 +7,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -669,11 +670,13 @@ __init void kvm_arch_init(void); > > static inline void kvm_guest_enter(void) > { > + account_system_vtime(current); > current->flags |= PF_VCPU; > } > > static inline void kvm_guest_exit(void) > { > + account_system_vtime(current); > current->flags &= ~PF_VCPU; > } I don't understand. Should kvm_guest_exit() be calling account_user_vtime() (instead of account_system_vtime())? -- Hollis Blanchard IBM Linux Technology Center