Skip to content

Commit

Permalink
sched: guest CPU accounting: maintain guest state in KVM
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laurent Vivier authored and Ingo Molnar committed Oct 15, 2007
1 parent 94886b8 commit d172fcd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,13 +2046,15 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
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))
kvm_x86_ops->tlb_flush(vcpu);

kvm_x86_ops->run(vcpu, kvm_run);

kvm_guest_exit();
vcpu->guest_mode = 0;
local_irq_enable();

Expand Down

0 comments on commit d172fcd

Please sign in to comment.