diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2011-09-14 03:58:32 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:17:05 -0500 |
commit | 3f2e5260f5a17d37be3e3c83aca2f335b9bf3893 (patch) | |
tree | a72ca61cd6b377b495b8aca591940a7b1db40882 /arch | |
parent | b297e672e24687546ac74af5ae5e8c4a022b9806 (diff) |
KVM: x86: Simplify kvm timer handler
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/timer.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c index ae432ea1cd83..6b85cc647f34 100644 --- a/arch/x86/kvm/timer.c +++ b/arch/x86/kvm/timer.c | |||
@@ -18,9 +18,10 @@ | |||
18 | #include <linux/atomic.h> | 18 | #include <linux/atomic.h> |
19 | #include "kvm_timer.h" | 19 | #include "kvm_timer.h" |
20 | 20 | ||
21 | static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer) | 21 | enum hrtimer_restart kvm_timer_fn(struct hrtimer *data) |
22 | { | 22 | { |
23 | int restart_timer = 0; | 23 | struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer); |
24 | struct kvm_vcpu *vcpu = ktimer->vcpu; | ||
24 | wait_queue_head_t *q = &vcpu->wq; | 25 | wait_queue_head_t *q = &vcpu->wq; |
25 | 26 | ||
26 | /* | 27 | /* |
@@ -40,26 +41,7 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer) | |||
40 | 41 | ||
41 | if (ktimer->t_ops->is_periodic(ktimer)) { | 42 | if (ktimer->t_ops->is_periodic(ktimer)) { |
42 | hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); | 43 | hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); |
43 | restart_timer = 1; | ||
44 | } | ||
45 | |||
46 | return restart_timer; | ||
47 | } | ||
48 | |||
49 | enum hrtimer_restart kvm_timer_fn(struct hrtimer *data) | ||
50 | { | ||
51 | int restart_timer; | ||
52 | struct kvm_vcpu *vcpu; | ||
53 | struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer); | ||
54 | |||
55 | vcpu = ktimer->vcpu; | ||
56 | if (!vcpu) | ||
57 | return HRTIMER_NORESTART; | ||
58 | |||
59 | restart_timer = __kvm_timer_fn(vcpu, ktimer); | ||
60 | if (restart_timer) | ||
61 | return HRTIMER_RESTART; | 44 | return HRTIMER_RESTART; |
62 | else | 45 | } else |
63 | return HRTIMER_NORESTART; | 46 | return HRTIMER_NORESTART; |
64 | } | 47 | } |
65 | |||