From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751487AbcJGETT (ORCPT ); Fri, 7 Oct 2016 00:19:19 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:54573 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750717AbcJGETM (ORCPT ); Fri, 7 Oct 2016 00:19:12 -0400 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.204 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Fri, 7 Oct 2016 13:19:08 +0900 From: Namhyung Kim To: Steven Rostedt CC: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML Subject: Re: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset() Message-ID: <20161007041907.GC31113@sejong> References: <20161001101700.29146-1-namhyung@kernel.org> <20161005092801.3a8e9166@gandalf.local.home> MIME-Version: 1.0 In-Reply-To: <20161005092801.3a8e9166@gandalf.local.home> User-Agent: Mutt/1.7.0 (2016-08-17) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/10/07 13:19:08, Serialize by Router on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/10/07 13:19:08, Serialize complete at 2016/10/07 13:19:08 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 Thanks, Namhyung > > > -- Steve > > > > > Cc: Steven Rostedt > > Signed-off-by: Namhyung Kim > > --- > > 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); >