From: Linus Torvalds <torvalds@linuxfoundation.org>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Jens Axboe <axboe@kernel.dk>
Cc: David Laight <David.Laight@aculab.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Matthew Wilcox (Oracle)" <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>,
Arnd Bergmann <arnd@kernel.org>,
"Jason@zx2c4.com" <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 0/7] minmax: reduce compilation time
Date: Fri, 26 Jul 2024 21:13:11 -0700 [thread overview]
Message-ID: <CAHk-=wgVZwBrCXyphH+HcY9X56EK0KNQrnWZ+Qb0Bz79POLSUw@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wjPr3b-=dshE6n3fM2Q0U3guT4reOoCZiBye_UMJ-qg1A@mail.gmail.com>
On Fri, 26 Jul 2024 at 14:36, Linus Torvalds
<torvalds@linuxfoundation.org> wrote:
>
> Now, fixing that, and you end up with
>
> Longest line is 61861 (82kB)
>
> so it's now "only" 82kB in size, and that actually comes from
> <linux/bio.h>, which has this:
>
> static inline unsigned bio_segments(struct bio *bio)
> {
> ...
> bio_for_each_segment(bv, bio, iter)
> segs++;
Ok, so I was playing around with this some more, and got really fed up
with manually matching up where the longest line actually came from in
the preprocessor output, so I updated my stupid "longest-line.c"
program to just track the original file and line number as it was
walking through the preprocessor file.
And yes, I realize that nobody sane would do this in C, and this all
should be done in some sane language that is actually meant for string
parsing, and me writing scripts in C shows that there's something
seriously wrong with me.
I'm aware.
But anyway, it works. At least to some degree.
So I can do things like this:
$ make drivers/net/ethernet/marvell/mvpp2/mvpp2_main.i
$ ~/longest-line drivers/net/ethernet/marvell/mvpp2/mvpp2_main.i
and it will spit out
Longest line is drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:1136 (2346kB)
' ((((((pkt_size) + __builtin_choose_expr((sizeof(int) ==
sizeof(*(8 ? ((void *)((long)((__builtin_...'
to tell me that we have that insane 2.2 *megabyte* line due to the
MVPP2_SKB_HEADROOM thing, and I should apply this patch:
-#define MVPP2_SKB_HEADROOM min(max(XDP_PACKET_HEADROOM, NET_SKB_PAD), 224)
+#define MVPP2_SKB_HEADROOM
MIN_T(int,MAX_T(int,XDP_PACKET_HEADROOM, NET_SKB_PAD), 224)
to fix it.
At which point the above incantation starts giving Jens the evil eye again:
Longest line is include/linux/bio.h:194 (82kB)
' for (iter = ((bio)->bi_iter); (iter).bi_size && ((bv = ((struct
bio_vec) { .bv_page = (((&((((((bio...'
but while that is certainly an impressive 82kB line, we have some good
company in code VM header files, and I've also seen
Longest line is include/linux/page-flags.h:507 (27kB)
'static inline __attribute__((__gnu_inline__))
__attribute__((__unused__)) __attribute__((no_instrume...'
because the expansion from
__PAGEFLAG(Locked, locked, PF_NO_TAIL)
does indeed generate some impressive stuff. It's all the functions for
the locked bit handling generated from one line.
But my C scripting may be buggy.
Anyway, I'm throwing this out in the hopes that somebody will use this
to go "look, file XYZ generates a ridiculous X-megabyte line".
I found that 2.2MB expansion in mvpp2_main.c by basically just
randomly grepping for nested min/max use. There may be worse things
hiding.
Linus
next prev parent reply other threads:[~2024-07-27 4:13 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 14:26 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
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 [this message]
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='CAHk-=wgVZwBrCXyphH+HcY9X56EK0KNQrnWZ+Qb0Bz79POLSUw@mail.gmail.com' \
--to=torvalds@linuxfoundation.org \
--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=axboe@kernel.dk \
--cc=dan.carpenter@linaro.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mjguzik@gmail.com \
--cc=pedro.falcato@gmail.com \
--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