mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Sami Tolvanen <samitolvanen@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
	linux-kernel@vger.kernel.org,
	clang-built-linux <llvm@lists.linux.dev>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [BUG] tracing: dynamic ftrace selftest detected failures
Date: Wed, 21 Aug 2024 16:32:46 +0100	[thread overview]
Message-ID: <ZsYInqSc-WS4UldP@J2N7QTR9R3.cambridge.arm.com> (raw)
In-Reply-To: <20240821070539.981b42e5f3b939c5ce5e3a71@kernel.org>

On Wed, Aug 21, 2024 at 07:05:39AM +0900, Masami Hiramatsu wrote:
> On Tue, 20 Aug 2024 08:10:42 -0700
> Sami Tolvanen <samitolvanen@google.com> wrote:
> 
> > On Tue, Aug 20, 2024 at 3:48 AM Mark Rutland <mark.rutland@arm.com> wrote:
> > >
> > > On Tue, Aug 20, 2024 at 10:03:30AM +0900, Masami Hiramatsu wrote:
> > > > On Mon, 19 Aug 2024 12:02:44 -0400
> > > > Steven Rostedt <rostedt@goodmis.org> wrote:
> > > >
> > > > > On Tue, 20 Aug 2024 00:56:49 +0900
> > > > > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> > > > > >
> > > > > > >
> > > > > > > We may need to add "noinline" or something to make sure those functions
> > > > > > > don't get inlined for LTO.
> > > > > >
> > > > > > Yeah, we need such option at least for function call test.
> > > > >
> > > > > Could you add the noinline, and if it fixes the issue send a patch?
> > > >
> > > > I found the target function already has "noinline". I tried to add noinline
> > > > to the testing function (callsite), but it also did not work.
> > > > I think "noinline" is for the compiler, but LTO is done by the linker.
> > >
> > > If LTO is breaking noinline, then that has much larger implications for
> > > noinstr code and similar, and means that LTO is unsound...
> > 
> > The noinline attribute is preserved in LLVM IR, so it should continue
> > to work with LTO. Which function are we talking about here? Are you
> > sure the function was inlined instead of being dropped completely?
> > Does marking the function __used help?
> 
> We are talking about trace_selftest_startup_dynamic_tracing() in
> kernel/trace/trace_selftest.c. The callee is func() which is actually
> DYN_FTRACE_TEST_NAME() in kernel/trace/trace_selftest_dynamic.c.
> That function passed as pointer (but the compiler can embed it by constant
> propagation.)

Ah, so IIUC the function isn't being inlined; the call is being
optimized away becase callee() has no side-effects.

That can happen without LTO if the caller is in the same compilation
unit, and I have worked around that in the past by adding a barrier()
into the callee.

If you add a barrier() into the callee, does it work? I suspect that's a
reasonable workaround.

Mark.

  parent reply	other threads:[~2024-08-21 15:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19  8:11 Masami Hiramatsu
2024-08-19 15:29 ` Steven Rostedt
2024-08-19 15:56   ` Masami Hiramatsu
2024-08-19 16:02     ` Steven Rostedt
2024-08-19 23:34       ` Masami Hiramatsu
2024-08-20  1:03       ` Masami Hiramatsu
2024-08-20 10:48         ` Mark Rutland
2024-08-20 13:56           ` Steven Rostedt
2024-08-20 15:10           ` Sami Tolvanen
2024-08-20 15:20             ` Steven Rostedt
2024-08-20 22:05             ` Masami Hiramatsu
2024-08-20 22:11               ` Steven Rostedt
2024-08-20 23:43                 ` Masami Hiramatsu
2024-08-20 23:49                   ` Steven Rostedt
2024-08-21  0:15                     ` Masami Hiramatsu
2024-08-21  0:21                   ` Masami Hiramatsu
2024-08-21 15:06                     ` Sami Tolvanen
2024-08-21 15:32               ` Mark Rutland [this message]
2024-08-21 15:42                 ` Mark Rutland
2024-08-21 15:50                   ` Steven Rostedt
2024-08-23  0:04                     ` Masami Hiramatsu

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=ZsYInqSc-WS4UldP@J2N7QTR9R3.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mhiramat@kernel.org \
    --cc=nathan@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    /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

Powered by JetHome