Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4616189rwb; Mon, 31 Jul 2023 09:26:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/AUUT2ZNE2/GftQ9L7QuqE7ST0l00WZJM9j/mxzjc6E3HxfhmvzrZJB43faKqTGkyrlxd X-Received: by 2002:a17:903:41cf:b0:1b8:ae8c:7bfb with SMTP id u15-20020a17090341cf00b001b8ae8c7bfbmr10446917ple.17.1690820812224; Mon, 31 Jul 2023 09:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690820812; cv=none; d=google.com; s=arc-20160816; b=EPDsBGDFC1wTIY2eE9a5+Jx2Q6CRMKQMnyVoM61+kiD+/7pndZlJpcLy72l9VvnpOS xOfdkDnhR/76PTOqeiLh4SxkWV/gdmG10kKMKq3IJqVM7cFKNhMP7/YaPbvZbEYTQLtp dKnJJ+lCkwguquzz+drKjklD9IXsK7b5X5ZzQa2exYjcPh9SzWE3td69e6W2bjU2jXak IEotM4GqHziYqq+GsGQrJ9xM33lWo6x/LQy/8m9jxK8K5+LTMmWAs3BPG+OKkxquXw0+ z+SZrQVWunxUE8cVSigSqjblGdFJMARTXM36Ak/r8IhU7mfxZ6Vew+fyKbQbk8/HjoXF QOhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EKqYEYwpmzU3d+d2pABaACYAWtuYzrDbCXhCr85JYBc=; fh=a22QsqO1LficBjRUSPCS6nnPoAb7cjURUs0khvZWQOc=; b=tMJ6adrA4PikoZV7zXsaqIvVM/e8WMTSIb8AJ5JM8VTqO+UoyzxMQzx3zfnMO68iqy 4rx1QPBRCn5QKZQH9bUrv1hxONOfql8WOSUL5r1NNiR9P/ATyUxqHBSJolALnIyd/hba MMBkS8gqCHcQOUA/fNMrt4+FdodlspniKbFBh3J29jnLDSqulybq/SxzIwgfRVMFSoGs aqXczadde0e36bp3e2TmRlFt3Wlv1p/JG3916PAomdcWLe2ITiaV8d97X4zVMT7x69w1 qEnMMmycmeV2Kr1dRVY6apF+F0MbKaNcMMyjB893igI8UVBayklQmMCUAdLXeUW8Bf1N fmSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xsiktcq6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kr14-20020a170903080e00b001bb8704e6f3si6198810plb.278.2023.07.31.09.26.39; Mon, 31 Jul 2023 09:26:52 -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=@kernel.org header.s=k20201202 header.b=Xsiktcq6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232964AbjGaPzm (ORCPT + 99 others); Mon, 31 Jul 2023 11:55:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232948AbjGaPzj (ORCPT ); Mon, 31 Jul 2023 11:55:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4687E199E; Mon, 31 Jul 2023 08:55:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3ED3B611E4; Mon, 31 Jul 2023 15:55:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E5CDC433C7; Mon, 31 Jul 2023 15:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690818931; bh=NpBtSIJSQAMZgop0+UrbZFjO72hykmWioT0INVInNzM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xsiktcq6yFo8bOa1grhEAGYy7DsiCxGQ61akQuSRbSwgdbkw9u2hCxXeagc3bSYfW UxwX+nPP9ioKXtvf/dOVtbUtbW2QUKfnDjPwdLPZ9Yj03LIV2NnploqVk+yNOSQKo3 lIn23gUH61k3GeZ5aAm5B6WjRfJtwyxQcnJQUrOwTKIbGN3u24EsVzIOF4eQBSnCt9 LeW53R+OyWgIL3cnlrgbfVVFuoeW1fiusxzu2NwTtIEErbXofC/yCejdXWSm/BHL3P Ynnp4jVgwfx1aj7I1kiGCuh2tIXDsSltWmnH+32lJC8m8QqxE3Vavb8Hx4QTLfD1n4 zSSrN7Jy0bO2Q== Date: Mon, 31 Jul 2023 23:43:52 +0800 From: Jisheng Zhang To: Arnd Bergmann Cc: guoren , Heiko =?utf-8?Q?St=C3=BCbner?= , Emil Renner Berthing , 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 Message-ID: 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> <8b3466e4-a295-4249-bd05-2edbf7b3f6e3@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8b3466e4-a295-4249-bd05-2edbf7b3f6e3@app.fastmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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 07:39:30AM +0200, Arnd Bergmann wrote: > On Mon, Jul 31, 2023, at 02:49, Guo Ren wrote: > > On Mon, Jul 31, 2023 at 4:36 AM 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 wrote: > >> > >> >> > + > >> >> > static inline void arch_dma_cache_wback(phys_addr_t paddr, size_t size) > >> >> > { > >> >> > void *vaddr = 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 consensus > >> > seemed to be that the flushing would completely dominate this branch. > >> > 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 I read this as: the cache clean/inv is so expensive that the static key saving percentage is trivial, is this understanding right? this could be measured by writing a small benchmark kernel module which just calls cache clean/inv a buf(for example 1500Bytes)in a loop. > >> 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