public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	 Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	"H . Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86/fpu: make WARN_ON_FPU get fully optimized out
Date: Fri, 10 Jan 2025 10:10:31 -0800	[thread overview]
Message-ID: <Z4Fil63TcgIgzwtx@google.com> (raw)
In-Reply-To: <20241226231159.10848-1-ebiggers@kernel.org>

On Thu, Dec 26, 2024, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> 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.
> 
> Fixes: 83242c515881 ("x86/fpu: Make WARN_ON_FPU() more robust in the !CONFIG_X86_DEBUG_FPU case")
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  arch/x86/kernel/fpu/internal.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/fpu/internal.h b/arch/x86/kernel/fpu/internal.h
> index dbdb31f55fc7..deb0a31b75e4 100644
> --- a/arch/x86/kernel/fpu/internal.h
> +++ b/arch/x86/kernel/fpu/internal.h
> @@ -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; })

>  #endif
>  
>  /* Used in init.c */
>  extern void fpstate_init_user(struct fpstate *fpstate);
>  extern void fpstate_reset(struct fpu *fpu);
> 
> base-commit: d6ef8b40d075c425f548002d2f35ae3f06e9cf96
> -- 
> 2.47.1
> 

      reply	other threads:[~2025-01-10 18:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-26 23:11 [PATCH] x86/fpu: make WARN_ON_FPU get fully optimized out Eric Biggers
2025-01-10 18:10 ` Sean Christopherson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z4Fil63TcgIgzwtx@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=ebiggers@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox