From mboxrd@z Thu Jan 1 00:00:00 1970 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 265D6C54798 for ; Thu, 29 Feb 2024 10:25:06 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k/SZp7KJaZ7L7l3bWgTlPRIXQemXSinm1ABN3l7ZgMg=; b=IdUOOkW4Wid5+s /rMTSEq0U0Qh6Ta0KKAMiCxIS4OXbc9ZYF1LnRZzsDLrFykC+2kjMPXPCtQLrcSlQ15ZmfA3ygpsN gH5AmRA0m6su3UjMzhnq012RLhCLanOTsfUtPZC/rVslDNs0XGCYfxhXOLgRu99JFX/qTnbe7X0Aj brOmDdQP+f+9hVJC3mkRwZuKf/a776I0UoN32/Kuf7v+NeTtHxwYnICXGPrGZikJCxnvmCBeNlOMw f/V/hhcqHrnVxuY23buHFFxcdSOMGDK5FIXlFhBj/v6dvNrhjPoibhJfvfr0s5E0ecylgeL9zyXAi QqKdkOiEzKjAERPp76Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfdaz-0000000D8fD-2YWD; Thu, 29 Feb 2024 10:24:57 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfdax-0000000D8eZ-1jln for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 10:24:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C56F6CE1B9E; Thu, 29 Feb 2024 10:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74CE5C433C7; Thu, 29 Feb 2024 10:24:45 +0000 (UTC) Date: Thu, 29 Feb 2024 10:24:42 +0000 From: Catalin Marinas To: Jason Gunthorpe Cc: Alexander Gordeev , Andrew Morton , Christian Borntraeger , Borislav Petkov , Dave Hansen , "David S. Miller" , Eric Dumazet , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , "H. Peter Anvin" , Justin Stitt , Jakub Kicinski , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, llvm@lists.linux.dev, Ingo Molnar , Bill Wendling , Nathan Chancellor , Nick Desaulniers , netdev@vger.kernel.org, Paolo Abeni , Salil Mehta , Jijie Shao , Sven Schnelle , Thomas Gleixner , x86@kernel.org, Yisen Zhuang , Arnd Bergmann , Leon Romanovsky , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Rutland , Michael Guralnik , patches@lists.linux.dev, Niklas Schnelle , Will Deacon Subject: Re: [PATCH 4/6] arm64/io: Provide a WC friendly __iowriteXX_copy() Message-ID: References: <0-v1-38290193eace+5-mlx5_arm_wc_jgg@nvidia.com> <4-v1-38290193eace+5-mlx5_arm_wc_jgg@nvidia.com> <20240228230616.GS13330@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240228230616.GS13330@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240229_022455_830142_B68F71C9 X-CRM114-Status: GOOD ( 24.14 ) 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 On Wed, Feb 28, 2024 at 07:06:16PM -0400, Jason Gunthorpe wrote: > On Tue, Feb 27, 2024 at 10:37:18AM +0000, Catalin Marinas wrote: > > On Tue, Feb 20, 2024 at 09:17:08PM -0400, Jason Gunthorpe wrote: > > > +/* > > > + * This generates a memcpy that works on a from/to address which is aligned to > > > + * bits. Count is in terms of the number of bits sized quantities to copy. It > > > + * optimizes to use the STR groupings when possible so that it is WC friendly. > > > + */ > > > +#define memcpy_toio_aligned(to, from, count, bits) \ > > > + ({ \ > > > + volatile u##bits __iomem *_to = to; \ > > > + const u##bits *_from = from; \ > > > + size_t _count = count; \ > > > + const u##bits *_end_from = _from + ALIGN_DOWN(_count, 8); \ > > > + \ > > > + for (; _from < _end_from; _from += 8, _to += 8) \ > > > + __const_memcpy_toio_aligned##bits(_to, _from, 8); \ > > > + if ((_count % 8) >= 4) { \ > > > + __const_memcpy_toio_aligned##bits(_to, _from, 4); \ > > > + _from += 4; \ > > > + _to += 4; \ > > > + } \ > > > + if ((_count % 4) >= 2) { \ > > > + __const_memcpy_toio_aligned##bits(_to, _from, 2); \ > > > + _from += 2; \ > > > + _to += 2; \ > > > + } \ > > > + if (_count % 2) \ > > > + __const_memcpy_toio_aligned##bits(_to, _from, 1); \ > > > + }) > > > > Do we actually need all this if count is not constant? If it's not > > performance critical anywhere, I'd rather copy the generic > > implementation, it's easier to read. > > Which generic version? The current __iowriteXX_copy() in lib/iomap_copy.c (copy them over or add some preprocessor reuse the generic functions). > The point is to maximize WC effects with non-constant values, so I > think we do need something like this. ie we can't just fall back to > looping over 64 bit stores one at a time. If that's a case you are also targeting and have seen it in practice, that's fine. But I had the impression that you are mostly after the constant count case which is already addressed by the other part of this patch. For the non-constant case, we have a DGH only at the end of whatever buffer was copied rather than after every 64-byte increments you'd get for a count of 8. > Most places I know about using this are performance paths, the entire > iocopy infrastructure was introduced as an x86 performance > optimization.. At least the x86 case makes sense even from a maintenance perspective, it's just a much simpler "rep movsl". I just want to make sure we don't over-complicate this code on arm64 unnecessarily. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel