From: Borislav Petkov <bp@alien8.de>
To: Vineet Gupta <vineet.gupta@linux.dev>
Cc: "Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
"Will Deacon" <will@kernel.org>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Xin Li (Intel)" <xin@zytor.com>,
"Brian Gerst" <brgerst@gmail.com>,
"Nikolay Borisov" <nik.borisov@suse.com>,
linux-kernel@vger.kernel.org,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"K Prateek Nayak" <kprateek.nayak@amd.com>,
"Robin Murphy" <robin.murphy@arm.com>,
iommu@lists.linux.dev, "Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
intel-xe@lists.freedesktop.org, llvm@lists.linux.dev,
"Jakub Jelinek" <jakub@redhat.com>
Subject: Re: [PATCH 0/4] Fix the x86 defconfig build with GCC 17
Date: Wed, 04 Nov 2026 21:18:41 +0000 [thread overview]
Message-ID: <9A0C01CD-F821-4156-A975-E7FC67C636E1@alien8.de> (raw)
In-Reply-To: <327c462a-3360-45fa-8398-4c23c1f2bd84@linux.dev>
On November 4, 2026 6:05:27 PM UTC, Vineet Gupta <vineet.gupta@linux.dev> wrote:
>+CC Jakub
>
>On 11/4/26 8:27 AM, Borislav Petkov wrote:
>> On Wed, Nov 04, 2026 at 08:07:17AM -0800, Vineet Gupta wrote:
>>> Fix build warnings and failures (CONFIG_WERROR=y) with a GCC 17 build.
>>> GCC 17 adds -Wconstant-logical-operand which is strict about operands
>>> of && or || that fold to a constant other than 0 or 1.
>> Just from looking at it, my initial reaction would be to disable that option.
>>
>> Because, frankly, I don't see the point.
>
>Here's my 2 cents:
>
>I wondered if this brings any codegen improvements, since we are telling the compiler that something is 0 or 1 vs. some other range before. And it doesn't, because of the way it is used. So focusing on just 1/4.
>
>- Constant bit: __builtin_constant_p(bit) && MASK_BIT_SET(bit) folds at compile time to the same truth value, with or without the !! bool conversion.
>- Variable bit: __builtin_constant_p(bit) is 0, so && short-circuits and the mask is never evaluated.
>
>Basically, the masked value never reaches generated code, so compiler gets nothing new to work with.
>
>So I did some digging, and turns out that it can be helpful to catch bugs in the source code itself. In fact GCC implemented the toggle at all, when Jakub spotted an issue with a typo: (data->flags && ff_genericize) vs. (data->flags & ff_genericize).
>
>In kernel, the predicate like *_BIT_SET() not returning a bool is not clean IMO and it used to return 0/1 before anyway so its not like we are going out of the way here.
>
>I'm mildly in the favor of keeping the warning, but ultimately your call, I can respin with it disabled.
>
>Thx,
>-Vineet
You might wanna look at the W= switches we have for less popular and more noisy options
--
Small device. Typos and formatting crap
prev parent reply other threads:[~2026-11-04 21:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:07 Vineet Gupta
2026-11-04 16:07 ` [PATCH 1/4] x86/cpufeatures: Make {REQUIRED,DISABLED}_MASK_BIT_SET() return 0 or 1 Vineet Gupta
2026-11-04 16:07 ` [PATCH 2/4] wait: Make ___wait_is_interruptible() " Vineet Gupta
2026-11-04 16:07 ` [PATCH 3/4] iommupt: Make PT_SUPPORTED_FEATURE() " Vineet Gupta
2026-11-04 16:07 ` [PATCH 4/4] drm/i915: Avoid -Wconstant-logical-operand with GCC 17 Vineet Gupta
2026-11-04 16:27 ` [PATCH 0/4] Fix the x86 defconfig build " Borislav Petkov
2026-11-04 18:05 ` Vineet Gupta
2026-11-04 21:18 ` Borislav Petkov [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=9A0C01CD-F821-4156-A975-E7FC67C636E1@alien8.de \
--to=bp@alien8.de \
--cc=airlied@gmail.com \
--cc=brgerst@gmail.com \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hpa@zytor.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jakub@redhat.com \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=joro@8bytes.org \
--cc=juri.lelli@redhat.com \
--cc=justinstitt@google.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=matthew.brost@intel.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nik.borisov@suse.com \
--cc=peterz@infradead.org \
--cc=robin.murphy@arm.com \
--cc=rodrigo.vivi@intel.com \
--cc=rostedt@goodmis.org \
--cc=simona@ffwll.ch \
--cc=tglx@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=vincent.guittot@linaro.org \
--cc=vineet.gupta@linux.dev \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/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
all inboxes | Powered by JetHome®