x86/xsave: Move xsave initialization to after parsing early parameters
Subsystems (2)
PATCH 1/2 x86/xsave: Move xsave initialization to after parsing early parameters
From: Andi Kleen <[email protected]>
Move the XSAVE initialization code to be after parsing early parameters. I don't see any reason why the FPU code needs to be initialized that early, nothing else in the initialization phase uses XSAVE. This is useful to be able to handle command line parameters in the XSAVE initialization code.
--- arch/x86/kernel/cpu/common.c | 1 - arch/x86/kernel/setup.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/common.c +0 -1
@@ -844,7 +844,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) }setup_force_cpu_cap (X86_FEATURE_ALWAYS ); -fpu__init_system (c); }void __init early_cpu_init (void )
arch/x86/kernel/setup.c +3 -0
@@ -90,6 +90,7 @@#include <asm/processor.h> #include <asm/bugs.h> #include <asm/kasan.h> +#include <asm/fpu/internal.h> #include <asm/vsyscall.h> #include <asm/cpu.h>
@@ -987,6 +988,8 @@ void __init setup_arch(char **cmdline_p)parse_early_param (); +fpu__init_system (&boot_cpu_data); +#ifdef CONFIG_MEMORY_HOTPLUG /* * Memory used by the kernel cannot be hot-removed because Linux
Signature · 1 line
2.9.3
PATCH 2/2 x86/fpu: Support disabling AVX and AVX512
From: Andi Kleen <[email protected]>
For performance testing it is useful to be able to disable AVX and AVX512. User programs check in XGETBV if AVX is supported by the OS. If we don't initialize the XSAVE state for AVX it will appear as if the OS is not supporting AVX. For kernel users we can also clear the internal cpu feature bits.
This patch implements disable options for AVX and AVX512 for the XSAVE code.
I originally considered a generic argument that would disable any XSAVE feature, but it turns out you need special code to also disable all the CPUID bits, because otherwise kernel code may assume it exists, when it doesn't. MPX already has an own disable flag. Not clear it is useful for the others. So we only do it for AVX/AVX512 for now.
--- Documentation/admin-guide/kernel-parameters.txt | 3 ++ arch/x86/kernel/fpu/xstate.c | 61 +++++++++++++++++++++---- 2 files changed, 55 insertions(+), 9 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -785,6 +785,9 @@ dhash_entries= [KNL] Set number of hash buckets for dentry cache. + disable_avx [X86] Disable support for AVX on Intel CPUs. + disable_avx512 [X86] Disable support for AVX512 on Intel CPUs. + disable_1tb_segments [PPC] Disables the use of 1TB hash page table segments. This causes the kernel to fall back to 256MB segments which
arch/x86/kernel/fpu/xstate.c +52 -9
96 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH 2/2] x86/fpu: Support disabling AVX and AVX512
Quoted 11 lines · Andi Kleen
From: Andi Kleen <[email protected]>
For performance testing it is useful to be able to disable AVX and AVX512. User programs check in XGETBV if AVX is supported by the OS. If we don't initialize the XSAVE state for AVX it will appear as if the OS is not supporting AVX. For kernel users we can also clear the internal cpu feature bits.
This patch implements disable options for AVX and AVX512 for the XSAVE code.
Quoted 6 lines
I originally considered a generic argument that would disable any XSAVE feature, but it turns out you need special code to also disable all the CPUID bits, because otherwise kernel code may assume it exists, when it doesn't. MPX already has an own disable flag. Not clear it is useful for the others. So we only do it for AVX/AVX512 for now.
Please read and follow Documentation/process/submitting-patches.rst.
Especially this paragraph:
Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour.
Documentation/admin-guide/kernel-parameters.txt line 788
Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1
-0+ disable_avx [X86] Disable support for AVX on Intel CPUs.
So that command line option fails on AMD CPUs, right?
Documentation/admin-guide/kernel-parameters.txt line 789
Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1
-0+ disable_avx512 [X86] Disable support for AVX512 on Intel CPUs.
Please drop the Intel stuff here as well. It's just a question of time until AMD gets that as well.
Quoted 14 lines
Documentation/admin-guide/kernel-parameters.txt +0
-0disable_1tb_segments [PPC] Disables the use of 1TB hash page table segments. This causes the kernel to fall back to 256MB segments whicharch/x86/kernel/fpu/xstate.c +3
-0@@ -16,6 +16,20 @@#include <asm/tlbflush.h> +enum xsave_features { +XSAVE_X87 , +XSAVE_SSE ,
arch/x86/kernel/fpu/xstate.c line 31
Quoted 10 lines
arch/x86/kernel/fpu/xstate.c +10
-0+XSAVE_AVX , +XSAVE_MPX_BOUNDS , +XSAVE_MPX_CSR , +XSAVE_AVX512_OPMASK , +XSAVE_AVX512_HI256 , +XSAVE_AVX512_ZMM_HI256 , +XSAVE_PT , +XSAVE_PKU , +XSAVE_UNKNOWN +};
What's that enum for? It's unused ....
arch/x86/kernel/fpu/xstate.c static const char *xfeature_names[] = · line 58
Quoted 8 lines
arch/x86/kernel/fpu/xstate.c +1
-0/* * Although we spell it out in here, the Processor Trace * xfeature is completely unused. We use other mechanisms @@ -41,6 +55,8 @@ static const char *xfeature_names[] =*/ u64 xfeatures_mask__read_mostly ; +u64 xfeatures_disabled__initdata ;
Why is this global?
arch/x86/kernel/fpu/xstate.c void __init fpu__init_system_xstate(void) · line 762
Quoted 2 lines
arch/x86/kernel/fpu/xstate.c +1
-0+ xfeatures_mask &= ~xfeatures_disabled; xfeatures_mask &=fpu__get_supported_xfeatures_mask ();
Thanks,
tglx
Re: [PATCH 2/2] x86/fpu: Support disabling AVX and AVX512
Quoted 7 lines · Thomas Gleixner
Quoted 7 lines
arch/x86/kernel/fpu/xstate.c +7
-0+enum xsave_features { +XSAVE_X87 , +XSAVE_SSE , +XSAVE_AVX , +XSAVE_MPX_BOUNDS , +XSAVE_MPX_CSR , +XSAVE_AVX512_OPMASK ,
Quoted 8 lines
arch/x86/kernel/fpu/xstate.c line 31
Quoted 6 lines
arch/x86/kernel/fpu/xstate.c +6
-0+XSAVE_AVX512_HI256 , +XSAVE_AVX512_ZMM_HI256 , +XSAVE_PT , +XSAVE_PKU , + XSAVE_UNKNOWN +};What's that enum for? It's unused ....
It's not. The disable functions use it (although only the AVX parts)
-Andi
Re: [PATCH 2/2] x86/fpu: Support disabling AVX and AVX512
Quoted 17 lines · Andi Kleen
Quoted 7 lines · Thomas Gleixner
Quoted 7 lines
arch/x86/kernel/fpu/xstate.c +7
-0+enum xsave_features { +XSAVE_X87 , +XSAVE_SSE , +XSAVE_AVX , +XSAVE_MPX_BOUNDS , +XSAVE_MPX_CSR , +XSAVE_AVX512_OPMASK ,Quoted 8 lines
arch/x86/kernel/fpu/xstate.c line 31
Quoted 6 lines
arch/x86/kernel/fpu/xstate.c +6
-0+XSAVE_AVX512_HI256 , +XSAVE_AVX512_ZMM_HI256 , +XSAVE_PT , +XSAVE_PKU , + XSAVE_UNKNOWN +};What's that enum for? It's unused ....
Quoted 1 line
It's not. The disable functions use it (although only the AVX parts)
Sorry, misread it.
Thanks,
tglx