All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>,
	linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 04/10] perf machine: Introduce synthesize_threads method out of open coded equivalent
Date: Tue, 12 Nov 2013 08:34:27 -0300	[thread overview]
Message-ID: <20131112113427.GA4053@ghostprotocols.net> (raw)
In-Reply-To: <20131111205045.GE18886@gmail.com>

Em Mon, Nov 11, 2013 at 09:50:45PM +0100, Ingo Molnar escreveu:
> * David Ahern <dsahern@gmail.com> 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

  reply	other threads:[~2013-11-12 11:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11 20:22 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 01/10] perf ui tui progress: Don't force a refresh during progress update Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 02/10] perf evsel: Remove idx parm from constructor Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 03/10] perf record: Synthesize non-exec MMAP records when --data used Arnaldo Carvalho de Melo
2013-11-11 20:38   ` David Ahern
2013-11-11 21:02     ` Vince Weaver
2013-11-11 20:22 ` [PATCH 04/10] perf machine: Introduce synthesize_threads method out of open coded equivalent Arnaldo Carvalho de Melo
2013-11-11 20:40   ` David Ahern
2013-11-11 20:50     ` Ingo Molnar
2013-11-12 11:34       ` Arnaldo Carvalho de Melo [this message]
2013-11-12 12:44         ` Ingo Molnar
2013-11-12 21:57         ` [tip:perf/urgent] perf target: Shorten perf_target__ to target__ tip-bot for Arnaldo Carvalho de Melo
2014-01-12 18:33         ` [tip:perf/core] perf tools: Rename 'perf_record_opts' to ' record_opts tip-bot for Arnaldo Carvalho de Melo
2014-01-12 18:35         ` [tip:perf/core] perf report: Rename 'perf_report' to 'report' tip-bot for Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 05/10] perf machine: Simplify synthesize_threads method Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 06/10] perf tools: Prevent condition that all sort keys are elided Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 07/10] perf record: Use correct return type for write() Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 08/10] perf record: Move existing write_output into helper function Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 09/10] perf tests: Check return of perf_evlist__open sw clock event period test Arnaldo Carvalho de Melo
2013-11-11 20:22 ` [PATCH 10/10] perf tests: Use lower sample_freq in " Arnaldo Carvalho de Melo
2013-11-11 20:45   ` David Ahern
2013-11-12  7:07   ` Adrian Hunter
2013-11-12  8:40     ` Namhyung Kim
2013-11-12 11:59       ` Arnaldo Carvalho de Melo
2013-11-12 14:41     ` Arnaldo Carvalho de Melo
2013-11-15  6:03       ` Namhyung Kim
2013-11-12 21:56     ` [tip:perf/urgent] perf tests: Compensate lower sample freq with longer test loop tip-bot for Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131112113427.GA4053@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.