Re: [PATCH v2 2/2] zstd: use cpu_feature_enabled() for in-kernel BMI2 dispatch
From: Linus Torvalds
Date: Sun Aug 30 2026 - 19:07:09 EST
On Sun, 30 Aug 2026 at 15:21, Usama Arif <usama.arif@xxxxxxxxx> wrote:
>
> Add ZSTD_USE_BMI2() and use it at every runtime BMI2/default selector.
Thanks, this looks sane to me.
I do still react to a couple of places. Notably, this part (repeated a
couple of times):
> +#if !defined(ZSTD_USE_KERNEL_CPU_FEATURES)
> cctx->bmi2 = ZSTD_cpuSupportsBmi2();
> +#endif
should probably be an "set state" macro the same way ZSTD_USE_BMI2()
is now a "get state" macro.
And:
> +ccflags-$(CONFIG_X86) += -DZSTD_USE_KERNEL_CPU_FEATURES
We don't have anything like this for any other ZSTD defines, so my gut
feel is that either this is in the wrong place, and it should be in
something like
lib/zstd/common/zstd_deps.h
which already has kernel-specific stuff in it, or it should just use
#ifdef __KERNEL__ like we use elsewhere for things that are also used
by user space.
The whole situation with ZSTD configuration is a bit strange. I note
that there are things like ZSTD_ARCH_ARM_NEON that the kernel never
uses.
Why is "DYNAMIC_BMI2" a settimg but things like that
ZSTD_ARCH_X86_SSE2 and ZSTD_ARCH_ARM_NEON are never set? This all
looks messy.
Or is there some hidden config I didn't find?
Strange.
Linus