Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2701323ybc; Wed, 20 Nov 2019 19:20:36 -0800 (PST) X-Google-Smtp-Source: APXvYqy9B5O6HqjKlXQcChcGyQA/YR0FXSGNiyLUX3e4fEO2n4qdv3pyuXBsf8PiRcaN/e2fKyOQ X-Received: by 2002:a17:906:80c:: with SMTP id e12mr10426482ejd.59.1574306436716; Wed, 20 Nov 2019 19:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574306436; cv=none; d=google.com; s=arc-20160816; b=RtL/lEaUAauzrRc/00KA/nOIgxirzAJJ0lemvUipi7gKGznKf/yzjjkHaEDgZElsI3 B0ldsFCrhHCAnUnlMKPYOCiWYiiHclqALjKndUQFl37K8xZcm1jTV6cOc+fyzp6UZpEG jyD9YujVHnDWSxUAvtDDcI8G7Ykk/AnKIOk6jN3dJXDI9QCegqkX1iByLb4zwjtARudO cTtYiKZYBYOiEK7gC0vuVMoWC5j1CFvu5O8gt9Man4IXjI5wTw5KJYLxpF4J0//7idDo K8f+bkDeliHjA6fv+JUkVKS8faYHQBNWzNbxRbMrPpHuI+l0bzx8Y+GvWWIWtQO+Lj67 MSKA== 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=W8NJFXMq1hP4Qw4qrsGTgJ6LydZYVSf7XvUILF35TkI=; b=lssj0UYVFWJW733sesJYldscKKwRL4kzzIM1sbx5EYziHoFRZHDrR0AyB2Xf4v81Jj RTm/qIQHLtyHrKNhrKgeOs8aaIHC2W6xskFo9ROPwgl775RswDL+WSpNL+7rb1M5zFeX u264FviL7ZXLlehXAZIZ/dvvjNgFTnGOBjcPjtNzJWtHbhyKIcEKUMnL9abW0tfnig0F LoT82uTNb9MpDMIFQ7UD+wuPrI+79BomsbWSi7Wt01ct1lQuOmnI5RSfx9kizTlb1r2y i4dwNqX5fK9LOeGmBd/ji5cHMsBYsfvLICdoaXOijq8SrgRRyhJmyUt+Z2Ke9sHUtk2+ YXSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e42q5Dt7; 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 a60si1253884edf.169.2019.11.20.19.20.12; Wed, 20 Nov 2019 19:20:36 -0800 (PST) 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=e42q5Dt7; 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 S1726573AbfKUDQq (ORCPT + 99 others); Wed, 20 Nov 2019 22:16:46 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:43318 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfKUDQp (ORCPT ); Wed, 20 Nov 2019 22:16:45 -0500 Received: by mail-ot1-f67.google.com with SMTP id l14so1617095oti.10; Wed, 20 Nov 2019 19:16:45 -0800 (PST) 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=W8NJFXMq1hP4Qw4qrsGTgJ6LydZYVSf7XvUILF35TkI=; b=e42q5Dt7gHmj9sk3HkUelEJSbwzQa5GeZLVk7+svkiu0ehkrRBfykcQ7JH7/X6HYA4 I46io4ICsit03LC1b71x8Wt4azLEocRlomjDC7ZBqnF/2uHf8hjdFDUXD1GjPJ4C6Pk5 KrsXjEKiTB+reJQkXh+sxGCfu1iGhnDnozGVrq0nLC15xL3XqvGQLwuC0aFConcDXfWs /WE7bWtY+LdFihCVHTT4zg2eEGo1cAcsnyyzAwbG+PU++U9ZRFGOlhziGvL0nUEE3NC/ dbnmlEJnWthi9pC7mJLqwYNrlzriPq7xtlaXUjHtUzqwtmEhdcY5wH0ArmZFz7Zts+Be Cnhw== 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=W8NJFXMq1hP4Qw4qrsGTgJ6LydZYVSf7XvUILF35TkI=; b=Lf5kAgzpfOXG12qeMYiSPeeQHEsBVZtg67YO863L7A16TIvFUdXMqzvO7zK7gpXEMk sFDEW+YmPpsvSuBzMKFUTAE2gE31QLxhUfhl3ZA/lCrEdH6Pyz2GQJe9ESw20LwrJJv9 7cSMBK91nmGT/1S8MrqF3kiQWhtLpqwuugzmJHff+JKfd9puuAbxaTLg8Snl7tuZemx6 2hzBYhwHzd3rdwN55CZLr/DGhabGtDIWz2Zg/xjXdZp+rS0W22PFq7blTvMfJ7Ca9e+G 0hpz+Xk0Tgvhpu4d8Bvkz+Z3A+Ia7jHauCcLrXC9cTdCHmZJmCui5J8BV4AoGX+znGCY wlLQ== X-Gm-Message-State: APjAAAXPmolPXkdKzZjnXisB9uJkLdA4/3vYvH8/1/Or2JSJ6W8JV5WC L/PI1rQ9wgN/7kLgvp2ixT5MD/gbhUVrfW1WFad5Lg== X-Received: by 2002:a9d:b83:: with SMTP id 3mr4524380oth.56.1574306204696; Wed, 20 Nov 2019 19:16:44 -0800 (PST) MIME-Version: 1.0 References: <1574221329-12370-1-git-send-email-wanpengli@tencent.com> <61E34902-0743-4DAF-A7DF-94C0E51CDA08@oracle.com> In-Reply-To: <61E34902-0743-4DAF-A7DF-94C0E51CDA08@oracle.com> From: Wanpeng Li Date: Thu, 21 Nov 2019 11:16:36 +0800 Message-ID: Subject: Re: [PATCH v3 1/2] KVM: VMX: FIXED+PHYSICAL mode single target IPI fastpath To: Liran Alon Cc: LKML , kvm , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel 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 Thu, 21 Nov 2019 at 07:37, Liran Alon wrote: > > > > > On 20 Nov 2019, at 5:42, Wanpeng Li wrote: > > > > From: Wanpeng Li > > > > ICR and TSCDEADLINE MSRs write cause the main MSRs write vmexits in > > our product observation, multicast IPIs are not as common as unicast > > IPI like RESCHEDULE_VECTOR and CALL_FUNCTION_SINGLE_VECTOR etc. > > Have you also had the chance to measure non-Linux workloads. Such as Wind= ows? I ask around, guys not pay attention to IPIs under windows guests before. > > > > > This patch tries to optimize x2apic physical destination mode, fixed > > delivery mode single target IPI. The fast path is invoked at > > ->handle_exit_irqoff() to emulate only the effect of the ICR write > > itself, i.e. the sending of IPIs. Sending IPIs early in the VM-Exit > > flow reduces the latency of virtual IPIs by avoiding the expensive bits > > of transitioning from guest to host, e.g. reacquiring KVM's SRCU lock. > > Especially when running guest w/ KVM_CAP_X86_DISABLE_EXITS capability > > enabled or guest can keep running, IPI can be injected to target vCPU > > by posted-interrupt immediately. > > May I suggest an alternative phrasing? Something such as: Great, thanks for better English. > > =E2=80=9C=E2=80=9D=E2=80=9D > This patch introduce a mechanism to handle certain performance-critical W= RMSRs > in a very early stage of KVM VMExit handler. > > This mechanism is specifically used for accelerating writes to x2APIC ICR= that > attempt to send a virtual IPI with physical destination-mode, fixed deliv= ery-mode > and single target. Which was found as one of the main causes of VMExits f= or > Linux workloads. > > The reason this mechanism significantly reduce the latency of such virtua= l IPIs > is by sending the physical IPI to the target vCPU in a very early stage o= f KVM > VMExit handler, before host interrupts are enabled and before expensive > operations such as reacquiring KVM=E2=80=99s SRCU lock. > Latency is reduced even more when KVM is able to use APICv posted-interru= pt > mechanism (which allows to deliver the virtual IPI directly to target vCP= U without > the need to kick it to host). > =E2=80=9C=E2=80=9D=E2=80=9D > > > > > Testing on Xeon Skylake server: > > > > The virtual IPI latency from sender send to receiver receive reduces > > more than 200+ cpu cycles. > > > > Cc: Paolo Bonzini > > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > > Cc: Sean Christopherson > > Cc: Vitaly Kuznetsov > > Cc: Liran Alon > > Signed-off-by: Wanpeng Li > > I see you used the code I provided my reply to v2. :) > I had only some very minor comments inline below. Therefore: > Reviewed-by: Liran Alon Thanks, handle them in v4. > > Thanks for doing this optimisation. Thanks everybody who help make this work nice. :) Wanpeng