From: Namhyung Kim <namhyung@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
Date: Fri, 7 Oct 2016 13:19:08 +0900 [thread overview]
Message-ID: <20161007041907.GC31113@sejong> (raw)
In-Reply-To: <20161005092801.3a8e9166@gandalf.local.home>
Hi Steve,
On Wed, Oct 05, 2016 at 09:28:01AM -0400, Steven Rostedt wrote:
> On Sat, 1 Oct 2016 19:17:00 +0900
> Namhyung Kim <namhyung@kernel.org> wrote:
>
> > When it's called with an offset less than or equal to the first event,
> > it'll return a garbage value since the data is not initialized.
>
> Well, it can at most be equal to (unless offset is negative) because
> kbuffer_load_subbuffer() sets kbuf->curr to zero.
Actually kbuffer_load_subbuffer() calls kbuf->next_event(). Inside
the function it has a loop updating next valid event. Sometimes, the
data starts with TIME_EXTEND with value of 0 and the loop skips it
which ended up setting kbuf->curr to 8. :)
I'll take a look it later.
>
> But that said, it looks like offset == 0 is buggy.
>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
Thanks,
Namhyung
>
>
> -- Steve
>
> >
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/lib/traceevent/kbuffer-parse.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
> > index 3bcada3ae05a..65984f1c2974 100644
> > --- a/tools/lib/traceevent/kbuffer-parse.c
> > +++ b/tools/lib/traceevent/kbuffer-parse.c
> > @@ -622,6 +622,7 @@ void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset,
> >
> > /* Reset the buffer */
> > kbuffer_load_subbuffer(kbuf, kbuf->subbuffer);
> > + data = kbuffer_read_event(kbuf, ts);
> >
> > while (kbuf->curr < offset) {
> > data = kbuffer_next_event(kbuf, ts);
>
next prev parent reply other threads:[~2016-10-07 4:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-01 10:17 [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset() Namhyung Kim
2016-10-05 11:37 ` Arnaldo Carvalho de Melo
2016-10-05 13:28 ` Steven Rostedt
2016-10-07 4:19 ` Namhyung Kim [this message]
2016-10-07 14:06 ` Steven Rostedt
2016-10-06 22:41 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
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=20161007041907.GC31113@sejong \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.