linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	x86@kernel.org, linux-block@vger.kernel.org,
	Ard Biesheuvel <ardb@kernel.org>, Keith Busch <kbusch@kernel.org>,
	Kent Overstreet <kent.overstreet@linux.dev>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH v3 2/6] scripts/gen-crc-consts: add gen-crc-consts.py
Date: Thu, 6 Feb 2025 12:08:43 -0800	[thread overview]
Message-ID: <20250206200843.GA1237@sol.localdomain> (raw)
In-Reply-To: <20250206193117.7a9a463c@pumpkin>

On Thu, Feb 06, 2025 at 07:31:17PM +0000, David Laight wrote:
> On Wed,  5 Feb 2025 23:39:44 -0800
> Eric Biggers <ebiggers@kernel.org> wrote:
> 
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > Add a Python script that generates constants for computing the given CRC
> > variant(s) using x86's pclmulqdq or vpclmulqdq instructions.
> > 
> > This is specifically tuned for x86's crc-pclmul-template.S.  However,
> > other architectures with a 64x64 => 128-bit carryless multiplication
> > instruction should be able to use the generated constants too.  (Some
> > tweaks may be warranted based on the exact instructions available on
> > each arch, so the script may grow an arch argument in the future.)
> > 
> > The script also supports generating the tables needed for table-based
> > CRC computation.  Thus, it can also be used to reproduce the tables like
> > t10_dif_crc_table[] and crc16_table[] that are currently hardcoded in
> > the source with no generation script explicitly documented.
> > 
> > Python is used rather than C since it enables implementing the CRC math
> > in the simplest way possible, using arbitrary precision integers.  The
> > outputs of this script are intended to be checked into the repo, so
> > Python will continue to not be required to build the kernel, and the
> > script has been optimized for simplicity rather than performance.
> 
> It might be better to output #defines that just contain array
> initialisers rather than the definition of the actual array itself.
> 
> Then any code that wants the values can include the header and
> just use the constant data it wants to initialise its own array.
> 
> 	David

The pclmul constants use structs, not arrays.  Maybe you are asking for the
script to only generate the struct initializers?  This suggestion seems a bit
more complicated than just having everything in one place.  It would allow
putting the struct definitions in the CRC-variant-specific files while keeping
the struct initializers all in one file, so __maybe_unused would no longer need
to be used on the definitions.  But the actual result would be the same, just
achieved in what seems like a slightly more difficult way.

- Eric

  reply	other threads:[~2025-02-06 20:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  7:39 [PATCH v3 0/6] x86 CRC optimizations Eric Biggers
2025-02-06  7:39 ` [PATCH v3 1/6] x86: move ZMM exclusion list into CPU feature flag Eric Biggers
2025-02-06  7:39 ` [PATCH v3 2/6] scripts/gen-crc-consts: add gen-crc-consts.py Eric Biggers
2025-02-06 19:31   ` David Laight
2025-02-06 20:08     ` Eric Biggers [this message]
2025-02-06 22:28       ` David Laight
2025-02-06 23:41         ` Eric Biggers
2025-02-06  7:39 ` [PATCH v3 3/6] x86/crc: add "template" for [V]PCLMULQDQ based CRC functions Eric Biggers
2025-02-06  7:39 ` [PATCH v3 4/6] x86/crc32: implement crc32_le using new template Eric Biggers
2025-02-06  7:39 ` [PATCH v3 5/6] x86/crc-t10dif: implement crc_t10dif " Eric Biggers
2025-02-06  7:39 ` [PATCH v3 6/6] x86/crc64: implement crc64_be and crc64_nvme " Eric Biggers

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=20250206200843.GA1237@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=ardb@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).