From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>,
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: Sat, 27 Jul 2024 17:31:19 +0100 [thread overview]
Message-ID: <1d87456d-b565-410f-bf4b-91fe5704617c@lucifer.local> (raw)
In-Reply-To: <93243310-22cf-4d44-810c-17629b46a33e@kernel.dk>
On Sat, Jul 27, 2024 at 09:38:54AM GMT, Jens Axboe wrote:
> On 7/27/24 9:30 AM, Jens Axboe wrote:
> > On 7/26/24 4:48 PM, Linus Torvalds wrote:
> >> I didn't even look at what the issue was with the
> >> bio_for_each_segment() expansion, in the hope that Jens will make that
> >> one look better.
> >
> > I did take a quick look, pretty obviously bvec_iter_bvec() which makes
> > it horrible, which came from Kent's immutable work quite a while ago.
> > Not sure yet what to do about it, will spend some time on this next
> > week.
>
> Maybe something like this, totally untested...
>
> diff --git a/include/linux/bvec.h b/include/linux/bvec.h
> index f41c7f0ef91e..9ccccddadde2 100644
> --- a/include/linux/bvec.h
> +++ b/include/linux/bvec.h
> @@ -130,12 +130,15 @@ struct bvec_iter_all {
> (mp_bvec_iter_page((bvec), (iter)) + \
> mp_bvec_iter_page_idx((bvec), (iter)))
>
> -#define bvec_iter_bvec(bvec, iter) \
> -((struct bio_vec) { \
> - .bv_page = bvec_iter_page((bvec), (iter)), \
> - .bv_len = bvec_iter_len((bvec), (iter)), \
> - .bv_offset = bvec_iter_offset((bvec), (iter)), \
> -})
> +static inline struct bio_vec bvec_iter_bvec(struct bio_vec *bv,
> + struct bvec_iter iter)
> +{
> + return (struct bio_vec) {
> + .bv_page = bvec_iter_page(bv, iter),
> + .bv_len = bvec_iter_len(bv, iter),
> + .bv_offset = bvec_iter_offset(bv, iter)
> + };
> +}
>
> static inline bool bvec_iter_advance(const struct bio_vec *bv,
> struct bvec_iter *iter, unsigned bytes)
>
> --
> Jens Axboe
>
I tried this patch, doesn't seem to make a huge difference, going from
3,958,564 bytes with longest line of 82 kB to 3,943,824 bytes with a
longest line of 77kB.
It seems that the .bv_len = ... expansion is what's doing it, so I tried
patching mp_bvec_iter_len() as well to do a silly ?: thing (sorry), which
takes us down to 3,880,309 with longest line of 20kB.
This is starting to feel like whack-a-mole isn't it? I looked at the next
longest line, which originates from include/linux/pid_namespace.h believe
it or not where some compiler cleverness + a loop is resulting in _another_
combinatorial explosion.
Whacking that gets us down to 3,860,780 with longest line of 16kB and
(credit to Willy for telling me about the make <file basename>.i thing):
awk '{print length}' mm/compaction.i | sort -n
Tells me we have... 18 lines >10k remaining in that file.
Obviously dropping from 82 kB to 16 kB max size is handy but I think all
this points to the need for a fundamental fix for this (I vote for
fundamental simplification of core min()/max() macros, keep something
complicated around for true const cases, e.g. MIN()/MAX()).
Patch attached including Jens's change + mine.
----8<----
From 4303ddf7bd7c892f89c37d9b2cc4102860d8ef97 Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Date: Sat, 27 Jul 2024 17:25:03 +0100
Subject: [PATCH] Various attempts at whack-a-mole.
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
include/linux/bvec.h | 26 +++++++++++++++++---------
include/linux/pid_namespace.h | 8 ++++++--
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index f41c7f0ef91e..567522aec2f9 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -101,9 +101,14 @@ struct bvec_iter_all {
#define mp_bvec_iter_page(bvec, iter) \
(__bvec_iter_bvec((bvec), (iter))->bv_page)
-#define mp_bvec_iter_len(bvec, iter) \
- min((iter).bi_size, \
- __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done)
+static inline unsigned mp_bvec_iter_len(const struct bio_vec *bvec,
+ struct bvec_iter iter)
+{
+ unsigned remains = __bvec_iter_bvec(bvec, iter)->bv_len -
+ iter.bi_bvec_done;
+
+ return remains < iter.bi_size ? remains : iter.bi_size;
+}
#define mp_bvec_iter_offset(bvec, iter) \
(__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done)
@@ -130,12 +135,15 @@ struct bvec_iter_all {
(mp_bvec_iter_page((bvec), (iter)) + \
mp_bvec_iter_page_idx((bvec), (iter)))
-#define bvec_iter_bvec(bvec, iter) \
-((struct bio_vec) { \
- .bv_page = bvec_iter_page((bvec), (iter)), \
- .bv_len = bvec_iter_len((bvec), (iter)), \
- .bv_offset = bvec_iter_offset((bvec), (iter)), \
-})
+static inline struct bio_vec bvec_iter_bvec(struct bio_vec *bv,
+ struct bvec_iter iter)
+{
+ return (struct bio_vec) {
+ .bv_page = bvec_iter_page(bv, iter),
+ .bv_len = bvec_iter_len(bv, iter),
+ .bv_offset = bvec_iter_offset(bv, iter)
+ };
+}
static inline bool bvec_iter_advance(const struct bio_vec *bv,
struct bvec_iter *iter, unsigned bytes)
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index f9f9931e02d6..0c9642acc670 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -60,8 +60,12 @@ static inline int pidns_memfd_noexec_scope(struct pid_namespace *ns)
{
int scope = MEMFD_NOEXEC_SCOPE_EXEC;
- for (; ns; ns = ns->parent)
- scope = max(scope, READ_ONCE(ns->memfd_noexec_scope));
+ for (; ns; ns = ns->parent) {
+ int ns_scope = READ_ONCE(ns->memfd_noexec_scope);
+
+ if (ns_scope > scope)
+ scope = ns_scope;
+ }
return scope;
}
--
2.45.2
next prev parent reply other threads:[~2024-07-27 16:31 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 [this message]
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=1d87456d-b565-410f-bf4b-91fe5704617c@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=axboe@kernel.dk \
--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