]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: remove APIC Timer periodic/oneshot spikes
authorAnthoine Bourgeois <anthoine.bourgeois@blade-group.com>
Sun, 29 Apr 2018 22:05:58 +0000 (22:05 +0000)
committerRadim Krčmář <rkrcmar@redhat.com>
Sat, 5 May 2018 21:09:39 +0000 (23:09 +0200)
commitc66197ab7fa8805297ca44ed9e83875607a35c59
treec0f4b7e44b31b2acf06f5273f92fd23cc868ba03
parent08effcaf3547d45ff8b15021fc9a99f98f886f60
KVM: x86: remove APIC Timer periodic/oneshot spikes

Since the commit "558228078d40: add APIC Timer periodic/oneshot mode VMX
preemption timer support", a Windows 10 guest has some erratic timer
spikes.

Here the results on a 150000 times 1ms timer without any load:
  Before 558228078d40 | After 558228078d40
Max           1834us          |  86000us
Mean          1100us          |   1021us
Deviation       59us          |    149us
Here the results on a 150000 times 1ms timer with a cpu-z stress test:
  Before 558228078d40 | After 558228078d40
Max          32000us          | 140000us
Mean          1006us          |   1997us
Deviation      140us          |  11095us

The root cause of the problem is starting hrtimer with an expiry time
already in the past can take more than 20 milliseconds to trigger the
timer function.  It can be solved by forward such past timers
immediately, rather than submitting them to hrtimer_start().
In case the timer is periodic, update the target expiration and call
hrtimer_start with it.

v2: Check if the tsc deadline is already expired. Thank you Mika.
v3: Execute the past timers immediately rather than submitting them to
hrtimer_start().
v4: Rearm the periodic timer with advance_periodic_target_expiration() a
simpler version of set_target_expiration(). Thank you Paolo.

Cc: Mika Penttilä <mika.penttila@nextfour.com>
Cc: Wanpeng Li <kernellwp@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Anthoine Bourgeois <anthoine.bourgeois@blade-group.com>
558228078d40 ("KVM: LAPIC: add APIC Timer periodic/oneshot mode VMX preemption timer support")
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/lapic.c