x86/fpu: make WARN_ON_FPU get fully optimized out
PATCH 1/1 x86/fpu: make WARN_ON_FPU get fully optimized out
From: Eric Biggers <[email protected]>
Currently WARN_ON_FPU evaluates its argument even if CONFIG_X86_DEBUG_FPU is disabled, which adds unnecessary instructions to several functions. Fix this by making the argument evaluation in the no-debug case conditional on if (0), similar to what no_printk() does.
--- arch/x86/kernel/fpu/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/fpu/internal.h +1 -1
@@ -16,11 +16,11 @@ static __always_inline __pure bool use_fxsr(void) }#ifdef CONFIG_X86_DEBUG_FPU # define WARN_ON_FPU (x) WARN_ON_ONCE(x)#else -# define WARN_ON_FPU (x) ({ (void)(x); 0; }) +# define WARN_ON_FPU (x) ({ if (0) (void)(x); 0; })#endif /* Used in init.c */ extern void fpstate_init_user (struct fpstate *fpstate);extern void fpstate_reset (struct fpu *fpu);
base-commit: d6ef8b40d075c425f548002d2f35ae3f06e9cf96
Signature · 1 line
2.47.1
Quoted 18 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Currently
WARN_ON_FPUevaluates its argument even ifCONFIG_X86_DEBUG_FPUis disabled, which adds unnecessary instructions to several functions. Fix this by making the argument evaluation in the no-debug case conditional on if (0), similar to whatno_printk()does.Fixes 83242c515881 ("x86/fpu: Make WARN_ON_FPU() more robust in the !CONFIG_X86_DEBUG_FPU case")Signed-off-by Eric Biggers <[email protected]>--- arch/x86/kernel/fpu/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/fpu/internal.h +0
-0
arch/x86/kernel/fpu/internal.h static __always_inline __pure bool use_fxsr(void) · line 21
Quoted 7 lines
arch/x86/kernel/fpu/internal.h +1
-1@@ -16,11 +16,11 @@ static __always_inline __pure bool use_fxsr(void) }#ifdef CONFIG_X86_DEBUG_FPU # define WARN_ON_FPU (x) WARN_ON_ONCE(x)#else -# define WARN_ON_FPU (x) ({ (void)(x); 0; }) +# define WARN_ON_FPU (x) ({ if (0) (void)(x); 0; })
BUILD_BUG_ON_INVALID() already takes care of this, e.g. I verified this also makes the code generation go away:
# define WARN_ON_FPU(x) ({ BUILD_BUG_ON_INVALID(x); 0; })Quoted 10 lines
arch/x86/kernel/fpu/internal.h +0
-0#endif /* Used in init.c */ extern void fpstate_init_user (struct fpstate *fpstate);extern void fpstate_reset (struct fpu *fpu);base-commit:
d6ef8b40d075c425f548002d2f35ae3f06e9cf96Signature · 1 line
2.47.1