Re: [linus:master] [x86/fpu] b81fac906a: stress-ng.af-alg.ops_per_sec -34.6% regression

From: Feng Tang
Date: Mon Jul 31 2023 - 08:10:55 EST


On Wed, Jul 19, 2023 at 10:07:52PM +0800, kernel test robot wrote:
>
>
> Hello,
>
> kernel test robot noticed a -34.6% regression of stress-ng.af-alg.ops_per_sec on:
>
>
> commit: b81fac906a8f9e682e513ddd95697ec7a20878d4 ("x86/fpu: Move FPU initialization into arch_cpu_finalize_init()")
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
>
> still regression on:
> fix commit: fe3e0a13e597c1c8617814bf9b42ab732db5c26e
> linus/master: ccff6d117d8dc8d8d86e8695a75e5f8b01e573bf
>
> testcase: stress-ng
> test machine: 64 threads 2 sockets Intel(R) Xeon(R) Gold 6346 CPU @ 3.10GHz (Ice Lake) with 256G memory
> parameters:
>
> nr_threads: 10%
> disk: 1HDD
> testtime: 60s
> fs: ext4
> class: os
> test: af-alg
> cpufreq_governor: performance
>
>
> besides, we noticed there are below information in dmesg (attached kmsg.xz),
> which we didn't see in dmesg for parent:
>
> kern :info : [ 65.660392] AVX or AES-NI instructions are not detected.
> user :notice: [ 65.661743] stress-ng: info: [4738] af-alg: 9 cryptographic algorithms are internal and may be unused
>
> kern :info : [ 65.720205] AVX or AES-NI instructions are not detected.
> kern :info : [ 65.820334] AVX2 instructions are not detected.
> kern :info : [ 66.130644] AVX or AES-NI instructions are not detected.
> kern :info : [ 66.167749] AVX or AES-NI instructions are not detected.
> kern :info : [ 66.213178] AVX2 instructions are not detected.
> kern :info : [ 66.318235] AVX or AES-NI instructions are not detected.
> kern :info : [ 66.360766] AVX or AES-NI instructions are not detected.
> kern :info : [ 66.437318] AVX2 instructions are not detected.
> kern :info : [ 66.683666] AVX or AES-NI instructions are not detected.
> user :notice: [ 66.713976] BMC ARP Control : ARP Responses Enabled, Gratuitous ARP Disabled
>
> kern :info : [ 66.738790] AVX or AES-NI instructions are not detected.
> kern :info : [ 66.822332] AVX2 instructions are not detected.
> kern :info : [ 67.083360] AVX or AES-NI instructions are not detected.
> kern :info : [ 67.122804] AVX or AES-NI instructions are not detected.

I think the regression is related with the commit, that commit
b81fac906a8f changes the FPU init order, and cause the 'X86_FEATURE_OSXSAVE'
missed the cpu capability setup, thus all later check of
boot_cpu_has(X86_FEATURE_OSXSAVE) will return false.

arch_cpu_finalize_init
identify_boot_cpu
identify_cpu
generic_identify
get_cpu_cap --> setup cpu capability
...
fpu__init_cpu
fpu__init_cpu_xstate
cr4_set_bits(X86_CR4_OSXSAVE);

Many security moduels in arch/x86 have dependency on X86_FEATURE_OSXSAVE,
and will fail to load later. While this 'af-alg' case involves secuirty
operation and tries to load those modules but fail, which cause the
regression.

Setting the 'OSXSVAE' feature bit after OSXSAVE enabling can restore
the regression, like the below RFC patch. pls help to review, thanks!

- Feng

---