Linux Trace Kernel
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Daniel Wagner <dwagner@suse.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-trace-kernel@vger.kernel.org,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: kprobe not always triggering
Date: Thu, 16 Jan 2025 08:48:18 +0900	[thread overview]
Message-ID: <20250116084818.2160d4faf29cf34c9b6e612f@kernel.org> (raw)
In-Reply-To: <e5d64ac8-5a30-4196-a5e5-b3d2743356b1@flourine.local>

Hi Daniel,

On Wed, 15 Jan 2025 17:29:34 +0100
Daniel Wagner <dwagner@suse.de> wrote:

> On Wed, Jan 15, 2025 at 10:17:15AM -0500, Steven Rostedt wrote:
> > [ Adding Masami ]
> > Is it consistently the same locations being dropped?
> 
> Yes, it is very consistent.
> 
> > There's been cases of a compiler inlining some functions for the code
> > called in the same file. If that happened, then those will likely be
> > dropped. That can be tested by adding:
> > 
> > bool noinline nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
> >                 enum nvme_ctrl_state new_state) 
> > 
> > You would think it shouldn't inline it, but there's nothing in the spec
> > that says it can't do so.
> 
> This did the trick, now I see the missing state transitions.

Have you tried to use `perf probe`? Even if it is inlined, you can find them
by

 perf probe -a nvme_change_ctrl_state new_state

But perhaps, some of them are inlined with constant numbers (maybe you can
find them as nvme_change_ctrl_state.constprop.XXX in kallsyms)

If my guess is correct, it is not inlined but the constant propagation
optimization[1] has been done by the compiler.

[1] https://en.wikipedia.org/wiki/Constant_folding#Constant_propagation

IIRC, commit 66f69b219716 ("perf probe: Support DW_AT_const_value constant value")
should support this case.

Thank you,

> 
> > > The system is idle, so I hope it's not just a dropped event. Any ideas
> > > what I am doing wrong?
> > 
> > I don't think it's a dropped event. It's not busy enough. But the compiler
> > making a copy of the function (by inlining or what not) can cause something
> > like this to happen.
> 
> I didn't expect that the compiler does inlining and not inlining at the
> same time. Again what learned :)
> 
> Thanks,
> Daniel


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  parent reply	other threads:[~2025-01-15 23:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15  8:26 kprobe not always triggering Daniel Wagner
2025-01-15 15:17 ` Steven Rostedt
2025-01-15 16:29   ` Daniel Wagner
2025-01-15 16:37     ` Steven Rostedt
2025-01-15 16:50       ` Daniel Wagner
2025-01-15 23:48     ` Masami Hiramatsu [this message]
2025-01-16 12:04       ` Daniel Wagner
2025-01-17  8:52         ` 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=20250116084818.2160d4faf29cf34c9b6e612f@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=dwagner@suse.de \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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