Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp373528ybc; Tue, 12 Nov 2019 02:52:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxbFXk2aHktHdZNHHkpMSG4/EFK0vB/ygFvqwK2f3ycaK2QcCux/DaAToZ/JS38LZDPLJbx X-Received: by 2002:a17:906:8697:: with SMTP id g23mr2655098ejx.177.1573555931593; Tue, 12 Nov 2019 02:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573555931; cv=none; d=google.com; s=arc-20160816; b=CNrUS+ZT3m4X6hyZuaDTndMmhEbevzkf0EzRfHFijwsw+1nm3K7vAbkqOTyx5AY7Q4 aya27N/WN7gDdvtL79+2la9l7cFDjsVkvwDuVmdZuC/Sl+qPz8uRFxOV//fvVYOaeZRW Tjp14ekzvK1Dk3Jx1cgZpJorTqno49la2Bnoxt/Dk1a2GqJc2B77dKcGdDybpKsR1l8I eg706ziaQukNIMgeqqeHXLopaayNvOLX1tNNRXHflMhrFW1oyLijuhWFsc/6mpSxRovI UUUTuGrAXtVy4NsQrfu52XL84ER9Kw3VFjbN09hCRKUeQpWAEbvW3d6QAZQPAkLkq90B v1Og== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=YzGU4275F60THwnrmJ8+5uShGAqb9m33BRttc64NVUY=; b=OHWDZM+/2HyH0jnTEwwmYvovr7qYSd36tqmeRFWgHDqDFjqSgy5WsGo8f2CmQzMCQL H9+kg63l4qEKRKH2gaYbKv6K4L927LsX8eQBAMAPTCPpwlBfDTdCTFQLkwLYzd1MOhF2 zZKPVENgyC5NxinQY/V9eFbz9NzN7Zu8qMPA6ggctECIraKFTZBbqTbwLVA73mbyFWm3 6ivtYR+HI6zBHoPJBWjH3bEjbCbstYDvuCki/YfgIiDyrMDVM/cxqSz0sir7aTPmHThh mFO22mEd14GLrhHm2fLLZDSed+DWx+RcS/ChgoqauSdYGjRNacmjiU4FniyiRfRp7KiJ vGIQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q44si13753549eda.242.2019.11.12.02.51.46; Tue, 12 Nov 2019 02:52:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726959AbfKLKuJ (ORCPT + 99 others); Tue, 12 Nov 2019 05:50:09 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:33276 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbfKLKuJ (ORCPT ); Tue, 12 Nov 2019 05:50:09 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iUTkJ-0008AZ-Hy; Tue, 12 Nov 2019 11:50:03 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 1BC081C0357; Tue, 12 Nov 2019 11:50:03 +0100 (CET) Date: Tue, 12 Nov 2019 10:50:02 -0000 From: "tip-bot2 for Vitaly Kuznetsov" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/hyperv] x86/hyperv: Micro-optimize send_ipi_one() Cc: Vitaly Kuznetsov , Thomas Gleixner , Michael Kelley , Roman Kagan , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191027151938.7296-1-vkuznets@redhat.com> References: <20191027151938.7296-1-vkuznets@redhat.com> MIME-Version: 1.0 Message-ID: <157355580264.29376.16644467726067576044.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/hyperv branch of tip: Commit-ID: b264f57fde0c686c5c1dfdd0c21992c49196bb87 Gitweb: https://git.kernel.org/tip/b264f57fde0c686c5c1dfdd0c21992c49196bb87 Author: Vitaly Kuznetsov AuthorDate: Sun, 27 Oct 2019 16:19:38 +01:00 Committer: Thomas Gleixner CommitterDate: Tue, 12 Nov 2019 11:44:20 +01:00 x86/hyperv: Micro-optimize send_ipi_one() When sending an IPI to a single CPU there is no need to deal with cpumasks. With 2 CPU guest on WS2019 a minor (like 3%, 8043 -> 7761 CPU cycles) improvement with smp_call_function_single() loop benchmark can be seeb. The optimization, however, is tiny and straitforward. Also, send_ipi_one() is important for PV spinlock kick. Switching to the regular APIC IPI send for CPU > 64 case does not make sense as it is twice as expesive (12650 CPU cycles for __send_ipi_mask_ex() call, 26000 for orig_apic.send_IPI(cpu, vector)). Signed-off-by: Vitaly Kuznetsov Signed-off-by: Thomas Gleixner Reviewed-by: Michael Kelley Reviewed-by: Roman Kagan Link: https://lkml.kernel.org/r/20191027151938.7296-1-vkuznets@redhat.com --- arch/x86/hyperv/hv_apic.c | 16 +++++++++++++--- arch/x86/include/asm/trace/hyperv.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c index 5c056b8..86c8674 100644 --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -194,10 +194,20 @@ do_ex_hypercall: static bool __send_ipi_one(int cpu, int vector) { - struct cpumask mask = CPU_MASK_NONE; + int vp = hv_cpu_number_to_vp_number(cpu); - cpumask_set_cpu(cpu, &mask); - return __send_ipi_mask(&mask, vector); + trace_hyperv_send_ipi_one(cpu, vector); + + if (!hv_hypercall_pg || (vp == VP_INVAL)) + return false; + + if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR)) + return false; + + if (vp >= 64) + return __send_ipi_mask_ex(cpumask_of(cpu), vector); + + return !hv_do_fast_hypercall16(HVCALL_SEND_IPI, vector, BIT_ULL(vp)); } static void hv_send_ipi(int cpu, int vector) diff --git a/arch/x86/include/asm/trace/hyperv.h b/arch/x86/include/asm/trace/hyperv.h index ace464f..4d705cb 100644 --- a/arch/x86/include/asm/trace/hyperv.h +++ b/arch/x86/include/asm/trace/hyperv.h @@ -71,6 +71,21 @@ TRACE_EVENT(hyperv_send_ipi_mask, __entry->ncpus, __entry->vector) ); +TRACE_EVENT(hyperv_send_ipi_one, + TP_PROTO(int cpu, + int vector), + TP_ARGS(cpu, vector), + TP_STRUCT__entry( + __field(int, cpu) + __field(int, vector) + ), + TP_fast_assign(__entry->cpu = cpu; + __entry->vector = vector; + ), + TP_printk("cpu %d vector %x", + __entry->cpu, __entry->vector) + ); + #endif /* CONFIG_HYPERV */ #undef TRACE_INCLUDE_PATH