Re: [PATCH 01/26] perf tools: Change thread_map::map into struct

From: Jiri Olsa
Date: Fri Jun 19 2015 - 18:05:53 EST


On Fri, Jun 19, 2015 at 06:07:13PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jun 18, 2015 at 11:48:40PM +0200, Jiri Olsa escreveu:
> > We need to store command names with the pid. Changing
> > map to be struct holding pid. Process name is coming
> > in shortly.
> >
> > Link: http://lkml.kernel.org/n/tip-z4zuyvcxa6glzqm8qubk6vg7@xxxxxxxxxxxxxx
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> > tools/perf/builtin-trace.c | 4 ++--
> > tools/perf/tests/openat-syscall-tp-fields.c | 2 +-
> > tools/perf/util/auxtrace.c | 4 ++--
> > tools/perf/util/event.c | 6 +++---
> > tools/perf/util/evlist.c | 4 ++--
> > tools/perf/util/evsel.c | 2 +-
> > tools/perf/util/thread_map.c | 22 +++++++++++-----------
> > tools/perf/util/thread_map.h | 8 +++++++-
> > 8 files changed, 29 insertions(+), 23 deletions(-)
> >
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index 4bf805b2fbf6..b75a68c385ea 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -2324,7 +2324,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> > */
> > if (trace->filter_pids.nr > 0)
> > err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries);
> > - else if (evlist->threads->map[0] == -1)
> > + else if (thread_map__pid(evlist->threads, 0) == -1)
> > err = perf_evlist__set_filter_pid(evlist, getpid());
> >
> > if (err < 0) {
> > @@ -2342,7 +2342,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> > if (forks)
> > perf_evlist__start_workload(evlist);
> >
> > - trace->multiple_threads = evlist->threads->map[0] == -1 ||
> > + trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 ||
> > evlist->threads->nr > 1 ||
> > perf_evlist__first(evlist)->attr.inherit;
> > again:
> > diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
> > index 6245221479d7..ebc6e7938c9a 100644
> > --- a/tools/perf/tests/openat-syscall-tp-fields.c
> > +++ b/tools/perf/tests/openat-syscall-tp-fields.c
> > @@ -45,7 +45,7 @@ int test__syscall_openat_tp_fields(void)
> >
> > perf_evsel__config(evsel, &opts);
> >
> > - evlist->threads->map[0] = getpid();
> > + thread_map__pid(evlist->threads, 0) = getpid();
>
> So this 'function(parms) = something' idiom looks ugly/unfamiliar, can't
> we keep using:
>
> evlist->thread->map[0].pid = getpid();

hum, I like it more than above line.. what's ugly about that assignment?

I'm adding thread_map__comm to access new 'comm' member,
so I wanted to introduce easy accessors for both members

get/set functions seem like overkill.. we could use upper case to state
that it's a macro:

THREAD_MAP__PID(evlist->threads, 0) = getpid();

anyway I can keep the original way if you insist ;-)

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/