From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:55024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbeENGo2 (ORCPT ); Mon, 14 May 2018 02:44:28 -0400 Date: Mon, 14 May 2018 08:44:11 +0200 From: Greg KH To: Anthoine Bourgeois Cc: stable@vger.kernel.org, Mika =?iso-8859-1?Q?Penttil=E4?= , Wanpeng Li , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 4.14-stable] KVM: x86: remove APIC Timer periodic/oneshot spikes Message-ID: <20180514064411.GA16752@kroah.com> References: <152576372223011@kroah.com> <20180508081714.24934-1-anthoine.bourgeois@blade-group.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180508081714.24934-1-anthoine.bourgeois@blade-group.com> Sender: stable-owner@vger.kernel.org List-ID: On Tue, May 08, 2018 at 08:17:14AM +0000, Anthoine Bourgeois wrote: > commit ecf08dad723d3e000aecff6c396f54772d124733 upstream. > > Since the commit "8003c9ae204e: 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 8003c9ae204e | After 8003c9ae204e > 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 8003c9ae204e | After 8003c9ae204e > 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ä > Cc: Wanpeng Li > Cc: Paolo Bonzini > Cc: # 4.14.x > Signed-off-by: Anthoine Bourgeois > 8003c9ae204e ("KVM: LAPIC: add APIC Timer periodic/oneshot mode VMX preemption timer support") > Signed-off-by: Radim Krčmář > --- > arch/x86/kvm/lapic.c | 37 ++++++++++++++++++++----------------- > 1 file changed, 20 insertions(+), 17 deletions(-) Now applied, thanks. greg k-h