public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ard Biesheuvel <ardb@kernel.org>, Chao Yu <chao@kernel.org>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Kent Overstreet <kent.overstreet@linux.dev>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Vinicius Peixoto <vpeixoto@lkcamp.dev>,
	WangYuli
	<wangyuli@grjsls0nwwnnilyahiblcmlmlcaoki5s.yundunwaf1.com>
Subject: Re: [GIT PULL] CRC updates for 6.14
Date: Thu, 23 Jan 2025 18:18:18 +0000	[thread overview]
Message-ID: <20250123181818.GA2117666@google.com> (raw)
In-Reply-To: <20250123140744.GB3875121@mit.edu>

On Thu, Jan 23, 2025 at 09:07:44AM -0500, Theodore Ts'o wrote:
> On Wed, Jan 22, 2025 at 11:46:18PM -0800, Eric Biggers wrote:
> > 
> > Actually, I'm tempted to just provide slice-by-1 (a.k.a. byte-by-byte) as the
> > only generic CRC32 implementation.  The generic code has become increasingly
> > irrelevant due to the arch-optimized code existing.  The arch-optimized code
> > tends to be 10 to 100 times faster on long messages.
> 
> Yeah, that's my intuition as well; I would think the CPU's that
> don't have a CRC32 optimization instruction(s) would probably be the
> most sensitive to dcache thrashing.
> 
> But given that Geert ran into this on m68k (I assume), maybe we could
> have him benchmark the various crc32 generic implementation to see if
> we is the best for him?  That is, assuming that he cares (which he
> might not. :-).

FWIW, benchmarking the CRC library functions is easy now; just enable
CONFIG_CRC_KUNIT_TEST=y and CONFIG_CRC_BENCHMARK=y.

But, it's just a traditional benchmark that calls the functions in a loop, and
doesn't account for dcache thrashing.  It's exactly the sort of benchmark I
mentioned doesn't tell the whole story about the drawbacks of using a huge
table.  So focusing only on microbenchmarks of slice-by-n generally leads to a
value n > 1 seeming optimal --- potentially as high as n=16 depending on the
CPU, but really old CPUs like m68k should need much less.  So the rationale of
choosing "slice-by-1" in the kernel would be to consider the reduced dcache use
and code size, and the fact that arch-optimized code is usually used instead
these days anyway, to be more important than microbenchmark results.  (And also
the other CRC variants in the kernel like CRC64, CRC-T10DIF, CRC16, etc. already
just have slice-by-1, so this would make CRC32 consistent with that.)

- Eric

  reply	other threads:[~2025-01-23 18:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-19 22:51 [GIT PULL] CRC updates for 6.14 Eric Biggers
2025-01-23  4:13 ` Linus Torvalds
2025-01-23  5:16   ` Eric Biggers
2025-01-23  7:46     ` Eric Biggers
2025-01-23 14:07       ` Theodore Ts'o
2025-01-23 18:18         ` Eric Biggers [this message]
2025-01-23 20:52           ` Linus Torvalds
2025-01-23 21:13             ` Eric Biggers
2025-01-23 21:16               ` Linus Torvalds
2025-01-23 21:22                 ` Eric Biggers
2025-01-23 20:58         ` David Laight
2025-01-23 21:16           ` Eric Biggers
2025-01-23 23:17             ` David Laight
2025-01-23 22:36       ` Kent Overstreet
2025-01-23 23:42         ` Eric Biggers
2025-01-24  0:32           ` Kent Overstreet
2025-01-23  8:16     ` Geert Uytterhoeven
2025-01-23  8:19       ` Geert Uytterhoeven
2025-01-23  8:26         ` Eric Biggers
2025-01-23  8:22       ` Eric Biggers
2025-01-23  4:49 ` pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250123181818.GA2117666@google.com \
    --to=ebiggers@kernel.org \
    --cc=ardb@kernel.org \
    --cc=chao@kernel.org \
    --cc=djwong@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpe@ellerman.id.au \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=vpeixoto@lkcamp.dev \
    --cc=wangyuli@grjsls0nwwnnilyahiblcmlmlcaoki5s.yundunwaf1.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox