Message ID | 20221028231929.347918-1-atishp@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1092913wru; Fri, 28 Oct 2022 16:25:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6BYdni8u80SFo6XQkh1DBQXfxKVPW6peYG8o/NjfSVc2h8rTKCAJLpZ5Rfg7seGy3HqsHt X-Received: by 2002:a05:6402:51d0:b0:462:847f:212b with SMTP id r16-20020a05640251d000b00462847f212bmr1691297edd.397.1666999549222; Fri, 28 Oct 2022 16:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666999549; cv=none; d=google.com; s=arc-20160816; b=wDU4G1iuMgczCpBywKLny9wf7b2G1D7pcxRc5e53GJnl3WGJzzGfRODO7YLw0wbjT/ dLdYrwdZFUQRH/GBQZtiW6eQsXri0bje2nxXFPIz57/NykdUI8e1OiF8jBUfNGHoNTpc 1ARWyAXOYpbUwqJB5dYYGsSChYzsFpwcsHdjpuY7R6GDVZp/Atl83HZmtfEf1KTuoCVN q78LVJu0uGSdDgd3UZTH1wPWNSxKakNkxnYSHzUqoXAIu/q11gJKh+h32cVlHRv0FtV1 i1GQ7pDDIsFfFJ6ND+sqK9yvbE0PhKDd2cVHs0XQNoGrV/NrdX/THDy7W33Ji46NTHwt HOVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vdbgZ8+Fu6n0HK4tgOaOYq43eN2AjNjj/Lhga+VAiyM=; b=FhhRtUtTkW76i7PMyFiqZivLtEdYuKIKDnG98+/T+s4L+9k9G7I/pxi5bqd6dLkWXU PnVQhccPTIGw2UKSLnkFrE5EUBW657PGBm8ARxRv6JGrVtNzbfjMu0x43y/suypEx5y9 86SADHdMarFWq9xQEsMR4NurJkJBInsFKnO+gTYr4qApgVM6k1r89q9nXG/v+Xsm3Qy3 aEKmjyU7e8+9SoaOVfgWb/ZwYUxbDWt8d4ZN706NyNAxPrXDKdGEgw1pbIgyx2YOkSuF jI3yar7pfd17fgtosTHGylcRKr+QRG1BjzQAM3VfRuDlokTdHeRBaILlRc9ax0Goelsx apeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=aMw3oUjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a509e8b000000b00461ea502defsi5942554edf.350.2022.10.28.16.25.25; Fri, 28 Oct 2022 16:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=aMw3oUjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbiJ1XTq (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Fri, 28 Oct 2022 19:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiJ1XTm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Oct 2022 19:19:42 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B6C1FD35 for <linux-kernel@vger.kernel.org>; Fri, 28 Oct 2022 16:19:41 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id f9so6080721pgj.2 for <linux-kernel@vger.kernel.org>; Fri, 28 Oct 2022 16:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vdbgZ8+Fu6n0HK4tgOaOYq43eN2AjNjj/Lhga+VAiyM=; b=aMw3oUjEz8KxyX5NRy8i43+HJNi8jXjsGtcRnti8nSdP4d/D/7x/NYETkIaL+23EEd 37AA/MvumskK4g5anPHvbmKTEazSBxU8xWFpbfzNfVoHL8XP0rk5+6xe+EiYp19r4lgg 3E2+1UsnCFUXhBv/6PElhfyEisP2ddRRJSTJQBGQiJch9HkvDg9XowGTYV86BxzccqYz woDM+lrq8UDV+DZZ021IjdtLqgVhH6v9U57om+imUTcuJkGHkuke/Q/IBc/q3cH2Vblp rbMzYHQKFrzrAiJ7g5Rku+VyVCcvidbHmCvRJM8e14ayWyUZFgykrPs9tabdGTJCZyeb IAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vdbgZ8+Fu6n0HK4tgOaOYq43eN2AjNjj/Lhga+VAiyM=; b=5L0UciDwA9JSw+SzINCy2vtn9ML2XsuqTGx6/S7CAHiTgLBeXxoeu5T84rrV+W/hls 5udyafOEcG7wtKQcmp0WY799kT8JpwriSHEndEUOfg2ZowPEl9fKfQc6N4Woh2BALxHA SIgwnYfdOV2vCKYTF1z+r9JitBICao6wXBes/UOqCHpbMpZ4kA4CNPYlb9SiHtw0WHCn LEfRugqi6PE2mv/CGeSTaCZyWEOI7mzKYAC/NeghwHv/1cuXD2u8cBdsO4YWtYw/VNrs mjQUZxmapXdBmSnuvtncgeEBBMurFlXhAPCA+vYgCgnFVUeOIPCA8OlfjaYCiKg50drH ZdoQ== X-Gm-Message-State: ACrzQf39qTC5VqgVHayQ1OtqWH/H/kynfnzpxEhrEjrz8h+g1e9QQ3X+ 8QmXR5f/SdMiOXDCIisUNUCBGw8Cu4EeCA== X-Received: by 2002:a63:69c2:0:b0:46a:eeb1:e784 with SMTP id e185-20020a6369c2000000b0046aeeb1e784mr1617170pgc.589.1666999180528; Fri, 28 Oct 2022 16:19:40 -0700 (PDT) Received: from rivos-atish.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id jb5-20020a170903258500b00176ea6ce0efsm1335plb.109.2022.10.28.16.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 16:19:40 -0700 (PDT) From: Atish Patra <atishp@rivosinc.com> To: linux-kernel@vger.kernel.org Cc: Atish Patra <atishp@rivosinc.com>, Albert Ou <aou@eecs.berkeley.edu>, Atish Patra <atishp@atishpatra.org>, Anup Patel <anup@brainfault.org>, Damien Le Moal <damien.lemoal@wdc.com>, devicetree@vger.kernel.org, Jisheng Zhang <jszhang@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>, linux-riscv@lists.infradead.org, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Rob Herring <robh+dt@kernel.org> Subject: [PATCH] RISC-V: Do not issue remote fences until smp is available Date: Fri, 28 Oct 2022 16:19:29 -0700 Message-Id: <20221028231929.347918-1-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747975719460305525?= X-GMAIL-MSGID: =?utf-8?q?1747975719460305525?= |
Series |
RISC-V: Do not issue remote fences until smp is available
|
|
Commit Message
Atish Patra
Oct. 28, 2022, 11:19 p.m. UTC
It is useless to issue remote fences if there is a single core
available. It becomes a bottleneck for sbi based rfences where
we will be making those ECALLs for no reason. Early code patching
because of static calls end up in this path.
Signed-off-by: Atish Patra <atishp@rivosinc.com>
---
arch/riscv/mm/cacheflush.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Fri, Oct 28, 2022 at 04:19:29PM -0700, Atish Patra wrote: > It is useless to issue remote fences if there is a single core > available. It becomes a bottleneck for sbi based rfences where > we will be making those ECALLs for no reason. Early code patching > because of static calls end up in this path. > > Signed-off-by: Atish Patra <atishp@rivosinc.com> Hey Atish, This doesn't apply for me to either fixes or for-next. What branch does it apply to? Thanks, Conor. > --- > arch/riscv/mm/cacheflush.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > index f10cb47eac3a..7fafc8c26505 100644 > --- a/arch/riscv/mm/cacheflush.c > +++ b/arch/riscv/mm/cacheflush.c > @@ -19,6 +19,10 @@ void flush_icache_all(void) > { > local_flush_icache_all(); > > + /* No need to issue remote fence if only 1 cpu is online */ > + if (num_online_cpus() == 1) > + return; > + > if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence()) > sbi_remote_fence_i(NULL); > else > -- > 2.34.1 >
On Mon, Oct 31, 2022 at 12:12 PM Conor Dooley <conor@kernel.org> wrote: > > On Fri, Oct 28, 2022 at 04:19:29PM -0700, Atish Patra wrote: > > It is useless to issue remote fences if there is a single core > > available. It becomes a bottleneck for sbi based rfences where > > we will be making those ECALLs for no reason. Early code patching > > because of static calls end up in this path. > > > > Signed-off-by: Atish Patra <atishp@rivosinc.com> > > Hey Atish, > This doesn't apply for me to either fixes or for-next. What branch does > it apply to? > Thanks, > Conor. > > > --- > > arch/riscv/mm/cacheflush.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > > index f10cb47eac3a..7fafc8c26505 100644 > > --- a/arch/riscv/mm/cacheflush.c > > +++ b/arch/riscv/mm/cacheflush.c > > @@ -19,6 +19,10 @@ void flush_icache_all(void) > > { > > local_flush_icache_all(); > > > > + /* No need to issue remote fence if only 1 cpu is online */ > > + if (num_online_cpus() == 1) > > + return; > > + > > if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence()) > > sbi_remote_fence_i(NULL); > > else > > -- > > 2.34.1 > > Sorry I forgot to specify the dependencies for this patch. This patch is based on Anup's IPI series [1] as I assumed the IPI series would go first. I can rebase on top of the master if required. However, the issue will manifest only after Jisheng's patch[2] which moved the sbi_init to earlier and introduced the static key in the paging_init path. [1] https://patchwork.kernel.org/project/linux-riscv/patch/20220820065446.389788-8-apatel@ventanamicro.com/ [2] https://lore.kernel.org/lkml/20220716115059.3509-1-jszhang@kernel.org/ -- Regards, Atish
On Mon, 31 Oct 2022 12:26:05 PDT (-0700), atishp@atishpatra.org wrote: > On Mon, Oct 31, 2022 at 12:12 PM Conor Dooley <conor@kernel.org> wrote: >> >> On Fri, Oct 28, 2022 at 04:19:29PM -0700, Atish Patra wrote: >> > It is useless to issue remote fences if there is a single core >> > available. It becomes a bottleneck for sbi based rfences where >> > we will be making those ECALLs for no reason. Early code patching >> > because of static calls end up in this path. >> > >> > Signed-off-by: Atish Patra <atishp@rivosinc.com> >> >> Hey Atish, >> This doesn't apply for me to either fixes or for-next. What branch does >> it apply to? >> Thanks, >> Conor. >> >> > --- >> > arch/riscv/mm/cacheflush.c | 4 ++++ >> > 1 file changed, 4 insertions(+) >> > >> > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c >> > index f10cb47eac3a..7fafc8c26505 100644 >> > --- a/arch/riscv/mm/cacheflush.c >> > +++ b/arch/riscv/mm/cacheflush.c >> > @@ -19,6 +19,10 @@ void flush_icache_all(void) >> > { >> > local_flush_icache_all(); >> > >> > + /* No need to issue remote fence if only 1 cpu is online */ >> > + if (num_online_cpus() == 1) >> > + return; >> > + >> > if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence()) >> > sbi_remote_fence_i(NULL); >> > else >> > -- >> > 2.34.1 >> > > > Sorry I forgot to specify the dependencies for this patch. This patch > is based on Anup's IPI series [1] as > I assumed the IPI series would go first. I can rebase on top of the > master if required. > However, the issue will manifest only after Jisheng's patch[2] which > moved the sbi_init to earlier and introduced the > static key in the paging_init path. > > [1] https://patchwork.kernel.org/project/linux-riscv/patch/20220820065446.389788-8-apatel@ventanamicro.com/ > [2] https://lore.kernel.org/lkml/20220716115059.3509-1-jszhang@kernel.org/ IMO we should just stop issuing the SBI remote fences at all, with the code to do IPI-based fences we're just adding complexity for the slow case.
On Thu, Nov 10, 2022 at 1:42 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Mon, 31 Oct 2022 12:26:05 PDT (-0700), atishp@atishpatra.org wrote: > > On Mon, Oct 31, 2022 at 12:12 PM Conor Dooley <conor@kernel.org> wrote: > >> > >> On Fri, Oct 28, 2022 at 04:19:29PM -0700, Atish Patra wrote: > >> > It is useless to issue remote fences if there is a single core > >> > available. It becomes a bottleneck for sbi based rfences where > >> > we will be making those ECALLs for no reason. Early code patching > >> > because of static calls end up in this path. > >> > > >> > Signed-off-by: Atish Patra <atishp@rivosinc.com> > >> > >> Hey Atish, > >> This doesn't apply for me to either fixes or for-next. What branch does > >> it apply to? > >> Thanks, > >> Conor. > >> > >> > --- > >> > arch/riscv/mm/cacheflush.c | 4 ++++ > >> > 1 file changed, 4 insertions(+) > >> > > >> > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > >> > index f10cb47eac3a..7fafc8c26505 100644 > >> > --- a/arch/riscv/mm/cacheflush.c > >> > +++ b/arch/riscv/mm/cacheflush.c > >> > @@ -19,6 +19,10 @@ void flush_icache_all(void) > >> > { > >> > local_flush_icache_all(); > >> > > >> > + /* No need to issue remote fence if only 1 cpu is online */ > >> > + if (num_online_cpus() == 1) > >> > + return; > >> > + > >> > if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence()) > >> > sbi_remote_fence_i(NULL); > >> > else > >> > -- > >> > 2.34.1 > >> > > > > > Sorry I forgot to specify the dependencies for this patch. This patch > > is based on Anup's IPI series [1] as > > I assumed the IPI series would go first. I can rebase on top of the > > master if required. > > However, the issue will manifest only after Jisheng's patch[2] which > > moved the sbi_init to earlier and introduced the > > static key in the paging_init path. > > > > [1] https://patchwork.kernel.org/project/linux-riscv/patch/20220820065446.389788-8-apatel@ventanamicro.com/ > > [2] https://lore.kernel.org/lkml/20220716115059.3509-1-jszhang@kernel.org/ > > IMO we should just stop issuing the SBI remote fences at all, with the > code to do IPI-based fences we're just adding complexity for the slow > case. Sure. We can do that too. However, that will have some performance impact for any platform(existing and future ones) without imsic. Is that acceptable ? Maybe it will encourage every vendor to implement AIA instead of PLIC ;) -- Regards, Atish
diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index f10cb47eac3a..7fafc8c26505 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -19,6 +19,10 @@ void flush_icache_all(void) { local_flush_icache_all(); + /* No need to issue remote fence if only 1 cpu is online */ + if (num_online_cpus() == 1) + return; + if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence()) sbi_remote_fence_i(NULL); else