Re: [RESEND 2][PATCH 4/4] Modify KVM to update guest time accounting.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Laurent Vivier <Laurent.Vivier@...>
Cc: Avi Kivity <avi@...>, Ingo Molnar <mingo@...>, linux-kernel <linux-kernel@...>
Date: Monday, October 15, 2007 - 10:39 am

Am Montag, 15. Oktober 2007 schrieb Laurent Vivier:

I think we can merge your patches, as the userspace interface seems fine. To 
make the accounting work for virtual cpu accounting found on ppc and s390 we
can later add an additional patch that also deals with interruptible guest 
contexts.
So something like this should work:

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

---
 drivers/kvm/kvm.h |    8 ++++++++
 kernel/sched.c    |    2 ++
 2 files changed, 10 insertions(+)

Index: kvm/drivers/kvm/kvm.h
===================================================================
--- kvm.orig/drivers/kvm/kvm.h
+++ kvm/drivers/kvm/kvm.h
@@ -18,6 +18,7 @@
 
 #include <linux/kvm.h>
 #include <linux/kvm_para.h>
+#include <asm/system.h>
 
 #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)
 #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
@@ -675,11 +676,18 @@ __init void kvm_arch_init(void);
 
 static inline void kvm_guest_enter(void)
 {
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+	account_system_vtime(current);
+#endif
 	current->flags |= PF_VCPU;
 }
 
 static inline void kvm_guest_exit(void)
 {
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+	account_system_vtime(current);
+	current->flags &= ~PF_VCPU;
+#endif
 }
 
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
Index: kvm/kernel/sched.c
===================================================================
--- kvm.orig/kernel/sched.c
+++ kvm/kernel/sched.c
@@ -3312,7 +3312,9 @@ void account_system_time(struct task_str
 
 	if (p->flags & PF_VCPU) {
 		account_guest_time(p, cputime);
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
 		p->flags &= ~PF_VCPU;
+#endif
 		return;
 	}
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RESEND 2][PATCH 4/4] Modify KVM to update guest , Christian Borntraeger, (Mon Oct 15, 7:19 am)
[PATCH] move kvm_guest_exit() after local_irq_enable(), Laurent Vivier, (Thu Oct 18, 9:19 am)
[PATCH] clear PF_VCPU in kvm_guest_exit(), Laurent Vivier, (Wed Oct 17, 9:08 am)
Use virtual cpu accounting if available for guest times., Christian Borntraeger, (Thu Oct 18, 8:39 am)
Re: [kvm-devel] Use virtual cpu accounting if available for ..., Hollis Blanchard, (Fri Oct 19, 12:57 pm)
Re: [PATCH] clear PF_VCPU in kvm_guest_exit(), Avi Kivity, (Wed Oct 17, 10:16 am)
Re: [PATCH] clear PF_VCPU in kvm_guest_exit(), Laurent Vivier, (Wed Oct 17, 11:09 am)
Re: [PATCH] clear PF_VCPU in kvm_guest_exit(), Christian Borntraeger, (Wed Oct 17, 9:18 am)
Re: [RESEND 2][PATCH 4/4] Modify KVM to update guest , Christian Borntraeger, (Mon Oct 15, 7:33 am)
Re: [RESEND 2][PATCH 4/4] Modify KVM to update guest time ac..., Christian Borntraeger, (Mon Oct 15, 10:39 am)