From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: Re: [PATCH v4] KVM: halt-polling: poll for the upcoming fire timers Date: Tue, 24 May 2016 19:15:14 +0200 Message-ID: <57448C22.2030504@de.ibm.com> References: <1464076674-4024-1-git-send-email-wanpeng.li@hotmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Wanpeng Li , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Matlack , Yang Zhang To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Return-path: Received: from e06smtp08.uk.ibm.com ([195.75.94.104]:60592 "EHLO e06smtp08.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254AbcEXRPd (ORCPT ); Tue, 24 May 2016 13:15:33 -0400 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 May 2016 18:15:29 +0100 In-Reply-To: <1464076674-4024-1-git-send-email-wanpeng.li@hotmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/24/2016 09:57 AM, Wanpeng Li wrote: > From: Wanpeng Li >=20 > If an emulated lapic timer will fire soon(in the scope of 10us the > base of dynamic halt-polling, lower-end of message passing workload > latency TCP_RR's poll time < 10us) we can treat it as a short halt, > and poll to wait it fire, the fire callback apic_timer_fn() will set > KVM_REQ_PENDING_TIMER, and this flag will be check during busy poll. > This can avoid context switch overhead and the latency which we wake > up vCPU. >=20 > This feature is slightly different from current advance expiration=20 > way. Advance expiration rely on the vCPU is running(do polling before= =20 > vmentry). But in some cases, the timer interrupt may be blocked by=20 > other thread(i.e., IF bit is clear) and vCPU cannot be scheduled to=20 > run immediately. So even advance the timer early, vCPU may still see=20 > the latency. But polling is different, it ensures the vCPU to aware=20 > the timer expiration before schedule out. >=20 > echo HRTICK > /sys/kernel/debug/sched_features in dynticks guests. >=20 > Context switching - times in microseconds - smaller is better > ---------------------------------------------------------------------= ---- > Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16= p/64K > ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw c= txsw > --------- ------------- ------ ------ ------ ------ ------ ------- --= ----- > kernel Linux 4.6.0+ 7.9800 11.0 10.8 14.6 9.4300 13.0 = 10.2 vanilla > kernel Linux 4.6.0+ 15.3 13.6 10.7 12.5 9.0000 12.8 7.= 38000 poll >=20 > Cc: Paolo Bonzini > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > Cc: David Matlack > Cc: Christian Borntraeger > Cc: Yang Zhang > Signed-off-by: Wanpeng Li > --- > v3 -> v4: > * add module parameter halt_poll_ns_timer > * rename patch subject since lapic maybe just for x86. > v2 -> v3: > * add Yang's statement to patch description > v1 -> v2: > * add return statement to non-x86 archs > * capture never expire case for x86 (hrtimer is not started) >=20 > arch/arm/include/asm/kvm_host.h | 4 ++++ > arch/arm64/include/asm/kvm_host.h | 4 ++++ > arch/mips/include/asm/kvm_host.h | 4 ++++ > arch/powerpc/include/asm/kvm_host.h | 4 ++++ > arch/s390/include/asm/kvm_host.h | 4 ++++ > arch/x86/kvm/lapic.c | 11 +++++++++++ > arch/x86/kvm/lapic.h | 1 + > arch/x86/kvm/x86.c | 5 +++++ > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 15 +++++++++++---- > 10 files changed, 49 insertions(+), 4 deletions(-) [...] @@ -1966,7 +1970,7 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vc= pu) > grow =3D READ_ONCE(halt_poll_ns_grow); > /* 10us base */ > if (val =3D=3D 0 && grow) > - val =3D 10000; > + val =3D halt_poll_ns_timer; Drop this hunk and leave this at 10000, so that a user can disable the = timer=20 logic, but keep the old polling? > else > val *=3D grow; >=20 >=20