Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp68449ybi; Tue, 18 Jun 2019 17:35:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLVlQ5XhGPB+w9h/BaIP8ol95B15mACuef/enIxwbEnEMc9AnhNArHzxVyjPN+3cj86HLw X-Received: by 2002:a63:360d:: with SMTP id d13mr5162396pga.80.1560904521298; Tue, 18 Jun 2019 17:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560904521; cv=none; d=google.com; s=arc-20160816; b=qIk87mGH4+X+9yV5ERZAc4u2TauvKeJ7kolO+bznKJSEMJ5oh4orXyhLehq7yVsmGd Nj/l5vfD73QYrsVcWnK8yJ9d+N8L3bccmuaHJIgol/oDY4KpKh4yt+ZClyrly+ChDJTs syF8CYd+hxhAowd0A5YFaqucAsNxQWKCZy9/goLQrfGzRscZi1FcM+P+ZOMA/0HbuUdP 49E/XSIL9uxRoSnT4kyTvaRdbhJKTOp35/1jWxAfQhV9jkQRBQK80nK/Z9SJpI7E/+hP BpZiK/LbsN53X+v69G4UHIgvyqSv+s2CXKD8g/kmZv9AxOQAZoZfmZAbY9qEiP6vEM3l 3BaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZXR7tAPaEkwGsGkQZyrZdvvi0BeI2lp41nwHf5CBMnU=; b=Dan63lnpNXVfnpOxUlxGyod3medKaTyRHVNDB92OZWMQjskGk2Tuj6+1+zRroBy9J+ AgeUqLOVof3bSrj8xV6hNnQnAz3Da1H0mhA+XwwoN7tEibNrzgzUxtulrKR7gaP/0mbQ F95TQqGk1iXMc0zRUBxL2ClWPXL2cZ9VyHGmtqkk6uagzq4ALZWuGO+ifokw3tVOzK1+ fgkPOUjrA1UFcl3IeJ9r3dMZvw7nf6JeKR4swz6nsxK/XNblL2khrqaqJPM1vbOPaHE8 iOGHLnVrTXNsjXDYjiZpjWVcTbHK3rWV6g4rGFDkzUYk4G4Obx95JqWo2oVhZ5dCiLs5 UI7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tIZk7NtZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si1535116pgs.34.2019.06.18.17.35.02; Tue, 18 Jun 2019 17:35:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tIZk7NtZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbfFSAev (ORCPT + 99 others); Tue, 18 Jun 2019 20:34:51 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:39949 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbfFSAev (ORCPT ); Tue, 18 Jun 2019 20:34:51 -0400 Received: by mail-ot1-f65.google.com with SMTP id e8so16485968otl.7; Tue, 18 Jun 2019 17:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZXR7tAPaEkwGsGkQZyrZdvvi0BeI2lp41nwHf5CBMnU=; b=tIZk7NtZsCu5f5iH8jH7Sa9+vz4sThRbI8n900KepBBMPO2KBKQ4P0tmwTLwU+t4c0 iEbUWDIPY/MBKqIEUNWjnEKN/vHeUN9U9LUMOHm41ETRZ2S1HBBvgkBjRF9ReJjfIhFq YiHSgQsCcRgDQ/PJOsxP5TEMBXgCZMFZVXRK4EvagCy+O4FBmQDyqRmHeP0yw3vcjL5b LSDJM7RVbToEUj/1LDk+K9x7/qEZ/yh3k3hcAiGmPEUrIf+Xm4COAT8BuRH/TtVRr19D BkjvlVpM3qYoErrvF3tXVWK4wMZaLwLftJywBnznYDxLJkE5nqUN87pGVHKp2dwivtNk j7WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZXR7tAPaEkwGsGkQZyrZdvvi0BeI2lp41nwHf5CBMnU=; b=ALIVh11S7t/lyFaeU6jDkShP+skQYsr99xTWJpt4Gdt6eif7CBnCYxMF8hW9fHPV2K lWlzySeSnD2aONFNe8HLxXudtoLIjxMR6NSZnZIE8o27L3cW1G/CqhmlXqSAwSjlg5Oz 3CdfN1JjIxotHQX0bmOIlG0UmKkxjm6zM6/QO8+JlAjne3of9kSJ06DsfrGpn3GOftDk 9I7iTtM1E0BztIcDf/ikqjzlGZm3vJb01mMjJeeBPGYyAo9HfnB1b1c9csPNZek1k4c1 AoNe3U9CeOGkdE+VtlQCcsX83ngmyOeTiKRrPbQwCMKna+w3kT2aDL+cPzMjLk27KarU UpBw== X-Gm-Message-State: APjAAAXD/ZYdJiPfj5AncUXeh558lEjNgSRcU2R+KJsLGGuQaWvA+g7C RTI8cryAqHsiE/WFD3LfcdRv4Mazz/5zQQvZTDzCnt4y X-Received: by 2002:a9d:2c47:: with SMTP id f65mr69195620otb.185.1560904490828; Tue, 18 Jun 2019 17:34:50 -0700 (PDT) MIME-Version: 1.0 References: <1560770687-23227-1-git-send-email-wanpengli@tencent.com> <1560770687-23227-3-git-send-email-wanpengli@tencent.com> <20190618133541.GA3932@amt.cnet> In-Reply-To: <20190618133541.GA3932@amt.cnet> From: Wanpeng Li Date: Wed, 19 Jun 2019 08:36:06 +0800 Message-ID: Subject: Re: [PATCH v4 2/5] KVM: LAPIC: inject lapic timer interrupt by posted interrupt To: Marcelo Tosatti Cc: Paolo Bonzini , LKML , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Jun 2019 at 21:36, Marcelo Tosatti wrote: > > On Mon, Jun 17, 2019 at 07:24:44PM +0800, Wanpeng Li wrote: > > From: Wanpeng Li > > > > Dedicated instances are currently disturbed by unnecessary jitter due > > to the emulated lapic timers fire on the same pCPUs which vCPUs residen= t. > > There is no hardware virtual timer on Intel for guest like ARM. Both > > programming timer in guest and the emulated timer fires incur vmexits. > > This patch tries to avoid vmexit which is incurred by the emulated > > timer fires in dedicated instance scenario. > > > > When nohz_full is enabled in dedicated instances scenario, the emulated > > timers can be offload to the nearest busy housekeeping cpus since APICv > > is really common in recent years. The guest timer interrupt is injected > > by posted-interrupt which is delivered by housekeeping cpu once the emu= lated > > timer fires. > > > > The host admin should fine tuned, e.g. dedicated instances scenario w/ > > nohz_full cover the pCPUs which vCPUs resident, several pCPUs surplus > > for busy housekeeping, disable mwait/hlt/pause vmexits to keep in non-r= oot > > mode, ~3% redis performance benefit can be observed on Skylake server. > > > > w/o patch: > > > > VM-EXIT Samples Samples% Time% Min Time Max Time Av= g time > > > > EXTERNAL_INTERRUPT 42916 49.43% 39.30% 0.47us 106.09us 0.= 71us ( +- 1.09% ) > > > > w/ patch: > > > > VM-EXIT Samples Samples% Time% Min Time Max Time = Avg time > > > > EXTERNAL_INTERRUPT 6871 9.29% 2.96% 0.44us 57.88us 0.= 72us ( +- 4.02% ) > > > > Cc: Paolo Bonzini > > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > > Cc: Marcelo Tosatti > > Signed-off-by: Wanpeng Li > > --- > > arch/x86/kvm/lapic.c | 33 ++++++++++++++++++++++++++------- > > arch/x86/kvm/lapic.h | 1 + > > arch/x86/kvm/vmx/vmx.c | 3 ++- > > arch/x86/kvm/x86.c | 5 +++++ > > arch/x86/kvm/x86.h | 2 ++ > > include/linux/sched/isolation.h | 2 ++ > > kernel/sched/isolation.c | 6 ++++++ > > 7 files changed, 44 insertions(+), 8 deletions(-) > > > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > > index 87ecb56..9ceeee5 100644 > > --- a/arch/x86/kvm/lapic.c > > +++ b/arch/x86/kvm/lapic.c > > @@ -122,6 +122,13 @@ static inline u32 kvm_x2apic_id(struct kvm_lapic *= apic) > > return apic->vcpu->vcpu_id; > > } > > > > +bool posted_interrupt_inject_timer(struct kvm_vcpu *vcpu) > > +{ > > + return pi_inject_timer && kvm_vcpu_apicv_active(vcpu) && > > + kvm_hlt_in_guest(vcpu->kvm); > > +} > > +EXPORT_SYMBOL_GPL(posted_interrupt_inject_timer); > > Paolo, can you explain the reasoning behind this? > > Should not be necessary... Here some new discussions: https://lkml.org/lkml/2019/6/13/1423 https://lkml.org/lkml/2019/6/13/1420