sched: guest CPU accounting: maintain guest state in KVM
authorLaurent Vivier <Laurent.Vivier@bull.net>
Mon, 15 Oct 2007 15:00:19 +0000 (17:00 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 15 Oct 2007 15:00:19 +0000 (17:00 +0200)
Modify KVM to update guest time accounting.

[ mingo@elte.hu: ported to 2.6.24 KVM. ]

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Acked-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
drivers/kvm/kvm.h
drivers/kvm/kvm_main.c

index ad0813843adc385c43f61d9b3fdffc01e6eee965..3b0bc4bda5f2372122b7ee21b0837c4b771722d7 100644 (file)
@@ -624,6 +624,16 @@ void kvm_mmu_unload(struct kvm_vcpu *vcpu);
 
 int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
 
+static inline void kvm_guest_enter(void)
+{
+       current->flags |= PF_VCPU;
+}
+
+static inline void kvm_guest_exit(void)
+{
+       current->flags &= ~PF_VCPU;
+}
+
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
                                     u32 error_code)
 {
index 353e58527d15d6ddfbb68c392ba78054224ea19a..af2d288c881d32500a5f753cb6453432ce3b6c15 100644 (file)
@@ -2046,6 +2046,7 @@ again:
                kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run);
 
        vcpu->guest_mode = 1;
+       kvm_guest_enter();
 
        if (vcpu->requests)
                if (test_and_clear_bit(KVM_TLB_FLUSH, &vcpu->requests))
@@ -2053,6 +2054,7 @@ again:
 
        kvm_x86_ops->run(vcpu, kvm_run);
 
+       kvm_guest_exit();
        vcpu->guest_mode = 0;
        local_irq_enable();