Re: [PATCH v4 21/24] crypto: x86 - report used CPU features via module parameters

From: Jason A. Donenfeld
Date: Wed Nov 16 2022 - 06:37:57 EST


On Tue, Nov 15, 2022 at 10:13:39PM -0600, Robert Elliott wrote:
> For modules that have multiple choices, add read-only module parameters
> reporting which CPU features a module is using.
>
> The parameters show up as follows for modules that modify the behavior
> of their registered drivers or register additional drivers for
> each choice:
> /sys/module/aesni_intel/parameters/using_x86_avx:1
> /sys/module/aesni_intel/parameters/using_x86_avx2:1
> /sys/module/aria_aesni_avx_x86_64/parameters/using_x86_gfni:0
> /sys/module/chacha_x86_64/parameters/using_x86_avx2:1
> /sys/module/chacha_x86_64/parameters/using_x86_avx512:1
> /sys/module/crc32c_intel/parameters/using_x86_pclmulqdq:1
> /sys/module/curve25519_x86_64/parameters/using_x86_adx:1
> /sys/module/libblake2s_x86_64/parameters/using_x86_avx512:1
> /sys/module/libblake2s_x86_64/parameters/using_x86_ssse3:1
> /sys/module/poly1305_x86_64/parameters/using_x86_avx:1
> /sys/module/poly1305_x86_64/parameters/using_x86_avx2:1
> /sys/module/poly1305_x86_64/parameters/using_x86_avx512:0
> /sys/module/sha1_ssse3/parameters/using_x86_avx:1
> /sys/module/sha1_ssse3/parameters/using_x86_avx2:1
> /sys/module/sha1_ssse3/parameters/using_x86_shani:0
> /sys/module/sha1_ssse3/parameters/using_x86_ssse3:1
> /sys/module/sha256_ssse3/parameters/using_x86_avx:1
> /sys/module/sha256_ssse3/parameters/using_x86_avx2:1
> /sys/module/sha256_ssse3/parameters/using_x86_shani:0
> /sys/module/sha256_ssse3/parameters/using_x86_ssse3:1
> /sys/module/sha512_ssse3/parameters/using_x86_avx:1
> /sys/module/sha512_ssse3/parameters/using_x86_avx2:1
> /sys/module/sha512_ssse3/parameters/using_x86_ssse3:1

Isn't chacha missing?

However, what's the point of any of this? Who benefits from this info?
If something seems slow, I'll generally look at perf top, which provides
this same thing.

Also, "using" isn't quite correct. Some AVX2 machines will never use any
ssse3 instructions, despite the code being executable.

>
> Delete the aesni_intel prints reporting those selections:
> pr_info("AVX2 version of gcm_enc/dec engaged.\n");

This part I like.

> +module_param_named(using_x86_adx, curve25519_use_bmi2_adx.key.enabled.counter, int, 0444);
> +MODULE_PARM_DESC(using_x86_adx, "Using x86 instruction set extensions: ADX");

And BMI2, not just ADX.