Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4049773rwb; Sun, 30 Jul 2023 23:44:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpadvFRVBk/QGDXgE6CuscM3M/O7sYLS2yiQ+hiU3wQjFUg+g5QMKb+zZVoad2ALrcaYMa X-Received: by 2002:a17:90a:bf08:b0:268:93d:b936 with SMTP id c8-20020a17090abf0800b00268093db936mr6952216pjs.18.1690785863915; Sun, 30 Jul 2023 23:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690785863; cv=none; d=google.com; s=arc-20160816; b=WHCiBKRTShh6BGMjDyoTS8f2yRJE1L9LHsibnmlI+sTDeYK9aIgU1E4B4uDoTpSnKB DKNq/1FXrHzdN4ImY91T1deMFpkO04n36Uc7WJLevyjTmOfV8FvYGSJsE9vN2CcljNIO Cd9dfiT1RpmYoEsyAb9W5KUl6Iu/bzAkQ8wIt6LAw4E1GXZ5RBWNSqo4Ts3u4PIrey5q VzInXiZI/ezOlimiXQt1U5SkuXvzb8/frregoFccNHX3QSMhXg6WUdBIFxwyXWVPkttu WdKlu/qNDepI7ehJQ1VujwW9EYeOoavQ4poVj3AHmldmCNEQML3RjQFRVinbXtvO67Rr 2ccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=UrQ44egSsYKrgrC8lXSaEIOM2nJnUB+IsN4O98912zA=; fh=8bH0S7d6/o8uETp9H0ZW7stpVmPLtZ0QSFiOvruwQmc=; b=ssoc3VUNP1xAcaiYzF7dE9bJKGy+WazgyBDEutFG+QreYd514YqEwL2v9novaatc2g ZpEPu7AuBKL3Bk77vFstIFoRQHxH9z8ki6zl5QU43G7xPogaxKK5vv/zbJDu3emDnl4X WGQM9f1xjisXw2+883u2Nhxnn1/g6TyHqxWAHbCBSOoBkusXm932mpHUPIeSfIIhPNgp b6m7s30sCTHXKGiJX6oLyb7Dgf2L9O2WzM4YMmgrAKe7S/jMuB4KhTdlpNl7gxK1ClCZ pJ4A2Rihatv6WTbJuHO5QzYmJpZMA+0ioKGf8eXnPKjlUi43dQhgBtKGpEeP5QLEyl0p CXUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=db2uzzxQ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=SfnVnfPX; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a17090a39c700b00262c7b59f4esi2540069pjf.188.2023.07.30.23.44.12; Sun, 30 Jul 2023 23:44:23 -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=@arndb.de header.s=fm2 header.b=db2uzzxQ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=SfnVnfPX; 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 S229880AbjGaFkE (ORCPT + 99 others); Mon, 31 Jul 2023 01:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbjGaFj6 (ORCPT ); Mon, 31 Jul 2023 01:39:58 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1597010F5; Sun, 30 Jul 2023 22:39:55 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 7F2155C0103; Mon, 31 Jul 2023 01:39:52 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Mon, 31 Jul 2023 01:39:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1690781992; x=1690868392; bh=UrQ44egSsYKrgrC8lXSaEIOM2nJnUB+IsN4 O98912zA=; b=db2uzzxQtgivo508fRTO8f4XT0UETH9ryLw+9yH+LWGIeJWJsCJ HyAkf5A99D/hyoKbJOko/ceLBuwZp2QtRooFcET2ZSJwaqbE4XTiUv+2ML8KaYYr tt8Ij6oLz9J3q18bAAOJaYnkH6yKUrILmwSFmfJM13iSYvenRqhyQQqGJh7PJCgB Kk6ktQNggVLNepXFQkg9hrbSvPSYoyF9eAs0xMuHa3xVMrzH5dMfaQUjEpSG2CHo mZKgUWbVbnZpTXQCcByWUxXsR5+0RmMUIfNBtlHVn4/qTnbVbb6vHbK6G5qFeXe9 dlcwt1USgct6rxxQiGj/1DBjCiZXcngSYUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1690781992; x=1690868392; bh=UrQ44egSsYKrgrC8lXSaEIOM2nJnUB+IsN4 O98912zA=; b=SfnVnfPXXL3mwHIIIuxPP6P+wTbpKu+T6nwkEpJpH+uTqi10iQl lD6rkBhcUmKB0he2oTsKCEaftfGrtSaqsYJM+K8d3W2oSMvoD56zpeUQ3WlPSzr3 4MWl9xiznEpkINcxm8BeUmkGejh123fEjEY9a9Q6EiELNqwX+K5H0uNMTMXeMi1b JnnccxzQVYFYS79Uib2hmQXRRlKzYLqdciQvM7zVwq/JtGNDe1MqWdreZGZw1elt XNvMJ+M7dCsV1mGGKcvWo/CJ+pU39XDBGqIImYfqgc4OBunU2MmKSzOG8UxRRUhU MhYl+QjUDC6CfSnaepOeCe5ZcXCZKyfmNrg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrjedvgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepgeefjeehvdelvdffieejieejiedvvdfhleeivdelveehjeelteegudektdfg jeevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id CC613B60089; Mon, 31 Jul 2023 01:39:50 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-592-ga9d4a09b4b-fm-defalarms-20230725.001-ga9d4a09b Mime-Version: 1.0 Message-Id: <8b3466e4-a295-4249-bd05-2edbf7b3f6e3@app.fastmail.com> In-Reply-To: References: <20230702203429.237615-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230702203429.237615-4-prabhakar.mahadev-lad.rj@bp.renesas.com> <92c00ddb-e956-4861-af80-5f5558c9a8f5@app.fastmail.com> Date: Mon, 31 Jul 2023 07:39:30 +0200 From: "Arnd Bergmann" To: guoren , =?UTF-8?Q?Heiko_St=C3=BCbner?= Cc: "Emil Renner Berthing" , "Jisheng Zhang" , Prabhakar , "Conor.Dooley" , "Geert Uytterhoeven" , "Andrew Jones" , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Samuel Holland" , linux-riscv@lists.infradead.org, "Christoph Hellwig" , "Rob Herring" , "Krzysztof Kozlowski" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-Renesas , "Biju Das" , "Lad, Prabhakar" Subject: Re: [PATCH v10 3/6] riscv: mm: dma-noncoherent: nonstandard cache operations support Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Mon, Jul 31, 2023, at 02:49, Guo Ren wrote: > On Mon, Jul 31, 2023 at 4:36=E2=80=AFAM Arnd Bergmann = wrote: >> >> On Sun, Jul 30, 2023, at 17:42, Emil Renner Berthing wrote: >> > On Sun, 30 Jul 2023 at 17:11, Jisheng Zhang wr= ote: >> >> >> > + >> >> > static inline void arch_dma_cache_wback(phys_addr_t paddr, size= _t size) >> >> > { >> >> > void *vaddr =3D phys_to_virt(paddr); >> >> > >> >> > +#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS >> >> > + if (unlikely(noncoherent_cache_ops.wback)) { >> >> >> >> I'm worried about the performance impact here. >> >> For unified kernel Image reason, RISCV_NONSTANDARD_CACHE_OPS will = be >> >> enabled by default, so standard CMO and T-HEAD's CMO platform's >> >> performance will be impacted, because even an unlikely is put >> >> here, the check action still needs to be done. >> > >> > On IRC I asked why not use a static key so the overhead is just a >> > single nop when the standard CMO ops are available, but the consens= us >> > seemed to be that the flushing would completely dominate this branc= h. >> > And on platforms with the standard CMO ops the branch be correctly >> > predicted anyway. >> >> Not just the flushing, but also loading back the invalidated >> cache lines afterwards is just very expensive. I don't think >> you would be able to measure a difference between the static >> key and a correctly predicted branch on any relevant usecase here. > Maybe we should move CMO & THEAD ops to the noncoherent_cache_ops, and > only keep one of them. > > I prefer noncoherent_cache_ops, it's more maintance than ALTERNATIVE. I think moving the THEAD ops at the same level as all nonstandard operations makes sense, but I'd still leave CMO as an explicit fast path that avoids the indirect branch. This seems like the right thing to do both for readability and for platforms on which the indirect branch has a noticeable overhead. Arnd