From: Thomas Gleixner <tglx@kernel.org>
To: "Bird, Tim" <Tim.Bird@sony.com>,
kernel test robot <lkp@intel.com>,
"pmladek@suse.com" <pmladek@suse.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"john.ogness@linutronix.de" <john.ogness@linutronix.de>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>
Cc: "oe-kbuild-all@lists.linux.dev" <oe-kbuild-all@lists.linux.dev>,
"francesco@valla.it" <francesco@valla.it>,
"geert@linux-m68k.org" <geert@linux-m68k.org>,
"shashankbalaji02@gmail.com" <shashankbalaji02@gmail.com>,
"linux-embedded@vger.kernel.org" <linux-embedded@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v4 1/1] printk: fix zero-valued printk timestamps in early boot
Date: Wed, 15 Apr 2026 00:48:33 +0200 [thread overview]
Message-ID: <87o6jldupq.ffs@tglx> (raw)
In-Reply-To: <MW5PR13MB563241C9F7C8BCAF0D5F3D21FD242@MW5PR13MB5632.namprd13.prod.outlook.com>
On Mon, Apr 13 2026 at 17:58, Tim Bird wrote:
> This is a false positive warning from the compiler (see below).
This is _NOT_ a false positive warning. The compiler is absolutely
correct.
>> 34
>> 35 /* returns a nanosecond value based on early cycles */
>> 36 static inline u64 early_times_ns(void)
>> 37 {
>> 38 if (CONFIG_EARLY_CYCLES_KHZ)
>> 39 /*
>> 40 * Note: the multiply must precede the division to avoid
>> 41 * truncation and loss of resolution
>> 42 * Don't use fancier MULT/SHIFT math here. Since this is
>> 43 * static, the compiler can optimize the math operations.
>> 44 */
>> > 45 return (early_unsafe_cycles() * NS_PER_KHZ) / CONFIG_EARLY_CYCLES_KHZ;
> Based on this conditional, it's not possible for CONFIG_EARLY_CYCLES_KHZ to be zero
> on this line of code. Does GCC not catch this?
> if (0)
> x = <some expression>/0;
>
> So this is a false positive.
You clearly fail to understand how compilers work. The dead code
elimination happens _after_ the evaluation of the code and the compiler
does not care whether your initial condition evaluated to false or
not. That's documented compiler behaviour,
Whether GCC complains about it or not is completely irrelevant.
> I'll see if I can silence this warning.
Don't put much effort into it. This whole hack is going nowhere.
Thanks,
tglx
next prev parent reply other threads:[~2026-04-14 22:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 20:37 [PATCH v4 0/1] printk: fix zero-valued printk timestamps Tim Bird
2026-04-10 20:37 ` [PATCH v4 1/1] printk: fix zero-valued printk timestamps in early boot Tim Bird
2026-04-12 10:10 ` kernel test robot
2026-04-13 17:58 ` Bird, Tim
2026-04-13 20:17 ` David Laight
2026-04-14 22:48 ` Thomas Gleixner [this message]
2026-04-12 11:12 ` kernel test robot
2026-04-12 12:55 ` kernel test robot
2026-04-14 7:03 ` Geert Uytterhoeven
2026-04-14 9:51 ` Roberto A. Foglietta
2026-04-14 22:38 ` Thomas Gleixner
2026-04-15 0:19 ` Roberto A. Foglietta
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=87o6jldupq.ffs@tglx \
--to=tglx@kernel.org \
--cc=Tim.Bird@sony.com \
--cc=francesco@valla.it \
--cc=geert@linux-m68k.org \
--cc=john.ogness@linutronix.de \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=shashankbalaji02@gmail.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