linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: David Ahern <daahern@cisco.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	acme@ghostprotocols.net, mingo@elte.hu, peterz@infradead.org,
	paulus@samba.org, tglx@linutronix.de
Subject: Re: [PATCH 1/3] perf script: change process_event prototype
Date: Thu, 3 Mar 2011 03:40:06 +0100	[thread overview]
Message-ID: <20110303024003.GC1946@nowhere> (raw)
In-Reply-To: <1299086960-26964-2-git-send-email-daahern@cisco.com>

On Wed, Mar 02, 2011 at 10:29:18AM -0700, David Ahern wrote:
> Prepare for handling of samples for any event type.
> 
> Signed-off-by: David Ahern <daahern@cisco.com>
> ---
>  tools/perf/builtin-script.c                        |   40 +++++++++++--------
>  .../util/scripting-engines/trace-event-python.c    |   20 ++++++++-

What about Perl?

>  tools/perf/util/trace-event-scripting.c            |    8 +--
>  tools/perf/util/trace-event.h                      |    6 ++-
>  4 files changed, 47 insertions(+), 27 deletions(-)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 5f40df6..0bee150 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -20,6 +20,27 @@ static u64			last_timestamp;
>  static u64			nr_unordered;
>  extern const struct option	record_options[];
>  
> +static void process_event(union perf_event *event,
> +			  struct perf_sample *sample,
> +			  struct perf_session *session)
> +{
> +	struct thread *thread = perf_session__findnew(session, event->ip.pid);
> +
> +	if (thread == NULL) {
> +		pr_debug("problem processing %d event, skipping it.\n",
> +			 event->header.type);
> +		return;
> +	}

Seems the thread is needed by any endpoints. It would be better to resolve
it from process_sample_event and pass it to the process_event() handler.

> +
> +	/*
> +	 * FIXME: better resolve from pid from the struct trace_entry
> +	 * field, although it should be the same than this perf
> +	 * event pid
> +	 */
> +	print_event(sample->cpu, sample->raw_data, sample->raw_size,
> +		    sample->time, thread->comm);
> +}
[...]
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 2040b85..5b03fb6 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -204,9 +204,9 @@ static inline struct event *find_cache_event(int type)
>  	return event;
>  }
>  
> -static void python_process_event(int cpu, void *data,
> -				 int size __unused,
> -				 unsigned long long nsecs, char *comm)
> +static void python_process_event(union perf_event *pevent,
> +				struct perf_sample *sample,
> +				struct perf_session *session)
>  {
>  	PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
>  	static char handler_name[256];
> @@ -218,6 +218,20 @@ static void python_process_event(int cpu, void *data,
>  	int type;
>  	int pid;

Please avoid such blank line in the middle of local vars declaration.

> +	int cpu = sample->cpu;
> +	void *data = sample->raw_data;
> +	unsigned long long nsecs = sample->time;
> +	char *comm;
> +	struct thread *thread;
> +
> +	thread = perf_session__findnew(session, pevent->ip.pid);
> +	if (thread == NULL) {
> +		pr_debug("problem processing %d event, skipping it.\n",
> +			 pevent->header.type);
> +		return;
> +	}
> +	comm = thread->comm;
> +

  reply	other threads:[~2011-03-03  2:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02 17:29 [PATCH 0/3] perf script: add support for S/W events and H/W based profiling David Ahern
2011-03-02 17:29 ` [PATCH 1/3] perf script: change process_event prototype David Ahern
2011-03-03  2:40   ` Frederic Weisbecker [this message]
2011-03-03 14:11     ` David Ahern
2011-03-03 17:07       ` Frederic Weisbecker
2011-03-02 17:29 ` [PATCH 2/3] perf script: prepare to handle more than tracepoint events David Ahern
2011-03-02 17:29 ` [PATCH 3/3] perf script: dump software events and samples from hardware-based profiling David Ahern
2011-03-03  3:05   ` Frederic Weisbecker
2011-03-03 14:20     ` David Ahern
2011-03-03 17:19       ` Frederic Weisbecker
2011-03-03 17:30         ` David Ahern
2011-03-03 18:06           ` Frederic Weisbecker

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=20110303024003.GC1946@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@ghostprotocols.net \
    --cc=daahern@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).