All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
@ 2016-10-01 10:17 Namhyung Kim
  2016-10-05 11:37 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Namhyung Kim @ 2016-10-01 10:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Steven Rostedt

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.

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);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
  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-06 22:41 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-05 11:37 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

Em Sat, Oct 01, 2016 at 07:17:00PM +0900, Namhyung Kim escreveu:
> 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.

Steven, Ack?

- Arnaldo
 
> 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);
> -- 
> 2.10.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
  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
  2016-10-06 22:41 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2016-10-05 13:28 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

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.

But that said, it looks like offset == 0 is buggy.

Acked-by: Steven Rostedt <rostedt@goodmis.org>


-- 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);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/urgent] tools lib traceevent: Fix kbuffer_read_at_offset()
  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-06 22:41 ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-10-06 22:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, tglx, namhyung, rostedt, jolsa, linux-kernel, peterz, hpa, mingo

Commit-ID:  a130347973c408c0e0017a52c74cbc3226c1f0ef
Gitweb:     http://git.kernel.org/tip/a130347973c408c0e0017a52c74cbc3226c1f0ef
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Sat, 1 Oct 2016 19:17:00 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 5 Oct 2016 11:36:22 -0300

tools lib traceevent: Fix kbuffer_read_at_offset()

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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20161001101700.29146-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 3bcada3..65984f1 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);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
  2016-10-05 13:28 ` Steven Rostedt
@ 2016-10-07  4:19   ` Namhyung Kim
  2016-10-07 14:06     ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2016-10-07  4:19 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

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);
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
  2016-10-07  4:19   ` Namhyung Kim
@ 2016-10-07 14:06     ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2016-10-07 14:06 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

On Fri, 7 Oct 2016 13:19:08 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> 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. :)

Right, because kbuffer_read_at_offset() should not return a TIME_EXTEND.

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-07 14:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-10-07 14:06     ` Steven Rostedt
2016-10-06 22:41 ` [tip:perf/urgent] " tip-bot for Namhyung Kim

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.