From patchwork Fri Oct 28 23:19:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 12599 Return-Path: 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 + 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 ); 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 ; Fri, 28 Oct 2022 16:19:41 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id f9so6080721pgj.2 for ; 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 To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Atish Patra , Anup Patel , Damien Le Moal , devicetree@vger.kernel.org, Jisheng Zhang , Krzysztof Kozlowski , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Rob Herring 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 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: 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?= 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 --- 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