Re: [PATCH 04/10] perf machine: Introduce synthesize_threads methodout of open coded equivalent

From: Arnaldo Carvalho de Melo
Date: Tue Nov 12 2013 - 06:34:39 EST


Em Mon, Nov 11, 2013 at 09:50:45PM +0100, Ingo Molnar escreveu:
> * David Ahern <dsahern@xxxxxxxxx> wrote:

> > On 11/11/13, 1:22 PM, Arnaldo Carvalho de Melo wrote:
> > >+ if (perf_target__has_task(target))
> > >+ return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
> > >+ else if (perf_target__has_cpu(target))
> > >+ return perf_event__synthesize_threads(tool, process, machine, data_mmap);

> > Getting kind of long on the line lengths...

> Maybe we could start losing most of the perf_ prefixes - it's all about
> perf here, so it does not really add much information, does it?

In some cases that is ok, that is why I didn't call it 'perf_machine',
just 'machine', in others, like 'perf_event', I thought 'event' would be
too general when somebody tries to use this code together with other
libraries.

In some cases, like 'perf_target', probably its ok to move to
'target', perhaps this is ok for this problem domain, i.e.
monitoring/profiling/etc.

> that would turn it into:
>
> if (target__has_task(target))
> return event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
> else if (target__has_cpu(target))
> return event__synthesize_threads(tool, process, machine, data_mmap);
>
> Another trick would be to combine (tool, machine) into a single helper
> struct (struct context *ctx?), if that is mostly a constant combination
> describing tool environment, which gets passed deep inside the guts of
> functions.


Reducing the function signature is something that may help as well, and
was done in this series with machine__synthesize_threads, that avoids
passing the tool and process arguments, since they were constanty
anyway.

What you propose is used in some cases, like with symbol_conf, will try
to work in that direction as time goes by, i.e. doing some refactoring
work of this kind every once in a while, not to disrupt too much the
patch flow.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/