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 D2E26D2F7CE for ; Wed, 16 Oct 2024 21:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6rT6SvK7xolt3UlX58t1xQusVt+D/+IBGGmUYkYASW8=; b=Nq4Ye2px55G38r0KlpO3AsHqfs 3CI4AeAA7tClbscxrEXr+jmzQVD19vpOrhLO1MRKjxJ8Es4cTZvH1n0SLl/7j8i5+OOy7oup0+W7h odLtfruoM77uwitotSyQRnDDqMljTSqIbHumWAcN2tHZ+mvDbUss7fdFA9TZad+tx+ZPbgV+ndapm 5WF39iqMpymYBexdNpvVlCgJUadnX9t9FTLq0DTzs2BxbbI37sK/7xE7s8RmEfpAYZr/DGnW7EP37 9bIqe8fTkaJn3zqRURzc7jpfUdg9z6UvhVms4BPgKxFf2Mh2YrX+ybtJmcvZ7uoWz10dQZpps8Fz/ R7mSvqbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Bzf-0000000D6ST-1cQg; Wed, 16 Oct 2024 21:55:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1By8-0000000D66d-0GA1 for linux-arm-kernel@bombadil.infradead.org; Wed, 16 Oct 2024 21:54:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6rT6SvK7xolt3UlX58t1xQusVt+D/+IBGGmUYkYASW8=; b=SldlUPPG5bmGAaHtY7Ef8CGUAf HVmT+4F440MC9Cv5GaKHVprjeYkCNQlGDX6jTRmWZ4nBL5Kii3ND+i4eS7og+s4Lj9UKhtvGmnunc C3Ok/gyzRiWwD3aLCL9KW/+AXMjWpQ2Cesth7r+Fsi2jo9P0SMh8XvmozDIsjhK+UmYJyTX0Ps4qL UKP/ZK3wIABhNeo8aM7YZLRxWhZSSh64OI4xCM9/ZksibgjqwwQXFvIYNensB3yigDHMgLxPTE5W5 NZdSmzXiuSog9JKC4/6YL8ph0FNgkdPj3+PNNOM4fITsZhZjdeVzU+qR7gmTTUXfmS9/X9AbqsDMQ 9jBD31mg==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1By3-00000006wJu-2rtz for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2024 21:54:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1015D5C5D0B; Wed, 16 Oct 2024 21:53:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEE03C4CEC5; Wed, 16 Oct 2024 21:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729115643; bh=m+aILuSTQuuIvz+4xgsIPY5lFYR6pkyUgYclTIHsst0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mVPyu/u298rQiQTrf8v/DSFN+3cJy8mG6vWNDugyfFRfy8bwSKWUda7GHma7Watar 3Jb/2jnv75iXyxSi2Vz3j5u7OC7nXI77S2VOMX3F2tXYaeUpAh5e2Iisb0LCnv0fjs gkI5Fq9s8Mjn7yR7szA7SpllJsOpMbIYHet/HxPPsqTf75cgwxsSm/D8ptvXzIbboj Hw5wBrp2wSw188ResfPQyh2rONJyPMrfVOR/r5JPH7DKi9R9EEdbz88BxodF/9hOU3 o0Li7pS2J3c/VtAORVwQnB1UWyMu5VCdaxWOiBqwVLDcBsfChpDn5UJI1XfnGur9Io szDkh+23H+22g== Date: Wed, 16 Oct 2024 14:54:01 -0700 From: Eric Biggers To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, will@kernel.org, catalin.marinas@arm.com, Ard Biesheuvel , Kees Cook Subject: Re: [PATCH v2 2/2] arm64/crc32: Implement 4-way interleave using PMULL Message-ID: <20241016215401.GC1742@sol.localdomain> References: <20241016192640.406255-4-ardb+git@google.com> <20241016192640.406255-6-ardb+git@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241016192640.406255-6-ardb+git@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241016_225407_995938_99C8EB3E X-CRM114-Status: GOOD ( 17.19 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 16, 2024 at 09:26:43PM +0200, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > Now that kernel mode NEON no longer disables preemption, using FP/SIMD > in library code which is not obviously part of the crypto subsystem is > no longer problematic, as it will no longer incur unexpected latencies. > > So accelerate the CRC-32 library code on arm64 to use a 4-way > interleave, using PMULL instructions to implement the folding. > > On Apple M2, this results in a speedup of 2 - 2.8x when using input > sizes of 1k - 8k. For smaller sizes, the overhead of preserving and > restoring the FP/SIMD register file may not be worth it, so 1k is used > as a threshold for choosing this code path. > > The coefficient tables were generated using code provided by Eric. [0] > > [0] https://github.com/ebiggers/libdeflate/blob/master/scripts/gen_crc32_multipliers.c > > Cc: Eric Biggers > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/lib/Makefile | 2 +- > arch/arm64/lib/crc32-4way.S | 242 ++++++++++++++++++++ > arch/arm64/lib/crc32-glue.c | 48 ++++ > 3 files changed, 291 insertions(+), 1 deletion(-) Reviewed-by: Eric Biggers > + /* Process up to 64 blocks of 64 bytes at a time */ > +.La\@: mov x3, #64 > + cmp len, #64 > + csel x3, x3, len, hi // x3 := max(len, 64) The comment should say min(len, 64), not max(len, 64). - Eric