Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6930372ybx; Mon, 11 Nov 2019 17:36:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxRkS6oSUKN+C0QnrFmuLdJ3KXrZ8yd+fu0P2th/3xBWfx3GMAGHX+8XeTckn9NGTyhEnZg X-Received: by 2002:a17:906:2786:: with SMTP id j6mr25601018ejc.206.1573522617410; Mon, 11 Nov 2019 17:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573522617; cv=none; d=google.com; s=arc-20160816; b=ZBZC8jDv8LE7ASL2QTCCXQ2d8P53tjGS0twvyEaO4T2DijXrmtpg/CXkT5UQU45WYO N8JQHnPC0VLVj5LH2oNnzFNnQPpr5Yanc+kriaEuyoh7Ceo77nNjoO87PXc/YoRcG9LM nY5YoVG89WHD7L6rOBnthWXGrV1Y1HKbkA0IT20trxNn8oBp7KLilFvPfIdymeEhX0Jj d65dbm85nOkUc3wCjEaOSYa99Cf2kxGmhw4igSLlicKAY5+NCWu5lmm8a2BzyfTlZhw9 s867Yxte0LqfSwXc+/DwUsjvXFvxjhlyySqm7K7w+ZYGWzbygPkw6I1OeF0pRaJWADSY nXow== 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=nCXnq6KfTcW48HdT/UVgMIRXRm8X+Lrr6IQKnNcG3B8=; b=ctA5v6LV3qz2WsnK705RB9J6ytxIE7M6W6aAJTVgo2Xca5zS/ZImFle/Ciz3jRhm3w Zr5DQS7R5QPciPZD56m9TmJvy7TerqfytFPa4NofhTOyn35eGenC1bV3ENZCW4KXS1Ua fHKuEpzAl3kuO/YbY5kc27VeQaR56J8xpLhkQOKvGUBjSBoIr9AaElKRmsbx79Js/W1F oEuGPIUGoh9UG3yM6hXDS0s76OsZeAugOv5lThlFdSgJJW/Bqopa4bB5qkzF8Ut9L9SJ DOszukcyDSdWUbM9CUbyAUKv2l5K9GHziYGWRFJBx3B9T2FK/6zIiivlFAj91zS6qvbg pkkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ario+ujY; 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 g5si11537004ejr.415.2019.11.11.17.36.32; Mon, 11 Nov 2019 17:36:57 -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=Ario+ujY; 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 S1727069AbfKLBeC (ORCPT + 99 others); Mon, 11 Nov 2019 20:34:02 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46410 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726928AbfKLBeC (ORCPT ); Mon, 11 Nov 2019 20:34:02 -0500 Received: by mail-ot1-f68.google.com with SMTP id n23so12915891otr.13; Mon, 11 Nov 2019 17:34:00 -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=nCXnq6KfTcW48HdT/UVgMIRXRm8X+Lrr6IQKnNcG3B8=; b=Ario+ujY8q3eOROTO8GLVkJJ9yLO2y/AkEe4/OrjczRsfMg0o6vljnEDoZiBp6QwWa YR5IZ5uW48wzJ/GrXjaw+fdVR0GpefkE8QpIcXNUw6N1Ry4yF6NkgCneKBRpuWf35szD xvbRESTqqUXBMBBTCYYEX8SQncXTOjpLPFaFRatHB38sfSK8MNULTNYYoy3K533Erm9H ZUGWdo95SMoWIJidYue9zO0CWzpL9AipHzsXrJ7yPz0VPC79LsGeAHyjPiSn9NC9DSgT txut7L+czczUhDe4Eh2LA1ljqU5AfnFZ1HS29MQc2wvkJ9EI7+XqYCHuIYe69RssAlac KHVQ== 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=nCXnq6KfTcW48HdT/UVgMIRXRm8X+Lrr6IQKnNcG3B8=; b=B9gvA/MGzw5gYuQcoJ7WB72yZOkAZKI8+1HuFzupfkxLC73WdKuiYoO4+ARjd7dU+G jSvMrLZJ4ZGX/ZjHlR0eK62hBosRFA/hEALSEV/PlZ8km0E3JiyQlFc7PaGczWEhTL5i UnirqFPtUxjKcXhhNiAADn7J5bnQG0pYGEIWrYBukWOdbgorl8ikIHCSk0EIkIjPpLNJ jfKIkDskJTsrYicqVrPCgK98N1KtvcAzWU3/h7kpUcTtgmCyp/wjndInpEE4usK6OqwM SmODu2PMaIwfJxxxGX43LUTBe/UsOEDaZSt7/ikw7gzkVYZZjzVM9T0XlRVmuhyZ9Rnq lgSw== X-Gm-Message-State: APjAAAXCTRL0gw/1ob6ZGEfbZBFZb4Q/OiDQEg8dqmn0zzNE6+mlea3e N2XXz+5ZUFw7FijEDp0olrRAjAS4sOUR+FVqNmGvTg4w X-Received: by 2002:a9d:b83:: with SMTP id 3mr22827187oth.56.1573522439777; Mon, 11 Nov 2019 17:33:59 -0800 (PST) MIME-Version: 1.0 References: <1573283135-5502-1-git-send-email-wanpengli@tencent.com> <4418c734-68e1-edaf-c939-f24d041acf2e@redhat.com> In-Reply-To: <4418c734-68e1-edaf-c939-f24d041acf2e@redhat.com> From: Wanpeng Li Date: Tue, 12 Nov 2019 09:33:49 +0800 Message-ID: Subject: Re: [PATCH 1/2] KVM: X86: Single target IPI fastpath To: Paolo Bonzini Cc: LKML , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , 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 Tue, 12 Nov 2019 at 05:59, Paolo Bonzini wrote: > > On 09/11/19 08:05, Wanpeng Li wrote: > > From: Wanpeng Li > > > > This patch tries to optimize x2apic physical destination mode, fixed delivery > > mode single target IPI by delivering IPI to receiver immediately after sender > > writes ICR vmexit to avoid various checks when possible. > > > > Testing on Xeon Skylake server: > > > > The virtual IPI latency from sender send to receiver receive reduces more than > > 330+ cpu cycles. > > > > Running hackbench(reschedule ipi) in the guest, the avg handle time of MSR_WRITE > > caused vmexit reduces more than 1000+ cpu cycles: > > > > Before patch: > > > > VM-EXIT Samples Samples% Time% Min Time Max Time Avg time > > MSR_WRITE 5417390 90.01% 16.31% 0.69us 159.60us 1.08us > > > > After patch: > > > > VM-EXIT Samples Samples% Time% Min Time Max Time Avg time > > MSR_WRITE 6726109 90.73% 62.18% 0.48us 191.27us 0.58us > > Do you have retpolines enabled? The bulk of the speedup might come just > from the indirect jump. Adding 'mitigations=off' to the host grub parameter: Before patch: VM-EXIT Samples Samples% Time% Min Time Max Time Avg time MSR_WRITE 2681713 92.98% 77.52% 0.38us 18.54us 0.73us ( +- 0.02% ) After patch: VM-EXIT Samples Samples% Time% Min Time Max Time Avg time MSR_WRITE 2953447 92.48% 62.47% 0.30us 59.09us 0.40us ( +- 0.02% ) Actually, this is not the first attempt to add shortcut for MSR writes which performance sensitive, the other effort is tscdeadline timer from Isaku Yamahata, https://patchwork.kernel.org/cover/10541035/ , ICR and TSCDEADLINE MSR writes cause the main MSR write vmexits in our product observation, multicast IPIs are not as common as unicast IPI like RESCHEDULE_VECTOR and CALL_FUNCTION_SINGLE_VECTOR etc. As far as I know, something similar to this patch has already been deployed in some cloud companies private kvm fork. Wanpeng