From: Ingo Molnar <mingo@kernel.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2] noinstr: Use asm_inline() in instrumentation_{begin,end}()
Date: Tue, 22 Apr 2025 22:05:06 +0200 [thread overview]
Message-ID: <aAf2crZau98tHFSn@gmail.com> (raw)
In-Reply-To: <CAFULd4bo0NGzZGLEs+pYoOJrDVLyKt2=Piug-LtU-WhFGwYTzQ@mail.gmail.com>
* Uros Bizjak <ubizjak@gmail.com> wrote:
> > That still doesn't make it clear where the apparently ~10
> > instructions per inlining come from, right?
>
> The growth is actually from different inlining decisions, that cover
> not only inlining of small functions, but other code blocks (hot vs.
> cold, tail duplication, etc) too. The compiler uses certain
> thresholds to estimate inlining gain (thresholds are different for
> -Os and -O2). Artificially bloated functions that don't use
> asm_inline() fall under this threshold (IOW, the inlining would
> increase size too much), so they are not inlined; code blocks that
> enclose unfixed asm clauses are treated differently than when they
> use asm_inline() instead of asm(). When asm_inline() is introduced,
> the size of the function (and consequently inlining gain) is
> estimated more accurately, the estimated size is lower, so there is
> more inlining happening.
>
> I'd again remark that the code size is not the right metric when
> compiling with -O2.
Understood, but still we somehow have to be able to measure whether the
marking of these primitives with asm_inline() is beneficial in
isolation - even if on a real build the noise of GCC's overall inlining
decisions obscure the results - and may even reverse them.
Is there a way to coax GCC into a mode of build where such changes can
be measured in a better fashion?
For example would setting -finline-limit=1000 or -finline-limit=10 (or
some other well-chosen inlining threshold value, or tweaking any of the
inliner parameters via --param values?), just for the sake of
measurement, give us more representative .text size change values?
Because, ideally, if we do these decisions correctly at the asm()
level, compilers will, eventually, after a few decades, catch up
and do the right thing as well. ;-)
Thanks,
Ingo
next prev parent reply other threads:[~2025-04-22 20:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 0:27 [PATCH v2] noinstr: Use asm_inline() in instrumentation_{begin,end}() Josh Poimboeuf
2025-04-15 7:48 ` Peter Zijlstra
2025-04-15 14:52 ` Josh Poimboeuf
2025-04-22 12:02 ` Ingo Molnar
2025-04-22 13:22 ` Uros Bizjak
2025-04-22 20:05 ` Ingo Molnar [this message]
2025-04-23 7:07 ` Uros Bizjak
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=aAf2crZau98tHFSn@gmail.com \
--to=mingo@kernel.org \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.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