Re: [PATCH v2] noinstr: Use asm_inline() in instrumentation_{begin,end}()
From: Josh Poimboeuf
Date: Tue Apr 15 2025 - 10:52:56 EST
On Tue, Apr 15, 2025 at 09:48:49AM +0200, Peter Zijlstra wrote:
> On Mon, Apr 14, 2025 at 05:27:11PM -0700, Josh Poimboeuf wrote:
> > Use asm_inline() in the instrumentation begin/end macros to prevent the
> > compiler from making poor inlining decisions based on the length of the
> > objtool annotations.
> >
> > Without the objtool annotations, each macro resolves to a single NOP.
> > Using inline_asm() seems obviously correct here as it accurately
> > communicates the actual code size to the compiler.
> >
> > These macros are used by WARN() and lockdep, so this change can affect a
> > lot of functions.
> >
> > For a defconfig kernel built with GCC 14.2.1, bloat-o-meter reports a
> > 0.17% increase in text size:
> >
> > add/remove: 74/352 grow/shrink: 914/353 up/down: 80747/-47120 (33627)
> > Total: Before=19460272, After=19493899, chg +0.17%
>
> Hmm, I was surprised that defconfig was affected at all. Why does
> defconfig have DEBUG_ENTRY on?
Hm, looks like Ingo enabled that with:
70c8dc910427 ("x86/defconfig: Enable CONFIG_DEBUG_ENTRY=y")
Though, is there any reason NOINSTR validation needs to depend on
DEBUG_ENTRY?
--
Josh