Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4405408ybv; Tue, 25 Feb 2020 19:33:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyfCCMBivMHXXObLi7XAXsieOiw7wjkK0J6GlaVrMASlZGWkgILCZU7SMNBlsJfvxB8cCwb X-Received: by 2002:aca:b70a:: with SMTP id h10mr1719104oif.20.1582688005877; Tue, 25 Feb 2020 19:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582688005; cv=none; d=google.com; s=arc-20160816; b=sOR2iYBZ8n7gN+yTc/hZX1Wc9YOf9hXY3tglhkwt0I2oGAtstUMSYt6p/IFDzw/GyX 54ehRkjI4SQPZKPw/RyVXCxCmbB95Ivz1wBaGcvaul6tcIDP8p5j3su3ewor/Ujib/1S dYAgktb3dG1H7vlGjLp/lrkQuudpFkcowoYias1tcKskF9EPGnLMnmG9aAXskNEIAyCA 9qBAY6erDXUDS/Th5gE4IWQy3+lA4lSCoONHUrVMAez8HOhots0ZQ7z+Yf93vyJlITge bLSm/mOkpFtCrEdQS8XTrKspuXzsOqo7pR9ce5Qel1hmXIr4RTkP9604f+nrObKF8FTe gVSw== 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=nAuQSDRahRWvh/vYkNzOtlSh60I0RAv61gNTFTFOsjs=; b=NfCDs9dGp1kYW5c4QKKol+12sNPoUKoxBtZgMTtZ/7+Ji3njpz7+bSEhZfs3+Z77ww RrQormfpARrWxbR1dMcGu6sY9mT8lng7U4OekoDqD8Fk+K/1GLx1AiQnYO3lhfGdhH21 fp83hG4B7u5LxTKR1vIHsjtHpXJ+eVY5W+noBlXYLKWfS3DMCi3yuQmUC/MXqc20QgHM I6smOOp2BRjNpYRM0VdleTDc6MSIPRFfeeoCcwBnQQNHeoxT637bcUPXxD/7f3YrXiwi PWyNr15lnp2hL652YIYqIBzaArb5CZdDJuoLDM0ZjWq38Z7AOMubUCGt0zs4ZVG6utmq jfoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RJqqS7hk; 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 n1si556924otf.102.2020.02.25.19.33.11; Tue, 25 Feb 2020 19:33:25 -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=RJqqS7hk; 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 S1727187AbgBZDdG (ORCPT + 99 others); Tue, 25 Feb 2020 22:33:06 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34314 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbgBZDdG (ORCPT ); Tue, 25 Feb 2020 22:33:06 -0500 Received: by mail-ot1-f65.google.com with SMTP id j16so1698091otl.1; Tue, 25 Feb 2020 19:33:05 -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=nAuQSDRahRWvh/vYkNzOtlSh60I0RAv61gNTFTFOsjs=; b=RJqqS7hkNae+vFD3w5QVk5o9bnNDLXSHHp1dt++J5YWq3q7h3yFv2pj54P3Y4whroz HcyQXYoBbEPewRaT2Fv8HCA1fg8I1buEob6QCR6uo2lGtTr23YukvZ5tykoUbJYR/pX+ dbJ8oQSMdEm9pwu0CnwHSrHnTOp7WiB1K5Wkt56u9ihEBN758F/igzkb2srNE+GvwUdH OXOm+0lfUtuWt0TYYLC0wX8/VIIunY+ydePvKsHh4EAUp5LVtRue0a5JK7LHCB4GGDYu 2tZlr5TApNnDS18QiUwO9TnJ2YJXwyKlUuAwdDpp0vu5gdrGWZWU7IRaDkpVxB1kH+md wtrA== 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=nAuQSDRahRWvh/vYkNzOtlSh60I0RAv61gNTFTFOsjs=; b=rpddsdwvu7sXv+9v+b67PxZbEHHfUCHXRjvI5dJBCCHrBsWwUL4k9I5FsCn7VLehCz wWJ/z+vD+9zT8/9PBN43iDGWAQhsSetBh7S8CI1YcVQIxEZG7ojPSEqckD6MaPqaKDmd OscWqLG9Ed0mI/ZMCCib0zJAoOtGYPXcpGZkiJ65Tj45q0awGPrvV5i2/xKMOVOurDGF 5+NSkxOu5rdykL8a3+uDelY5rQq64oGg86ZnfyUlMV8BBkP6TA/jcebJAgoTgNkd22TM EjCHzn/cuflrDHYpkuLIUBZn5jdKFJJ5014kth4vCcRQrZTfM8a5MlVqkg0NW4K6hKlh ukXA== X-Gm-Message-State: APjAAAWBCmToMoZ1pnA27TnT6mQvwomMRryH84uGph5Aq732n4WBDjLB n3ksTVGzfhKyMJNSTWrF9Vr2eIoEPxbvGuIg74RuToC4S7POFw== X-Received: by 2002:a9d:63d6:: with SMTP id e22mr1421440otl.185.1582687984972; Tue, 25 Feb 2020 19:33:04 -0800 (PST) MIME-Version: 1.0 References: <1574306232-872-1-git-send-email-wanpengli@tencent.com> In-Reply-To: <1574306232-872-1-git-send-email-wanpengli@tencent.com> From: Wanpeng Li Date: Wed, 26 Feb 2020 11:32:53 +0800 Message-ID: Subject: Re: [PATCH v4 1/2] KVM: VMX: FIXED+PHYSICAL mode single target IPI fastpath To: LKML , kvm Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Liran Alon 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 11:17, 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. > > This patch introduce a mechanism to handle certain performance-critical > WRMSRs 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 > delivery-mode and single target. Which was found as one of the main cause= s > of VMExits for 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 st= age > of KVM VMExit handler, before host interrupts are enabled and before expe= nsive > 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). > > Testing on Xeon Skylake server: > > The virtual IPI latency from sender send to receiver receive reduces > more than 200+ cpu cycles. Testing by IPI microbenchmark(https://lkml.org/lkml/2017/12/19/141): Normal IPI: Improved 3% Broadcast IPI: Improved 5% w/ --overcommit cpu-pm=3Don Normal IPI: Improved 14% Broadcast IPI: Improved 3.6% Wanpeng