Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1204913pxb; Fri, 1 Oct 2021 05:58:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnRQ0QznbDIo0EnvcXgQyeEKB2x8P4nxouElDjkZ4/v9R9/uIrpsj80kDDDB6fuTDa18U4 X-Received: by 2002:a17:906:3b8e:: with SMTP id u14mr6005935ejf.418.1633093118711; Fri, 01 Oct 2021 05:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633093118; cv=none; d=google.com; s=arc-20160816; b=Qe5ZzgX7S1IMOcqhjBlPfuzXrZWkmxZL2HDuAdumQ5Vlg8fEe/sVGNnH6DDXyrZgLi 8MBQVRigxDMCDs/Dg9i9IfT21N9PyiW6JCvgpwNK1pufJHtk9dMGxhzLAVjRIfqIbyMw NKcwyZNvyC4GR7TKWcEC1IXr7+Dcg2gtbRc+StW/p7ILrRoKvVPkjwweW91paqnktqfa fUUKLaCDtfs7pqgu2e9U0rUMU/9UM1nyJYtv1Zpui6GYZ3UplaKrvFbLfhF76LnLLwZU rFUkB7nrSrl2gw1sm+By/XDqr05wtPNFgOgkX0MUL3bTrsZbdyUBEI5XOedzlCNhCQfE Zi6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WW8Z8AcLmnzExFqcwWko/J3s0pxGOP9gvDPMrWujQBM=; b=o5pwAEp+dn/Ckb9/SEjdHcbihxR408dyxT2HwHHzZnaZsr53PeUV/UXHe9ZbOzo9NG JYLgcdEcsh+RPilFJtmt2pQ77TvjdgNgQhKjz6dyMc+dI/1mdKZn1R+42At5ZmisUy2v fRHS5TucOg3yEodXP11tBg3zHNb/f+j4P42JDS0HniyeKAE1sKJJrX1upXb0GCn8HqJ+ 0Twmpzubn4kZ8kJbv9euxOxpRzBxCiQptr3b5bmH+3eNdmkwcs9yiXLFnJ2x12BaXWHO UbvrrjOCjDz5qTwD8I5oKlAEkGnu5imKyDLfsWZd69EXugp6jEruEB1sr4G0qgTsxQIN XlJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si4575787ejj.578.2021.10.01.05.58.12; Fri, 01 Oct 2021 05:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353743AbhJALZr (ORCPT + 99 others); Fri, 1 Oct 2021 07:25:47 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:51174 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353760AbhJALZo (ORCPT ); Fri, 1 Oct 2021 07:25:44 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 4B4681C0B80; Fri, 1 Oct 2021 13:23:54 +0200 (CEST) Date: Fri, 1 Oct 2021 13:23:54 +0200 From: Pavel Machek To: Matteo Croce Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Emil Renner Berthing , Akira Tsukamoto , Drew Fustini , Bin Meng , David Laight , Guo Ren , Christoph Hellwig Subject: Re: [PATCH v5 1/3] riscv: optimized memcpy Message-ID: <20211001112354.GA10720@duo.ucw.cz> References: <20210929172234.31620-1-mcroce@linux.microsoft.com> <20210929172234.31620-2-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <20210929172234.31620-2-mcroce@linux.microsoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Matteo Croce >=20 > Write a C version of memcpy() which uses the biggest data size allowed, > without generating unaligned accesses. >=20 > The procedure is made of three steps: > First copy data one byte at time until the destination buffer is aligned > to a long boundary. > Then copy the data one long at time shifting the current and the next u8 > to compose a long at every cycle. > Finally, copy the remainder one byte at time. >=20 > On a BeagleV, the TCP RX throughput increased by 45%: >=20 > before: >=20 > $ iperf3 -c beaglev > Connecting to host beaglev, port 5201 > [ 5] local 192.168.85.6 port 44840 connected to 192.168.85.48 port 5201 > [ ID] Interval Transfer Bitrate Retr Cwnd > [ 5] 0.00-1.00 sec 76.4 MBytes 641 Mbits/sec 27 624 KBytes > [ 5] 1.00-2.00 sec 72.5 MBytes 608 Mbits/sec 0 708 KBytes >=20 > after: >=20 > $ iperf3 -c beaglev > Connecting to host beaglev, port 5201 > [ 5] local 192.168.85.6 port 44864 connected to 192.168.85.48 port 5201 > [ ID] Interval Transfer Bitrate Retr Cwnd > [ 5] 0.00-1.00 sec 109 MBytes 912 Mbits/sec 48 559 KBytes > [ 5] 1.00-2.00 sec 108 MBytes 902 Mbits/sec 0 690 > KBytes That's really quite cool. Could you see if it is your "optimized unaligned" copy doing the difference?> +/* convenience union to avoid cast between different pointer types */ > +union types { > + u8 *as_u8; > + unsigned long *as_ulong; > + uintptr_t as_uptr; > +}; > + > +union const_types { > + const u8 *as_u8; > + unsigned long *as_ulong; > + uintptr_t as_uptr; > +}; Missing consts here? Plus... this is really "interesting" coding style. I'd just use casts in kernel. Regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --huq684BweRXVnRxX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYVbvygAKCRAw5/Bqldv6 8vL4AKCm6Y1l3PaTBC4mmrpz0UrY1DvWGQCfYF5/9wrjjsk9fb68mC20qc3UVpc= =NRFP -----END PGP SIGNATURE----- --huq684BweRXVnRxX--