diff options
Diffstat (limited to 'arch/x86/kvm/timer.c')
-rw-r--r-- | arch/x86/kvm/timer.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c index 85cc743a8203..1baed414b57a 100644 --- a/arch/x86/kvm/timer.c +++ b/arch/x86/kvm/timer.c | |||
@@ -9,12 +9,16 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer) | |||
9 | int restart_timer = 0; | 9 | int restart_timer = 0; |
10 | wait_queue_head_t *q = &vcpu->wq; | 10 | wait_queue_head_t *q = &vcpu->wq; |
11 | 11 | ||
12 | /* FIXME: this code should not know anything about vcpus */ | 12 | /* |
13 | if (!atomic_inc_and_test(&ktimer->pending)) | 13 | * There is a race window between reading and incrementing, but we do |
14 | set_bit(KVM_REQ_PENDING_TIMER, &vcpu->requests); | 14 | * not care about potentially loosing timer events in the !reinject |
15 | 15 | * case anyway. | |
16 | if (!ktimer->reinject) | 16 | */ |
17 | atomic_set(&ktimer->pending, 1); | 17 | if (ktimer->reinject || !atomic_read(&ktimer->pending)) { |
18 | /* FIXME: this code should not know anything about vcpus */ | ||
19 | if (!atomic_inc_and_test(&ktimer->pending)) | ||
20 | set_bit(KVM_REQ_PENDING_TIMER, &vcpu->requests); | ||
21 | } | ||
18 | 22 | ||
19 | if (waitqueue_active(q)) | 23 | if (waitqueue_active(q)) |
20 | wake_up_interruptible(q); | 24 | wake_up_interruptible(q); |