Commit e56a7a28 authored by Christian Borntraeger's avatar Christian Borntraeger Committed by Avi Kivity

KVM: Use virtual cpu accounting if available for guest times.

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.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 8a7ae055
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <linux/hardirq.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -671,11 +672,13 @@ __init void kvm_arch_init(void); ...@@ -671,11 +672,13 @@ __init void kvm_arch_init(void);
static inline void kvm_guest_enter(void) static inline void kvm_guest_enter(void)
{ {
account_system_vtime(current);
current->flags |= PF_VCPU; current->flags |= PF_VCPU;
} }
static inline void kvm_guest_exit(void) static inline void kvm_guest_exit(void)
{ {
account_system_vtime(current);
current->flags &= ~PF_VCPU; current->flags &= ~PF_VCPU;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment