Skip to content

Commit 3f2e526

Browse files
jan-kiszkaavikivity
authored andcommitted
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 <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
1 parent b297e67 commit 3f2e526

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

arch/x86/kvm/timer.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
#include <linux/atomic.h>
1919
#include "kvm_timer.h"
2020

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

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

4142
if (ktimer->t_ops->is_periodic(ktimer)) {
4243
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)
6144
return HRTIMER_RESTART;
62-
else
45+
} else
6346
return HRTIMER_NORESTART;
6447
}
65-

0 commit comments

Comments
 (0)