linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Arun Kalyanasundaram <arunkaly@google.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	mingo@kernel.org, David Carrillo-Cisneros <davidcc@google.com>
Subject: Re: tracing/kprobes: [Bug] Identical timestamps on two kprobes that are few instructions apart
Date: Fri, 7 Jul 2017 15:01:36 -0400	[thread overview]
Message-ID: <20170707150136.7f167b85@gandalf.local.home> (raw)
In-Reply-To: <CAGjB_BpTmk+gvNMpuxWweu1UnzFixPrxKKAxzJxm2svz+-FVXg@mail.gmail.com>

On Fri, 7 Jul 2017 10:34:48 -0700
Arun Kalyanasundaram <arunkaly@google.com> wrote:

> Hi,
> 
> I am trying to use kprobes to time a few kernel functions. However, when I
> add two kprobes on a function that are a few instructions apart, I
> sometimes get the same timestamp (measured in nano seconds) on the two
> probes.
> 
> For example, if I add the two probes as follows,
> 1) perf probe -a "kprobe1=__schedule"
> 2) perf probe -a "kprobe2=__schedule+12"
> 
> I then use "perf record" on a multi-threaded benchmark (e.g. stream:
> https://www.cs.virginia.edu/stream/) to collect samples. I then see the
> same timestamp on kprobe1 and kprobe2 for the same thread running on the
> same CPU. Following is an example of the output showing the same timestamp
> on the two probes.
> 
> comm,tid,cpu,time,event,ip,sym
> stream,62182,[064],3020935.384132080,probe:kprobe1,ffffffffb36399f1,__schedule
> stream,62182,[064],3020935.384132080,probe:kprobe2,ffffffffb36399fd,__schedule
> 
> Since it happens intermittently, I am wondering if there is some sort of
> race condition here. Please let me know if this is an expected behavior or
> is there something wrong in the way I use kprobes.
>

I don't see this with ftrace. What kernel are you using?

 # cd /sys/kernel/debug/tracing
 # echo perf > trace_clock
 # echo 'p:s1 __schedule' > kprobe_events
 # echo 'p:s2 __schedule+12' >> kprobe_events
 # echo 1 > events/kprobes/enable
 # cd
 # trace-cmd extract 
 # trace-cmd report -t --cpu 0 | less

I didn't see anything where they had the same timestamps.


-- Steve

       reply	other threads:[~2017-07-07 19:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGjB_BpTmk+gvNMpuxWweu1UnzFixPrxKKAxzJxm2svz+-FVXg@mail.gmail.com>
2017-07-07 19:01 ` Steven Rostedt [this message]
2017-07-07 23:06   ` tracing/kprobes: [Bug] Identical timestamps on two kprobes that are few instructions apart Arun Kalyanasundaram
2017-07-10  0:18     ` Masami Hiramatsu
2017-07-10 17:38       ` Arun Kalyanasundaram
2017-07-09 12:51 ` 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=20170707150136.7f167b85@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=arunkaly@google.com \
    --cc=davidcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@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;
as well as URLs for NNTP newsgroup(s).