Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2619481ybc; Wed, 20 Nov 2019 17:37:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwDWEjxQGtEHU5CbM3XcmRy2dtiK4K4UXVKEFhB01UmeYrVNM6x1kOpQPTnd0TqZuqyULzO X-Received: by 2002:a17:906:8319:: with SMTP id j25mr9313894ejx.170.1574300249475; Wed, 20 Nov 2019 17:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574300249; cv=none; d=google.com; s=arc-20160816; b=qt8kh+Ql6eA2/941tdEP2Z2j6sQEU/Xj1FHBQAZ5+9nPGOR5d62YkU506JzOvoLBFE v9LAHNrhjafah8KACdHSH/ccJAIQt6j9mJn435FJ3nNT8rpno6PJrxR9mjfsRj39+OBu KOUBK9H6jjfi2U4kG8tWdNsYi6EtdsERS/1f9FyxNlWgbt5kjJCb5MQUXCWipJRnHuQw Nn0BvC8QE66PlYND3k4mA4VuXFIPTAHoJQqu4rOTc5QTJPM72WAF7GMSYzRGOQDA+SSF c2+fw5CCAcF8mC8VmgU0A4YdJGdVL9LkrOmNyLJAuenzwTVyk4mSTCiNqrN7j3hlBOFP ZD2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lpEa+/BRm24XesFPsnNk5cI0mT1TDDR8Zk/jTKgI6uM=; b=WkCeJJ8SBXSll55+DlSnETdEYRtdCtPo5PyIWY+/qJHdekhf76e4mMGvCfc+cH8v+x d4VeiYShxO6CLbJT0/TLat5JBk9xWuo2JTjYzN1b7yEUeo1fc8wSsK5j2E/xTxpbakA1 WnmxzPdrVv4AE8AHATlsZdrwOOKCIKJ2EurkbYwsBKHvpscTY6dq1fYi/KcA4rJBx7Fc d1Ve5ejZ6iWT4rYlQAesix7DQGnhryqsbFkRYDKQiDr38McDZF342ysIPz4RYszXmou2 onlGklHBR3S1GYEIK+cn4XRL57zXEDjKyjnuds+l4W/vKE0exq7WGuI4i+DtNBWE5vGZ zU0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hCQOu+Rt; 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 h21si1003159edb.20.2019.11.20.17.37.05; Wed, 20 Nov 2019 17:37:29 -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=hCQOu+Rt; 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 S1726664AbfKUBen (ORCPT + 99 others); Wed, 20 Nov 2019 20:34:43 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:33833 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbfKUBen (ORCPT ); Wed, 20 Nov 2019 20:34:43 -0500 Received: by mail-oi1-f196.google.com with SMTP id l202so1738533oig.1; Wed, 20 Nov 2019 17:34:43 -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; bh=lpEa+/BRm24XesFPsnNk5cI0mT1TDDR8Zk/jTKgI6uM=; b=hCQOu+RtXc+YXfM1Aja28NLxoCRtfmCn2qZbMjZj5luctKt9TvpQsZJerrqPznbs1n K3zr4y7z2dA/M6CkglXs6aS7AVLpRj+13QF0doj3sxcoOFQh7uc2Xx+ZLc7+bYvrHkRz yStcTqVPDo0yD6y94m9A7mG+48ywg401un2aDv8C+VEyfNA1eRFgF3PAPc2w0m/K5HlA Tx4ryfdHVA65brhhxqvEwtu5vGwhB7H/1CILjybawf+/N98lrvo8TdI4GCWms8H01oKP g51T6XE+PtDo8agk1mKeP5FfxSj/CxM4+KOgLR4rYj1IyCToj20LOLNn9VhXGfgVvW9k iG+w== 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; bh=lpEa+/BRm24XesFPsnNk5cI0mT1TDDR8Zk/jTKgI6uM=; b=IGitO5EUApfom5R3MAXyNda+NUwDasz4Ak8+ZSzIKfCH1t5I2P4nf0bGHU4tLg0sVK HahU4W9+ZL2e53ZUM5c+u/eWF5fteoL58vkfLRKRKvlznjTczMh5VA+cR2u+94r05QXR PSt0HoWl0jsxLhL7gBiq6wTU+h3UqrfyGShvNDSix17oyNA01C3Acx4RWhLOQJ5FdckU t0t3nfmDD2JoXJZy2+ARVz55obEFCsTZ5sXlnx1o/Ciyu8UysV/Snc7t9J02IMzL1er4 RIRrWMp5nmf7Vfn9mLBmNx59MwAVbL/3vx+9S1oVYRvlEzdWfwOn6IKzD34+vMo7MxLZ dodQ== X-Gm-Message-State: APjAAAU3YsjgfZJ3VPZCKYeIIDeVdP3Vu0nGmV8Ef0EnIFU4tx2AohoJ pmqqNooQAFElKRNs8lfRWXbtfxH6zwULeXhXkzI= X-Received: by 2002:aca:c50f:: with SMTP id v15mr5658442oif.5.1574300082776; Wed, 20 Nov 2019 17:34:42 -0800 (PST) MIME-Version: 1.0 References: <1574145389-12149-1-git-send-email-wanpengli@tencent.com> <09CD3BD3-1F5E-48DA-82ED-58E3196DBD83@oracle.com> <20191120170228.GC32572@linux.intel.com> In-Reply-To: <20191120170228.GC32572@linux.intel.com> From: Wanpeng Li Date: Thu, 21 Nov 2019 09:34:34 +0800 Message-ID: Subject: Re: [PATCH v2 1/2] KVM: VMX: FIXED+PHYSICAL mode single target IPI fastpath To: Sean Christopherson Cc: Liran Alon , LKML , kvm , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Content-Type: text/plain; charset="UTF-8" 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 01:02, Sean Christopherson wrote: > > On Wed, Nov 20, 2019 at 11:49:36AM +0800, Wanpeng Li wrote: > > On Tue, 19 Nov 2019 at 20:11, Liran Alon wrote: > > > > + > > > > +static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu, u32 *exit_reason) > > > > { > > > > struct vcpu_vmx *vmx = to_vmx(vcpu); > > > > > > > > @@ -6231,6 +6263,8 @@ static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu) > > > > handle_external_interrupt_irqoff(vcpu); > > > > else if (vmx->exit_reason == EXIT_REASON_EXCEPTION_NMI) > > > > handle_exception_nmi_irqoff(vmx); > > > > + else if (vmx->exit_reason == EXIT_REASON_MSR_WRITE) > > > > + *exit_reason = handle_ipi_fastpath(vcpu); > > > > > > 1) This case requires a comment as the only reason it is called here is an > > > optimisation. In contrast to the other cases which must be called before > > > interrupts are enabled on the host. > > > > > > 2) I would rename handler to handle_accel_set_msr_irqoff(). To signal this > > > handler runs with host interrupts disabled and to make it a general place > > > for accelerating WRMSRs in case we would require more in the future. > > > > Yes, TSCDEADLINE/VMX PREEMPTION TIMER is in my todo list after this merged > > upstream, handle all the comments in v3, thanks for making this nicer > > further. :) > > Handling those is very different than what is being proposed here though. > For this case, only the side effect of the WRMSR is being expedited, KVM > still goes through the heavy VM-Exit handler path to handle emulating the > WRMSR itself. > > To truly expedite things like TSCDEADLINE, the entire emulation of WRMSR > would need be handled without going through the standard VM-Exit handler, > which is a much more fundamental change to vcpu_enter_guest() and has > different requirements. For example, keeping IRQs disabled is pointless > for generic WRMSR emulation since the interrupt will fire as soon as KVM > resumes the guest, whereas keeping IRQs disabled for processing ICR writes > is a valid optimization since recognition of the IPI on the dest vCPU > isn't dependent on KVM resuming the current vCPU. > > Rather than optimizing full emulation flows one at a time, i.e. exempting > the ICR case, I wonder if we're better off figuring out a way to improve > the performance of VM-Exit handling at a larger scale, e.g. avoid locking > kvm->srcu unnecessarily, Andrea's retpolin changes, etc... I use the latest kvm/queue, so Andrea's patch is there. As you know, improve the performance of vmexit is a long term effort. But, let's make v4 upstream firstly. :) Wanpeng