[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190513200015.GA2064@krava>
Date: Mon, 13 May 2019 22:00:15 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Jiri Olsa <jolsa@...nel.org>, lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Stanislav Fomichev <sdf@...ichev.me>,
Song Liu <songliubraving@...com>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 01/12] perf tools: Separate generic code in
dso__data_file_size
On Mon, May 13, 2019 at 04:47:54PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 08, 2019 at 03:19:59PM +0200, Jiri Olsa escreveu:
> > Moving file specific code in dso__data_file_size function
> > into separate file_size function. I'll add bpf specific
> > code in following patches.
>
> I'm applying this patch, as it just moves things around, no logic
> change, but can you please clarify a question I have after looking at
> this patch?
>
> > Link: http://lkml.kernel.org/n/tip-rkcsft4a0f8sw33p67llxf0d@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> > ---
> > tools/perf/util/dso.c | 19 ++++++++++++-------
> > 1 file changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> > index e059976d9d93..cb6199c1390a 100644
> > --- a/tools/perf/util/dso.c
> > +++ b/tools/perf/util/dso.c
> > @@ -898,18 +898,12 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
> > return r;
> > }
> >
> > -int dso__data_file_size(struct dso *dso, struct machine *machine)
> > +static int file_size(struct dso *dso, struct machine *machine)
> > {
> > int ret = 0;
> > struct stat st;
> > char sbuf[STRERR_BUFSIZE];
> >
> > - if (dso->data.file_size)
> > - return 0;
> > -
> > - if (dso->data.status == DSO_DATA_STATUS_ERROR)
> > - return -1;
> > -
> > pthread_mutex_lock(&dso__data_open_lock);
> >
> > /*
> > @@ -938,6 +932,17 @@ int dso__data_file_size(struct dso *dso, struct machine *machine)
> > return ret;
> > }
> >
> > +int dso__data_file_size(struct dso *dso, struct machine *machine)
> > +{
> > + if (dso->data.file_size)
> > + return 0;
> > +
> > + if (dso->data.status == DSO_DATA_STATUS_ERROR)
> > + return -1;
> > +
> > + return file_size(dso, machine);
> > +}
>
>
> So the name of the function suggests we want to know the
> "data_file_size" of a dso, then the logic in it returns _zero_ if a
> member named "dso->data.file_size" is _not_ zero, can you please
> clarify?
>
> I was expecting something like:
>
> if (dso->data.file_size)
> return dso->data.file_size;
>
> I.e. if we had already read it, return the cached value, otherwise go
> and call some other function to get that info somehow.
we keep the data size in dso->data.file_size,
the function just updates it
the return code is the error code.. not sure,
why its like that, but it is ;-)
maybe we wanted separate size and error code,
because the size needs to be u64 and we use
int everywhere.. less casting
jirka
Powered by blists - more mailing lists