From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE93212D65 for ; Fri, 10 Jan 2025 18:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736532635; cv=none; b=SzQZ0/bkUf7P7rvspLmH5QT7yRk54E6woqsDKsOmEs7haqFICB1tDpOXhZsL8ej1AiP+2Df/LtFpwUc603q0tCxqBQyLXTL1OKXgSy63K+gBZE83zhHUwR5aEcPDFNlEHoC0XCoUbBhfkO6hRY5i3u1/G+Wc/AwzBNHfFHarqLM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736532635; c=relaxed/simple; bh=ubZ9JIPNnhmZmPsUXT/aCgLPwuP8jxT+BLNuTzIGtUI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ixaDaDU+kqlGv+fvzVC8H3ShmWJCP3I80oCialCQDd8/PGd4k0sVOi0e2MjdZBlTC0y4M0BOta/KhK347UUVVIO7WelfD4B+8RXMEmSgM5GdyfDJMEJx7OlkHjuminJSJfG2kEY/VxNU3ciNB0dQzl7QgSfH7XsSpfZ4zepJLXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ecNj/e2I; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ecNj/e2I" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef9da03117so6082910a91.1 for ; Fri, 10 Jan 2025 10:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736532633; x=1737137433; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Zg2xc913NtwsqTvDRv0wdwJunEB36gSPNin0ldygshE=; b=ecNj/e2I33ILSvXMAupJMq+WiXCvwSkIbO89pvbUUT04w+RCEa1InhFJDjLiOFe09R oO54MPEsUV93nKr+PcL34UkH2SPGpyMT0XXEtB28o09wcWaH6uhJlO2a93dhc+TcB8LJ mlCsAaHyYR0DT9ZuyisWjDWCcXwDAVTiy640NCK+XcwM3oAu15+lYAYoff+JEql1cE+T mCCG+wDMD8YY1b5x5ANMOU1BKvndTygGrTH2qUSWECS3Ll/RIEGlDpc9ST3VAYJJ3mxY SiIkufjUCtvzwd0MeQIDXxWrcP9FgzTd1iH6wmp3Ks6Xz/roIszD/0JmGFkJ69wRdc9/ Fztw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736532633; x=1737137433; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zg2xc913NtwsqTvDRv0wdwJunEB36gSPNin0ldygshE=; b=QEQpHHG+YiWoBojKbxIX4AAML69rvelGlzNaXGON0T1jLtHCFU2MSRwy4/FXxfdzFe JHo83EP86ma7bIdlLh81FOd6fyyXg4hGFj1xr2DhloDZGkjtOrDMFBisFh/5vfmPH8NU olzpE55xW6OOr8gmZAXVc34EOyxNwzO6pbXCwn1bLB7UXeWP8/p1mWtMlGMBei92u9q0 8cQahg+3B1o+mfS9IvNuahygo18BTnPvBnyOu+vkit90QujOH9T2i16GTkwDm4kw2eoS p8TKbcRPZT66P/h5hovJZy3UJSTJtC/ur8FlHRHHDq/QimSMa7+0QQgCMDQ7eyTt0ZuI tbWQ== X-Forwarded-Encrypted: i=1; AJvYcCVoMI1MG9urxOZ3nfUqEuNWw/hMVfJ9E7PBTB/e1b803CyCbELSZBrnAnegXymzc+8APQBxukHSyOjAfpI=@vger.kernel.org X-Gm-Message-State: AOJu0YzivUKem5/so6f2XWzAX2EfPptUyK0vzXDnrLD4lgEY6BYvuLcr YLj+8hQ5VbPJaNcvJTLNCBXswt5W6PRuXUtWo6I0ndmj/WDHILhGp7/H+vZdQFXPZ+0F8wg/ZUH rYQ== X-Google-Smtp-Source: AGHT+IFDJns65+lkpM0KwYuhoV+3Jex8IgzEW+srOsqPjo9V91J3F7wRQpsNOtThEm2crh8v2cQxWgJDJc8= X-Received: from pjbsy14.prod.google.com ([2002:a17:90b:2d0e:b0:2ef:d136:17fc]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:fc4f:b0:2ee:6d04:9dac with SMTP id 98e67ed59e1d1-2f548f7ed36mr14640898a91.32.1736532632807; Fri, 10 Jan 2025 10:10:32 -0800 (PST) Date: Fri, 10 Jan 2025 10:10:31 -0800 In-Reply-To: <20241226231159.10848-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241226231159.10848-1-ebiggers@kernel.org> Message-ID: Subject: Re: [PATCH] x86/fpu: make WARN_ON_FPU get fully optimized out From: Sean Christopherson To: Eric Biggers Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" Content-Type: text/plain; charset="us-ascii" On Thu, Dec 26, 2024, Eric Biggers wrote: > From: Eric Biggers > > 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 > --- > 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 >