Skip to content

Commit

Permalink
KVM: x86: Simplify kvm timer handler
Browse files Browse the repository at this point in the history
The vcpu reference of a kvm_timer can't become NULL while the timer is
valid, so drop this redundant test. This also makes it pointless to
carry a separate __kvm_timer_fn, fold it into kvm_timer_fn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Jan Kiszka authored and Avi Kivity committed Dec 27, 2011
1 parent b297e67 commit 3f2e526
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions arch/x86/kvm/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#include <linux/atomic.h>
#include "kvm_timer.h"

static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
{
int restart_timer = 0;
struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
struct kvm_vcpu *vcpu = ktimer->vcpu;
wait_queue_head_t *q = &vcpu->wq;

/*
Expand All @@ -40,26 +41,7 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)

if (ktimer->t_ops->is_periodic(ktimer)) {
hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
restart_timer = 1;
}

return restart_timer;
}

enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
{
int restart_timer;
struct kvm_vcpu *vcpu;
struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);

vcpu = ktimer->vcpu;
if (!vcpu)
return HRTIMER_NORESTART;

restart_timer = __kvm_timer_fn(vcpu, ktimer);
if (restart_timer)
return HRTIMER_RESTART;
else
} else
return HRTIMER_NORESTART;
}

0 comments on commit 3f2e526

Please sign in to comment.