public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf script: pass more arguments to the python event handler
@ 2014-05-30 16:25 Sebastian Andrzej Siewior
  2014-06-03  3:07 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-05-30 16:25 UTC (permalink / raw)
  To: acme
  Cc: namhyung.kim, linux-kernel, tzanussi, jolsa, a.p.zijlstra, mingo,
	paulus, Sebastian Andrzej Siewior

This patch extends the current argument list in case of events by
- IP / addr of the event. Currently only the function name is passed.
- seconds and ns as the timestamp. Split into two value to stay close to
  what the trace handler passes.
- the pid of the proccess

I added a common_ prefix to stay close to the naming of the "trace"
handler. Currently I don't mind dropping it since "comm" isn't named
"common_comm". Any suggestions?

All items I added here are already exposed by the generic output i.e.
"perf script"

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 40a815a..591bd97 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -381,6 +381,8 @@ static void python_process_general_event(struct perf_sample *sample,
 {
 	PyObject *handler, *retval, *t, *dict;
 	static char handler_name[64];
+	unsigned long long nsecs = sample->time;
+	unsigned long s, ns;
 	unsigned n = 0;
 
 	/*
@@ -401,6 +403,9 @@ static void python_process_general_event(struct perf_sample *sample,
 	if (!handler || !PyCallable_Check(handler))
 		goto exit;
 
+	s = nsecs / NSECS_PER_SEC;
+	ns = nsecs - s * NSECS_PER_SEC;
+
 	pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
 	pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
 			(const char *)&evsel->attr, sizeof(evsel->attr)));
@@ -410,6 +415,12 @@ static void python_process_general_event(struct perf_sample *sample,
 			(const char *)sample->raw_data, sample->raw_size));
 	pydict_set_item_string_decref(dict, "comm",
 			PyString_FromString(thread__comm_str(thread)));
+	pydict_set_item_string_decref(dict, "addr",
+			PyLong_FromUnsignedLongLong(sample->ip));
+	pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s));
+	pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns));
+	pydict_set_item_string_decref(dict, "common_pid",
+			PyInt_FromLong(sample->pid));
 	if (al->map) {
 		pydict_set_item_string_decref(dict, "dso",
 			PyString_FromString(al->map->dso->name));
-- 
2.0.0.rc4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf script: pass more arguments to the python event handler
  2014-05-30 16:25 [PATCH] perf script: pass more arguments to the python event handler Sebastian Andrzej Siewior
@ 2014-06-03  3:07 ` Namhyung Kim
  2014-06-03  7:19   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2014-06-03  3:07 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: acme, namhyung.kim, linux-kernel, tzanussi, jolsa, a.p.zijlstra,
	mingo, paulus

Hi Sebastian,

On Fri, 30 May 2014 18:25:23 +0200, Sebastian Andrzej Siewior wrote:
> This patch extends the current argument list in case of events by
> - IP / addr of the event. Currently only the function name is passed.
> - seconds and ns as the timestamp. Split into two value to stay close to
>   what the trace handler passes.
> - the pid of the proccess
>
> I added a common_ prefix to stay close to the naming of the "trace"
> handler. Currently I don't mind dropping it since "comm" isn't named
> "common_comm". Any suggestions?

Please take a look at Joseph's work on the same direction (and more).

https://lkml.org/lkml/2014/4/3/217

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf script: pass more arguments to the python event handler
  2014-06-03  3:07 ` Namhyung Kim
@ 2014-06-03  7:19   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-06-03  7:19 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: acme, namhyung.kim, linux-kernel, tzanussi, jolsa, a.p.zijlstra,
	mingo, paulus

On 06/03/2014 05:07 AM, Namhyung Kim wrote:
> Hi Sebastian,
Hi Namhyung,

> Please take a look at Joseph's work on the same direction (and more).
> 
> https://lkml.org/lkml/2014/4/3/217

This looks very good, thanks for pointing out.

> 
> Thanks,
> Namhyung
> 
Sebastian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-03  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30 16:25 [PATCH] perf script: pass more arguments to the python event handler Sebastian Andrzej Siewior
2014-06-03  3:07 ` Namhyung Kim
2014-06-03  7:19   ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox