Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 576A2C433EF for ; Sun, 20 Feb 2022 06:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2X5BUfMluA2m13wch592Icm+7lEomtqzu+fdSDUPqkU=; b=AaArNqC6lAkH64 NVzGCsMVxJmTEz8TjHn1QFWW1NHJyNxvF/tZXxw+5mP018SIkoqGMJ+5LmOBcrpU9X3HgW/yHhYyl ZZOKCcLKeIH2JieamVm7tICI+JF/xZqB9nifI/z4EbqQrqlWUIu6oReKa3QQQnFSr+kT7+2MU2AWZ P7na7qtC43sLqbr2encrq38qF9mpA5KAm7q0BpoWCJEZJ3XCUUk+ci2/kLxScnFYHq1vsw7351sp1 uoI7ABPvH7tECoXAkcYPgCV3GACbbRsP4V+xWcHt3Z9i4+ee0eEYBsOTESmx23fI09yFkIWzNhsjK zBI7uxTCeGAFmwVTF82Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLfZ9-000hZ8-Tj; Sun, 20 Feb 2022 06:19:28 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLfZ6-000hYd-7j for linux-arm-kernel@lists.infradead.org; Sun, 20 Feb 2022 06:19:25 +0000 Received: by mail-pj1-x102c.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso16060528pjg.0 for ; Sat, 19 Feb 2022 22:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AxhQxLNvA7mygJSe4CoHbzxz1WYaj+5k5Oout0vgy10=; b=ZQR3NDZ+zKn/9Aq7nzyF2Yfqp/AhR/zE7HrjcTKrwZIucPXU6uUZHCZvtvUe2FA3IG bBa0T834hqKWtSnQLM4Gk2J04msOE7R2Xw1vsKoOHWup8E7v3lm3iDXTFQufhajLp83W QnVBFJ/h1xBgtXZOGWfg1gWA33V+mCTzlEOxt/KGWM+sNdU3qc9Q1ahrZV7GxDl6S4kN aFj59jcu/RJ4JhfrxnA86Pb6pz6RHO/H5NufuUHPZvvfY59xT0mJAEx1f2WPNQvu/8Fw eZaFvuN8s/UWKg7+3wfzy75nQr5b9IpIiPsdWIzYqdt3oUdOWw9lbrwGmFrTw0OC6xP4 Z8cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AxhQxLNvA7mygJSe4CoHbzxz1WYaj+5k5Oout0vgy10=; b=JOlS/dwcNbuWGLyqqlM8/oSGiLN+uRLxYCyGz8TwuQxX/qD4voTh2SGEtgqlmXvdz3 8xyOX076gT56gS73tc7J1iBYkHhqjf5Ge6df3MH8Wi699DCY+dMx5O2lNQxt0ZCt0EL4 M/htNBC8D8X9ChGMCl94G48v8PeehA9iE2rqp5EidUEblckUGOAWaI64PmU4Cl/sc3qF ygCYnycNa28pjXI//CCH/Nc+8YqaSWvjE6dwJqM3hC79dWPZl5/cnMtJpZE+ynGcvg4R 5bOoIhhJWq0ZX/oEnInX6jL7LFe/T2IJ+1Qgo+KuEr/yKHpQVx4vQ/qPsWg3iQ5jqBeE RBng== X-Gm-Message-State: AOAM532HjoM8dwj4oh/GMm/w0kuGOmm1DXt0orlyplEnf1qBLfsSeFyX d+QTE5Lird3m0wE8ra02PTs= X-Google-Smtp-Source: ABdhPJzpDUYFD9vKBvtQV3C2vOtXz0x2vzXkeykypcsiV+otX0e4rQZ1rMoKrZpPy4gUlzkhhYqBdQ== X-Received: by 2002:a17:90a:9482:b0:1b9:aaff:7eda with SMTP id s2-20020a17090a948200b001b9aaff7edamr15680863pjo.207.1645337963478; Sat, 19 Feb 2022 22:19:23 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:afc6:e60b:3e3b:52de]) by smtp.gmail.com with ESMTPSA id 19sm7789060pfz.153.2022.02.19.22.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 22:19:23 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: maz@kernel.org, tglx@linutronix.de, will@kernel.org, linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Barry Song Subject: [PATCH v2] irqchip/gic-v3: use dsb(ishst) to synchronize data to smp before issuing ipi Date: Sun, 20 Feb 2022 19:19:10 +1300 Message-Id: <20220220061910.6155-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220219_221924_318717_6F195E49 X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Barry Song dsb(ishst) should be enough here as we only need to guarantee the visibility of data to other CPUs in smp inner domain before we send the ipi. A micro-benchmark is written to verify the performance impact on kunpeng920 machine with 2 sockets, each socket has 2 dies, and each die has 24 CPUs, so totally the system has 2 * 2 * 24 = 96 CPUs. ~2% performance improvement can be seen by this benchmark. The code of benchmark module: #include #include volatile int data0 ____cacheline_aligned; volatile int data1 ____cacheline_aligned; volatile int data2 ____cacheline_aligned; volatile int data3 ____cacheline_aligned; volatile int data4 ____cacheline_aligned; volatile int data5 ____cacheline_aligned; volatile int data6 ____cacheline_aligned; static void ipi_latency_func(void *val) { } static int __init ipi_latency_init(void) { ktime_t stime, etime, delta; int cpu, i; int start = smp_processor_id(); stime = ktime_get(); for ( i = 0; i < 1000; i++) for (cpu = 0; cpu < 96; cpu++) { data0 = data1 = data2 = data3 = data4 = data5 = data6 = cpu; smp_call_function_single(cpu, ipi_latency_func, NULL, 1); } etime = ktime_get(); delta = ktime_sub(etime, stime); printk("%s ipi from cpu%d to cpu0-95 delta of 1000times:%lld\n", __func__, start, delta); return 0; } module_init(ipi_latency_init); static void ipi_latency_exit(void) { } module_exit(ipi_latency_exit); MODULE_DESCRIPTION("IPI benchmark"); MODULE_LICENSE("GPL"); run the below commands 10 times on both Vanilla and the kernel with this patch: # taskset -c 0 insmod test.ko # rmmod test The result on vanilla: ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126757449 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126784249 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126177703 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127022281 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126184883 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127374585 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:125778089 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126974441 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127357625 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126228184 The result on the kernel with this patch: ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:124467401 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123474209 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123558497 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:122993951 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:122984223 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123323609 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:124507583 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123386963 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123340664 ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123285324 Signed-off-by: Barry Song --- -v2: add benchmark and benchmark data in commit log drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 5e935d97207d..0efe1a9a9f3b 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1211,7 +1211,7 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) * Ensure that stores to Normal memory are visible to the * other CPUs before issuing the IPI. */ - wmb(); + dsb(ishst); for_each_cpu(cpu, mask) { u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu)); -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel