[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wgVZwBrCXyphH+HcY9X56EK0KNQrnWZ+Qb0Bz79POLSUw@mail.gmail.com>
Date: Fri, 26 Jul 2024 21:13:11 -0700
From: Linus Torvalds <torvalds@...uxfoundation.org>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Jens Axboe <axboe@...nel.dk>
Cc: David Laight <David.Laight@...lab.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>, Christoph Hellwig <hch@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Dan Carpenter <dan.carpenter@...aro.org>, Arnd Bergmann <arnd@...nel.org>,
"Jason@...c4.com" <Jason@...c4.com>, "pedro.falcato@...il.com" <pedro.falcato@...il.com>,
Mateusz Guzik <mjguzik@...il.com>, "linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH 0/7] minmax: reduce compilation time
On Fri, 26 Jul 2024 at 14:36, Linus Torvalds
<torvalds@...uxfoundation.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
Powered by blists - more mailing lists