From: Petr Pavlu <petr.pavlu@suse.com>
To: Wentao Guan <guanwentao@uniontech.com>
Cc: masahiroy@kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org
Subject: Re: [PATCH v2] genksyms: Support arm64 CRC32 hardware acceleration
Date: Mon, 25 May 2026 09:50:06 +0200 [thread overview]
Message-ID: <5d1b8b13-d590-497d-9185-609494135348@suse.com> (raw)
In-Reply-To: <20260525070344.1564886-1-guanwentao@uniontech.com>
+Cc: kbuild, modules
On 5/25/26 9:03 AM, Wentao Guan wrote:
> Use hardware 'crc32b' to partial_crc32_one() when support,
> it shows 2x speed up than crctab32 way.
>
> I think it will be scaled to more architecture.
Could you please provide measurements showing how this improves the
runtime of genksyms and affects the overall kernel build time? Are
CRC calculations actually a hot path in genksyms? I don't think it is
worth complicating the genksyms code with architecture-specific
optimizations unless there is a clear benefit.
Additionally, many distributions already switched to gendwarfksyms last
year. Unless someone provides a good reason to keep genksyms around,
I expect it will be deprecated soon and eventually removed. It would be
more valuable to show whether the same optimization is worthwhile for
gendwarfksyms.
--
Thanks,
Petr
>
> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
> ---
> changelog:
> 1. remove change in partial_crc32(),
> for partial_crc32_one() already use crc32b.
>
> ---
> ---
> scripts/genksyms/genksyms.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> index 83e48670c2fcf..80b7797c842aa 100644
> --- a/scripts/genksyms/genksyms.c
> +++ b/scripts/genksyms/genksyms.c
> @@ -116,8 +116,40 @@ static const uint32_t crctab32[] = {
> 0x2d02ef8dU
> };
>
> +/*
> + * Architecture-specific CRC32 hardware acceleration.
> + */
> +static int crc32_hw_available;
> +
> +#ifdef __aarch64__
> +#include <sys/auxv.h>
> +#include <asm/hwcap.h>
> +
> +static void crc32_check_hw(void)
> +{
> + crc32_hw_available = (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0;
> +}
> +
> +static inline uint32_t crc32_hw_byte(uint8_t c, uint32_t crc)
> +{
> + asm volatile(".arch_extension crc\n\t"
> + "crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(c));
> + return crc;
> +}
> +
> +#else
> +static void crc32_check_hw(void)
> +{
> + crc32_hw_available = 0;
> +}
> +#endif
> +
> static uint32_t partial_crc32_one(uint8_t c, uint32_t crc)
> {
> +#if defined(__aarch64__)
> + if (__builtin_expect(crc32_hw_available, 0))
> + return crc32_hw_byte(c, crc);
> +#endif
> return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
> }
>
> @@ -740,6 +772,8 @@ int main(int argc, char **argv)
> FILE *dumpfile = NULL, *ref_file = NULL;
> int o;
>
> + crc32_check_hw();
> +
> struct option long_opts[] = {
> {"debug", 0, 0, 'd'},
> {"warnings", 0, 0, 'w'},
next prev parent reply other threads:[~2026-05-25 7:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 7:03 Wentao Guan
2026-05-25 7:50 ` Petr Pavlu [this message]
2026-05-25 8:02 ` [PATCH v2] genksyms: Support arm64 CRC32 hardware acceleration1~ Wentao Guan
2026-05-25 9:09 ` Petr Pavlu
2026-05-25 13:41 ` Wentao Guan
2026-05-25 17:33 ` Petr Pavlu
2026-05-26 18:12 ` Wentao Guan
2026-05-26 19:13 ` Wentao Guan
2026-05-28 10:33 ` [PATCH v2] genksyms: Support arm64 CRC32 hardware acceleration kernel test robot
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=5d1b8b13-d590-497d-9185-609494135348@suse.com \
--to=petr.pavlu@suse.com \
--cc=guanwentao@uniontech.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=masahiroy@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
all inboxes | Powered by JetHome®