From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: David Laight <David.Laight@aculab.com>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>,
Arnd Bergmann <arnd@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
"pedro.falcato@gmail.com" <pedro.falcato@gmail.com>,
Mateusz Guzik <mjguzik@gmail.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 4/7] minmax: Simplify signedness check
Date: Fri, 26 Jul 2024 14:27:06 +0100 [thread overview]
Message-ID: <f1601a08-6d6e-4074-8f86-4be7869641d8@lucifer.local> (raw)
In-Reply-To: <f2ee5fe686f7440ab1e5469a6e560064@AcuMS.aculab.com>
On Fri, Jul 26, 2024 at 12:57:43PM GMT, David Laight wrote:
> From: Lorenzo Stoakes
> > Sent: 26 July 2024 10:44
> >
> > On Thu, Jul 25, 2024 at 10:02:45AM GMT, Linus Torvalds wrote:
[snip]
> > > Christ. This whole series is a nightmare of "add complexity to deal
> > > with stupid issues".
> > >
> > > But the kernel test robot clearly found even more issues.
> > >
> > > I think we need to just go back to the old code. It was stupid and
> > > limited and caused us to have to be more careful about types than was
> > > strictly necessary.
> >
> > The problem is simply reverting reveals that seemingly a _ton_ of code has
> > come to rely on the relaxed conditions.
> >
> > When I went to gather the numbers for my initial report I had to manually
> > fix up every case which was rather painful, and that was just a defconfig +
> > a few extra options. allmodconfig is likely to be a hellscape.
> >
> > I've not dug deep into the ins + outs of this, so forgive me for being
> > vague (Arnd has a far clearer understanding) - but it seems that the
> > majority of the complexity comes from having to absolutely ensure all this
> > works for compile-time constant values.
>
> The problems arise due to some odd uses, not just the requirement for compile-time
> constants for on-stack array sizes.
Odd implies not many, same argument applies.
[snip]
>
> > Arnd had a look through and determined there weren't _too_ many cases where
> > we need this (for instance array sizes).
> >
> > So I wonder whether we can't just vastly simplify this stuff (and reducing
> > the macro expansion hell) for the usual case, and implement something like
> > cmin()/cmax() or whatever for the true-constant cases?
>
> I did do that in a patch set from much earlier in the year.
> But Linus said they'd need to be MIN() and MAX() and that requires changes
> to a few places where those are already defined.
OK, so what's stopping you from doing that?
In order to implement a MIN()/MAX() you'd need to change call sites only
(should be a managable amount), so we can change this too?
I'm concerned that a solution is being proposed here and then handwaved
away...
Unfortunately a revert is no longer possible (I had to fix up 33 call sites
manually just for my defconfig build to compare perf before/after), so if
the intent is to eliminate the complexity, then we need a practical way
forward.
>
> > > But it was also about a million times simpler, and didn't cause build
> > > time regressions.
>
> Just bugs because people did min_t(short, 65536, 128) and didn't expect zero.
>
> It has to be said that the chances of a min(negative_value, unsigned_constant)
> appearing are pretty slim.
> All these tests are there to trap that case.
>
> There is always the option of disabling the tests for 'normal' build, but
> leaving them there for (say) the W=1 builds.
> Then it won't matter as much if the tests slow down the build a little.
Very much NAK disabling tests as a solution! Also leaving them for a build
that's apparently broken... yeah not a fan.
>
> I think I have tried a W=1 build - but there are too many warnings/errors
> from other places to get anywhere.
> A lot are for 'unsigned_var >= 0' in paths that get optimised away.
> The compiler doesn't help!
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>
next prev parent reply other threads:[~2024-07-26 13:27 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 14:26 [PATCH 0/7] minmax: reduce compilation time David Laight
2024-07-24 14:28 ` [PATCH 1/7] minmax: Put all the clamp() definitions together David Laight
2024-07-24 14:29 ` [PATCH 2/7] minmax: Use _Static_assert() instead of static_assert() David Laight
2024-07-24 14:29 ` [PATCH 3/7] compiler.h: Add __if_constexpr(expr, if_const, if_not_const) David Laight
2024-07-24 17:32 ` Arnd Bergmann
2024-07-25 9:12 ` David Laight
2024-07-24 19:48 ` Linus Torvalds
2024-07-25 8:45 ` David Laight
2024-07-24 14:30 ` [PATCH 4/7] minmax: Simplify signedness check David Laight
2024-07-24 16:48 ` Arnd Bergmann
2024-07-24 20:02 ` Linus Torvalds
2024-07-25 9:00 ` David Laight
2024-07-25 17:02 ` Linus Torvalds
2024-07-26 9:43 ` Lorenzo Stoakes
2024-07-26 12:57 ` David Laight
2024-07-26 13:27 ` Lorenzo Stoakes [this message]
2024-07-25 13:24 ` kernel test robot
2024-07-25 16:39 ` David Laight
2024-07-24 14:31 ` [PATCH 5/7] minmax: Factor out the zero-extension logic from umin/umax David Laight
2024-07-24 14:32 ` [PATCH 6/7] minmax: Optimise _Static_assert() check in clamp() David Laight
2024-07-24 14:33 ` [PATCH 7/7] minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments David Laight
2024-07-24 17:03 ` Arnd Bergmann
2024-07-25 9:07 ` David Laight
2024-07-24 19:34 ` [PATCH 0/7] minmax: reduce compilation time Lorenzo Stoakes
2024-07-24 19:52 ` Linus Torvalds
2024-07-26 18:12 ` Lorenzo Stoakes
2024-07-26 18:24 ` Linus Torvalds
2024-07-26 18:56 ` Lorenzo Stoakes
2024-07-26 19:21 ` Lorenzo Stoakes
2024-07-26 21:36 ` Linus Torvalds
2024-07-26 21:46 ` Jens Axboe
2024-07-26 22:48 ` Linus Torvalds
2024-07-27 15:30 ` Jens Axboe
2024-07-27 15:38 ` Jens Axboe
2024-07-27 16:31 ` Lorenzo Stoakes
2024-07-27 16:36 ` Jens Axboe
2024-07-27 16:41 ` Lorenzo Stoakes
2024-07-27 16:52 ` Jens Axboe
2024-07-27 16:56 ` Lorenzo Stoakes
2024-07-28 11:32 ` David Laight
2024-07-27 4:13 ` Linus Torvalds
2024-07-27 4:14 ` Linus Torvalds
2024-07-27 8:08 ` David Laight
2024-07-27 18:58 ` Lorenzo Stoakes
2024-07-27 19:21 ` Linus Torvalds
2024-07-28 11:17 ` David Laight
2024-07-28 13:07 ` Lorenzo Stoakes
2024-07-27 17:33 ` Matthew Wilcox
2024-07-27 18:16 ` Linus Torvalds
2024-07-27 8:07 ` Lorenzo Stoakes
2024-07-27 16:26 ` Linus Torvalds
2024-07-27 18:44 ` Lorenzo Stoakes
2024-07-30 4:10 ` Linus Torvalds
2024-07-30 10:36 ` Arnd Bergmann
2024-07-28 17:57 ` Geert Uytterhoeven
2024-07-28 18:43 ` Lorenzo Stoakes
2024-07-26 21:32 ` David Laight
2024-07-26 21:38 ` Linus Torvalds
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=f1601a08-6d6e-4074-8f86-4be7869641d8@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=David.Laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mjguzik@gmail.com \
--cc=pedro.falcato@gmail.com \
--cc=torvalds@linuxfoundation.org \
--cc=willy@infradead.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