LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC 0/2] perf scripting cleanups
@ 2015-04-01 16:36 Arnaldo Carvalho de Melo
  2015-04-01 16:36 ` [PATCH 1/2] perf script: No need to lookup thread twice Arnaldo Carvalho de Melo
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-04-01 16:36 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
	Adrian Hunter, Borislav Petkov, Don Zickus, Frederic Weisbecker,
	Namhyung Kim, Stephane Eranian

Hi David, Jiri,

	Please take a look if it is ok for you guys

Adrian, there is another thing:

  db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);

In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
as well, see the (al->thread, al), I'll probably remove that extra thread parm
there if you don't have any other subtle use for that...

- Arnaldo

Arnaldo Carvalho de Melo (2):
  perf script: No need to lookup thread twice
  perf scripting: No need to pass thread twice to the scripting
    callbacks

 tools/perf/builtin-script.c                            | 14 +++-----------
 tools/perf/util/scripting-engines/trace-event-perl.c   |  5 ++---
 tools/perf/util/scripting-engines/trace-event-python.c | 13 +++++--------
 tools/perf/util/trace-event-scripting.c                |  1 -
 tools/perf/util/trace-event.h                          |  3 +--
 5 files changed, 11 insertions(+), 25 deletions(-)

-- 
1.9.3


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

* [PATCH 1/2] perf script: No need to lookup thread twice
  2015-04-01 16:36 [RFC 0/2] perf scripting cleanups Arnaldo Carvalho de Melo
@ 2015-04-01 16:36 ` Arnaldo Carvalho de Melo
  2015-04-03  5:06   ` [tip:perf/core] " tip-bot for Arnaldo Carvalho de Melo
  2015-04-01 16:36 ` [PATCH 2/2] perf scripting: No need to pass thread twice to the scripting callbacks Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-04-01 16:36 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Don Zickus, Frederic Weisbecker,
	Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We get the thread when we call perf_event__preprocess_sample(), no need
to do it before that.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ksvs38n1d5vf9hfnhzj75xrm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 662366ceb572..c286b49c81b2 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -549,14 +549,6 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 				struct machine *machine)
 {
 	struct addr_location al;
-	struct thread *thread = machine__findnew_thread(machine, sample->pid,
-							sample->tid);
-
-	if (thread == NULL) {
-		pr_debug("problem processing %d event, skipping it.\n",
-			 event->header.type);
-		return -1;
-	}
 
 	if (debug_mode) {
 		if (sample->time < last_timestamp) {
@@ -581,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 	if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
 		return 0;
 
-	scripting_ops->process_event(event, sample, evsel, thread, &al);
+	scripting_ops->process_event(event, sample, evsel, al.thread, &al);
 
 	return 0;
 }
-- 
1.9.3


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

* [PATCH 2/2] perf scripting: No need to pass thread twice to the scripting callbacks
  2015-04-01 16:36 [RFC 0/2] perf scripting cleanups Arnaldo Carvalho de Melo
  2015-04-01 16:36 ` [PATCH 1/2] perf script: No need to lookup thread twice Arnaldo Carvalho de Melo
@ 2015-04-01 16:36 ` Arnaldo Carvalho de Melo
  2015-04-03  5:06   ` [tip:perf/core] " tip-bot for Arnaldo Carvalho de Melo
  2015-04-02  8:16 ` [RFC 0/2] perf scripting cleanups Namhyung Kim
  2015-04-02  9:16 ` Adrian Hunter
  3 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-04-01 16:36 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Don Zickus, Frederic Weisbecker,
	Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

It is already in the addr_location, so remove the redundant 'thread'
parameter from the callback signatures.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-fuj5cj0uxc5a8j9xr2mqfwav@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c                            |  6 +++---
 tools/perf/util/scripting-engines/trace-event-perl.c   |  5 ++---
 tools/perf/util/scripting-engines/trace-event-python.c | 13 +++++--------
 tools/perf/util/trace-event-scripting.c                |  1 -
 tools/perf/util/trace-event.h                          |  3 +--
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c286b49c81b2..257dd066cb1a 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -446,9 +446,9 @@ static void print_sample_bts(union perf_event *event,
 }
 
 static void process_event(union perf_event *event, struct perf_sample *sample,
-			  struct perf_evsel *evsel, struct thread *thread,
-			  struct addr_location *al)
+			  struct perf_evsel *evsel, struct addr_location *al)
 {
+	struct thread *thread = al->thread;
 	struct perf_event_attr *attr = &evsel->attr;
 
 	if (output[attr->type].fields == 0)
@@ -573,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 	if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
 		return 0;
 
-	scripting_ops->process_event(event, sample, evsel, al.thread, &al);
+	scripting_ops->process_event(event, sample, evsel, &al);
 
 	return 0;
 }
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 8171fed4136e..430b5d27828e 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -360,10 +360,9 @@ static void perl_process_event_generic(union perf_event *event,
 static void perl_process_event(union perf_event *event,
 			       struct perf_sample *sample,
 			       struct perf_evsel *evsel,
-			       struct thread *thread,
-			       struct addr_location *al __maybe_unused)
+			       struct addr_location *al)
 {
-	perl_process_tracepoint(sample, evsel, thread);
+	perl_process_tracepoint(sample, evsel, al->thread);
 	perl_process_event_generic(event, sample, evsel);
 }
 
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 2ec5dfb5a456..de8df1d5e1bd 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -381,7 +381,6 @@ exit:
 
 static void python_process_tracepoint(struct perf_sample *sample,
 				      struct perf_evsel *evsel,
-				      struct thread *thread,
 				      struct addr_location *al)
 {
 	struct event_format *event = evsel->tp_format;
@@ -395,7 +394,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
 	int cpu = sample->cpu;
 	void *data = sample->raw_data;
 	unsigned long long nsecs = sample->time;
-	const char *comm = thread__comm_str(thread);
+	const char *comm = thread__comm_str(al->thread);
 
 	t = PyTuple_New(MAX_FIELDS);
 	if (!t)
@@ -766,7 +765,6 @@ static int python_process_call_return(struct call_return *cr, void *data)
 
 static void python_process_general_event(struct perf_sample *sample,
 					 struct perf_evsel *evsel,
-					 struct thread *thread,
 					 struct addr_location *al)
 {
 	PyObject *handler, *t, *dict, *callchain, *dict_sample;
@@ -816,7 +814,7 @@ static void python_process_general_event(struct perf_sample *sample,
 	pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
 			(const char *)sample->raw_data, sample->raw_size));
 	pydict_set_item_string_decref(dict, "comm",
-			PyString_FromString(thread__comm_str(thread)));
+			PyString_FromString(thread__comm_str(al->thread)));
 	if (al->map) {
 		pydict_set_item_string_decref(dict, "dso",
 			PyString_FromString(al->map->dso->name));
@@ -843,22 +841,21 @@ exit:
 static void python_process_event(union perf_event *event,
 				 struct perf_sample *sample,
 				 struct perf_evsel *evsel,
-				 struct thread *thread,
 				 struct addr_location *al)
 {
 	struct tables *tables = &tables_global;
 
 	switch (evsel->attr.type) {
 	case PERF_TYPE_TRACEPOINT:
-		python_process_tracepoint(sample, evsel, thread, al);
+		python_process_tracepoint(sample, evsel, al);
 		break;
 	/* Reserve for future process_hw/sw/raw APIs */
 	default:
 		if (tables->db_export_mode)
 			db_export__sample(&tables->dbe, event, sample, evsel,
-					  thread, al);
+					  al->thread, al);
 		else
-			python_process_general_event(sample, evsel, thread, al);
+			python_process_general_event(sample, evsel, al);
 	}
 }
 
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 5c9bdd1591a9..9df61059a85d 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -43,7 +43,6 @@ static int stop_script_unsupported(void)
 static void process_event_unsupported(union perf_event *event __maybe_unused,
 				      struct perf_sample *sample __maybe_unused,
 				      struct perf_evsel *evsel __maybe_unused,
-				      struct thread *thread __maybe_unused,
 				      struct addr_location *al __maybe_unused)
 {
 }
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 356629a30ca9..d5168f0be4ec 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -72,8 +72,7 @@ struct scripting_ops {
 	void (*process_event) (union perf_event *event,
 			       struct perf_sample *sample,
 			       struct perf_evsel *evsel,
-			       struct thread *thread,
-				   struct addr_location *al);
+			       struct addr_location *al);
 	int (*generate_script) (struct pevent *pevent, const char *outfile);
 };
 
-- 
1.9.3


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

* Re: [RFC 0/2] perf scripting cleanups
  2015-04-01 16:36 [RFC 0/2] perf scripting cleanups Arnaldo Carvalho de Melo
  2015-04-01 16:36 ` [PATCH 1/2] perf script: No need to lookup thread twice Arnaldo Carvalho de Melo
  2015-04-01 16:36 ` [PATCH 2/2] perf scripting: No need to pass thread twice to the scripting callbacks Arnaldo Carvalho de Melo
@ 2015-04-02  8:16 ` Namhyung Kim
  2015-04-02  8:35   ` Jiri Olsa
  2015-04-02  9:16 ` Adrian Hunter
  3 siblings, 1 reply; 11+ messages in thread
From: Namhyung Kim @ 2015-04-02  8:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, David Ahern, Adrian Hunter,
	Borislav Petkov, Don Zickus, Frederic Weisbecker,
	Stephane Eranian

On Wed, Apr 01, 2015 at 01:36:48PM -0300, Arnaldo Carvalho de Melo wrote:
> Hi David, Jiri,
> 
> 	Please take a look if it is ok for you guys
> 
> Adrian, there is another thing:
> 
>   db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);
> 
> In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
> as well, see the (al->thread, al), I'll probably remove that extra thread parm
> there if you don't have any other subtle use for that...

For both patches,

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

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

* Re: [RFC 0/2] perf scripting cleanups
  2015-04-02  8:16 ` [RFC 0/2] perf scripting cleanups Namhyung Kim
@ 2015-04-02  8:35   ` Jiri Olsa
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Olsa @ 2015-04-02  8:35 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, linux-kernel, David Ahern,
	Adrian Hunter, Borislav Petkov, Don Zickus, Frederic Weisbecker,
	Stephane Eranian

On Thu, Apr 02, 2015 at 05:16:09PM +0900, Namhyung Kim wrote:
> On Wed, Apr 01, 2015 at 01:36:48PM -0300, Arnaldo Carvalho de Melo wrote:
> > Hi David, Jiri,
> > 
> > 	Please take a look if it is ok for you guys
> > 
> > Adrian, there is another thing:
> > 
> >   db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);
> > 
> > In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
> > as well, see the (al->thread, al), I'll probably remove that extra thread parm
> > there if you don't have any other subtle use for that...
> 
> For both patches,
> 
> Acked-by: Namhyung Kim <namhyung@kernel.org>

looks ok for me too

Acked-by: Jiri Olsa <jolsa@kernel.org>


jirka

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

* Re: [RFC 0/2] perf scripting cleanups
  2015-04-01 16:36 [RFC 0/2] perf scripting cleanups Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2015-04-02  8:16 ` [RFC 0/2] perf scripting cleanups Namhyung Kim
@ 2015-04-02  9:16 ` Adrian Hunter
  2015-04-02 14:15   ` Arnaldo Carvalho de Melo
  3 siblings, 1 reply; 11+ messages in thread
From: Adrian Hunter @ 2015-04-02  9:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: linux-kernel, David Ahern, Borislav Petkov, Don Zickus,
	Frederic Weisbecker, Namhyung Kim, Stephane Eranian

On 01/04/15 19:36, Arnaldo Carvalho de Melo wrote:
> Hi David, Jiri,
> 
> 	Please take a look if it is ok for you guys
> 
> Adrian, there is another thing:
> 
>   db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);
> 
> In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
> as well, see the (al->thread, al), I'll probably remove that extra thread parm

Yes please remove it too.

> there if you don't have any other subtle use for that...

Nope

> 
> - Arnaldo
> 
> Arnaldo Carvalho de Melo (2):
>   perf script: No need to lookup thread twice
>   perf scripting: No need to pass thread twice to the scripting
>     callbacks
> 
>  tools/perf/builtin-script.c                            | 14 +++-----------
>  tools/perf/util/scripting-engines/trace-event-perl.c   |  5 ++---
>  tools/perf/util/scripting-engines/trace-event-python.c | 13 +++++--------
>  tools/perf/util/trace-event-scripting.c                |  1 -
>  tools/perf/util/trace-event.h                          |  3 +--
>  5 files changed, 11 insertions(+), 25 deletions(-)
> 


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

* Re: [RFC 0/2] perf scripting cleanups
  2015-04-02  9:16 ` Adrian Hunter
@ 2015-04-02 14:15   ` Arnaldo Carvalho de Melo
  2015-04-02 20:42     ` Adrian Hunter
  2015-04-03  5:07     ` [tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample tip-bot for Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-04-02 14:15 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Jiri Olsa, linux-kernel, David Ahern, Borislav Petkov,
	Don Zickus, Frederic Weisbecker, Namhyung Kim, Stephane Eranian

Em Thu, Apr 02, 2015 at 12:16:40PM +0300, Adrian Hunter escreveu:
> On 01/04/15 19:36, Arnaldo Carvalho de Melo wrote:
> > Hi David, Jiri,
> > 
> > 	Please take a look if it is ok for you guys
> > 
> > Adrian, there is another thing:
> > 
> >   db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);
> > 
> > In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
> > as well, see the (al->thread, al), I'll probably remove that extra thread parm
> 
> Yes please remove it too.
> 
> > there if you don't have any other subtle use for that...
> 
> Nope

Ok, adding it as below, with your Acked-by, there is the one at the
bottom too, i.s. struct export_sample doesn't need a ->thread field,
same reason, if you are ok with that too, will add your Acked-by.

- Arnaldo

>From 765b042be1054ec7b5f76b3a004e0aff503e350f Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Thu, 2 Apr 2015 11:08:30 -0300
Subject: [PATCH 1/1] perf db-export: No need to pass thread twice to
 db_export__sample

As it is available via another parameter, address_location->thread.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: lkml.kernel.org/r/551D08F8.3040706@intel.com
Link: http://lkml.kernel.org/n/tip-6dbn0tcm9hyv92g7h3zj2dbt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/db-export.c                            | 3 ++-
 tools/perf/util/db-export.h                            | 2 +-
 tools/perf/util/scripting-engines/trace-event-python.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index c81dae399763..5499887edc46 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -282,8 +282,9 @@ int db_export__branch_type(struct db_export *dbe, u32 branch_type,
 
 int db_export__sample(struct db_export *dbe, union perf_event *event,
 		      struct perf_sample *sample, struct perf_evsel *evsel,
-		      struct thread *thread, struct addr_location *al)
+		      struct addr_location *al)
 {
+	struct thread* thread = al->thread;
 	struct export_sample es = {
 		.event = event,
 		.sample = sample,
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index adbd22d66798..b9faa1386cf4 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -97,7 +97,7 @@ int db_export__branch_type(struct db_export *dbe, u32 branch_type,
 			   const char *name);
 int db_export__sample(struct db_export *dbe, union perf_event *event,
 		      struct perf_sample *sample, struct perf_evsel *evsel,
-		      struct thread *thread, struct addr_location *al);
+		      struct addr_location *al);
 
 int db_export__branch_types(struct db_export *dbe);
 
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index de8df1d5e1bd..1d3cc1b01731 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -852,8 +852,7 @@ static void python_process_event(union perf_event *event,
 	/* Reserve for future process_hw/sw/raw APIs */
 	default:
 		if (tables->db_export_mode)
-			db_export__sample(&tables->dbe, event, sample, evsel,
-					  al->thread, al);
+			db_export__sample(&tables->dbe, event, sample, evsel, al);
 		else
 			python_process_general_event(sample, evsel, al);
 	}
-- 
1.8.3.1

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 5499887edc46..bb39a3ffc70b 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -289,7 +289,6 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 		.event = event,
 		.sample = sample,
 		.evsel = evsel,
-		.thread = thread,
 		.al = al,
 	};
 	struct thread *main_thread;
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index b9faa1386cf4..25e22fd76aca 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -34,7 +34,6 @@ struct export_sample {
 	union perf_event	*event;
 	struct perf_sample	*sample;
 	struct perf_evsel	*evsel;
-	struct thread		*thread;
 	struct addr_location	*al;
 	u64			db_id;
 	u64			comm_db_id;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 1d3cc1b01731..5544b8cdd1ee 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -679,7 +679,7 @@ static int python_export_sample(struct db_export *dbe,
 	tuple_set_u64(t, 0, es->db_id);
 	tuple_set_u64(t, 1, es->evsel->db_id);
 	tuple_set_u64(t, 2, es->al->machine->db_id);
-	tuple_set_u64(t, 3, es->thread->db_id);
+	tuple_set_u64(t, 3, es->al->thread->db_id);
 	tuple_set_u64(t, 4, es->comm_db_id);
 	tuple_set_u64(t, 5, es->dso_db_id);
 	tuple_set_u64(t, 6, es->sym_db_id);

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

* Re: [RFC 0/2] perf scripting cleanups
  2015-04-02 14:15   ` Arnaldo Carvalho de Melo
@ 2015-04-02 20:42     ` Adrian Hunter
  2015-04-03  5:07     ` [tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 11+ messages in thread
From: Adrian Hunter @ 2015-04-02 20:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, David Ahern, Borislav Petkov,
	Don Zickus, Frederic Weisbecker, Namhyung Kim, Stephane Eranian

On 2/04/2015 5:15 p.m., Arnaldo Carvalho de Melo wrote:
> Em Thu, Apr 02, 2015 at 12:16:40PM +0300, Adrian Hunter escreveu:
>> On 01/04/15 19:36, Arnaldo Carvalho de Melo wrote:
>>> Hi David, Jiri,
>>>
>>> 	Please take a look if it is ok for you guys
>>>
>>> Adrian, there is another thing:
>>>
>>>    db_export__sample(&tables->dbe, event, sample, evsel, al->thread, al);
>>>
>>> In tools/perf/util/scripting-engines/trace-event-python.c has this redundancy
>>> as well, see the (al->thread, al), I'll probably remove that extra thread parm
>>
>> Yes please remove it too.
>>
>>> there if you don't have any other subtle use for that...
>>
>> Nope
>
> Ok, adding it as below, with your Acked-by, there is the one at the
> bottom too, i.s. struct export_sample doesn't need a ->thread field,
> same reason, if you are ok with that too, will add your Acked-by.

Yes that also looks fine.


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

* [tip:perf/core] perf script: No need to lookup thread twice
  2015-04-01 16:36 ` [PATCH 1/2] perf script: No need to lookup thread twice Arnaldo Carvalho de Melo
@ 2015-04-03  5:06   ` tip-bot for Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2015-04-03  5:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, adrian.hunter, eranian, acme, linux-kernel, bp, mingo,
	fweisbec, tglx, dsahern, dzickus, namhyung, hpa

Commit-ID:  79628f2cfe0f488b23e5dc99a4a9a599032fa653
Gitweb:     http://git.kernel.org/tip/79628f2cfe0f488b23e5dc99a4a9a599032fa653
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Wed, 1 Apr 2015 13:26:45 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 2 Apr 2015 13:18:21 -0300

perf script: No need to lookup thread twice

We get the thread when we call perf_event__preprocess_sample(), no need
to do it before that.

Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427906210-10519-2-git-send-email-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 662366c..c286b49 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -549,14 +549,6 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 				struct machine *machine)
 {
 	struct addr_location al;
-	struct thread *thread = machine__findnew_thread(machine, sample->pid,
-							sample->tid);
-
-	if (thread == NULL) {
-		pr_debug("problem processing %d event, skipping it.\n",
-			 event->header.type);
-		return -1;
-	}
 
 	if (debug_mode) {
 		if (sample->time < last_timestamp) {
@@ -581,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 	if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
 		return 0;
 
-	scripting_ops->process_event(event, sample, evsel, thread, &al);
+	scripting_ops->process_event(event, sample, evsel, al.thread, &al);
 
 	return 0;
 }

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

* [tip:perf/core] perf scripting: No need to pass thread twice to the scripting callbacks
  2015-04-01 16:36 ` [PATCH 2/2] perf scripting: No need to pass thread twice to the scripting callbacks Arnaldo Carvalho de Melo
@ 2015-04-03  5:06   ` tip-bot for Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2015-04-03  5:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, eranian, fweisbec, namhyung, bp, adrian.hunter, jolsa,
	dzickus, linux-kernel, hpa, acme, dsahern, tglx

Commit-ID:  f9d5d549d2c2934be84b0bc7e5e034834459f591
Gitweb:     http://git.kernel.org/tip/f9d5d549d2c2934be84b0bc7e5e034834459f591
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Wed, 1 Apr 2015 13:29:25 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 2 Apr 2015 13:18:41 -0300

perf scripting: No need to pass thread twice to the scripting callbacks

It is already in the addr_location, so remove the redundant 'thread'
parameter from the callback signatures.

Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427906210-10519-3-git-send-email-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c                            |  6 +++---
 tools/perf/util/scripting-engines/trace-event-perl.c   |  5 ++---
 tools/perf/util/scripting-engines/trace-event-python.c | 13 +++++--------
 tools/perf/util/trace-event-scripting.c                |  1 -
 tools/perf/util/trace-event.h                          |  3 +--
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c286b49..257dd06 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -446,9 +446,9 @@ static void print_sample_bts(union perf_event *event,
 }
 
 static void process_event(union perf_event *event, struct perf_sample *sample,
-			  struct perf_evsel *evsel, struct thread *thread,
-			  struct addr_location *al)
+			  struct perf_evsel *evsel, struct addr_location *al)
 {
+	struct thread *thread = al->thread;
 	struct perf_event_attr *attr = &evsel->attr;
 
 	if (output[attr->type].fields == 0)
@@ -573,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 	if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
 		return 0;
 
-	scripting_ops->process_event(event, sample, evsel, al.thread, &al);
+	scripting_ops->process_event(event, sample, evsel, &al);
 
 	return 0;
 }
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 8171fed..430b5d2 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -360,10 +360,9 @@ static void perl_process_event_generic(union perf_event *event,
 static void perl_process_event(union perf_event *event,
 			       struct perf_sample *sample,
 			       struct perf_evsel *evsel,
-			       struct thread *thread,
-			       struct addr_location *al __maybe_unused)
+			       struct addr_location *al)
 {
-	perl_process_tracepoint(sample, evsel, thread);
+	perl_process_tracepoint(sample, evsel, al->thread);
 	perl_process_event_generic(event, sample, evsel);
 }
 
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 2ec5dfb..de8df1d 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -381,7 +381,6 @@ exit:
 
 static void python_process_tracepoint(struct perf_sample *sample,
 				      struct perf_evsel *evsel,
-				      struct thread *thread,
 				      struct addr_location *al)
 {
 	struct event_format *event = evsel->tp_format;
@@ -395,7 +394,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
 	int cpu = sample->cpu;
 	void *data = sample->raw_data;
 	unsigned long long nsecs = sample->time;
-	const char *comm = thread__comm_str(thread);
+	const char *comm = thread__comm_str(al->thread);
 
 	t = PyTuple_New(MAX_FIELDS);
 	if (!t)
@@ -766,7 +765,6 @@ static int python_process_call_return(struct call_return *cr, void *data)
 
 static void python_process_general_event(struct perf_sample *sample,
 					 struct perf_evsel *evsel,
-					 struct thread *thread,
 					 struct addr_location *al)
 {
 	PyObject *handler, *t, *dict, *callchain, *dict_sample;
@@ -816,7 +814,7 @@ static void python_process_general_event(struct perf_sample *sample,
 	pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
 			(const char *)sample->raw_data, sample->raw_size));
 	pydict_set_item_string_decref(dict, "comm",
-			PyString_FromString(thread__comm_str(thread)));
+			PyString_FromString(thread__comm_str(al->thread)));
 	if (al->map) {
 		pydict_set_item_string_decref(dict, "dso",
 			PyString_FromString(al->map->dso->name));
@@ -843,22 +841,21 @@ exit:
 static void python_process_event(union perf_event *event,
 				 struct perf_sample *sample,
 				 struct perf_evsel *evsel,
-				 struct thread *thread,
 				 struct addr_location *al)
 {
 	struct tables *tables = &tables_global;
 
 	switch (evsel->attr.type) {
 	case PERF_TYPE_TRACEPOINT:
-		python_process_tracepoint(sample, evsel, thread, al);
+		python_process_tracepoint(sample, evsel, al);
 		break;
 	/* Reserve for future process_hw/sw/raw APIs */
 	default:
 		if (tables->db_export_mode)
 			db_export__sample(&tables->dbe, event, sample, evsel,
-					  thread, al);
+					  al->thread, al);
 		else
-			python_process_general_event(sample, evsel, thread, al);
+			python_process_general_event(sample, evsel, al);
 	}
 }
 
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 5c9bdd1..9df6105 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -43,7 +43,6 @@ static int stop_script_unsupported(void)
 static void process_event_unsupported(union perf_event *event __maybe_unused,
 				      struct perf_sample *sample __maybe_unused,
 				      struct perf_evsel *evsel __maybe_unused,
-				      struct thread *thread __maybe_unused,
 				      struct addr_location *al __maybe_unused)
 {
 }
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 356629a..d5168f0 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -72,8 +72,7 @@ struct scripting_ops {
 	void (*process_event) (union perf_event *event,
 			       struct perf_sample *sample,
 			       struct perf_evsel *evsel,
-			       struct thread *thread,
-				   struct addr_location *al);
+			       struct addr_location *al);
 	int (*generate_script) (struct pevent *pevent, const char *outfile);
 };
 

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

* [tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample
  2015-04-02 14:15   ` Arnaldo Carvalho de Melo
  2015-04-02 20:42     ` Adrian Hunter
@ 2015-04-03  5:07     ` tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 11+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2015-04-03  5:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: adrian.hunter, jolsa, dzickus, fweisbec, tglx, linux-kernel,
	namhyung, mingo, hpa, eranian, bp, acme, dsahern

Commit-ID:  b83e868d0a0350c107b98417b4dcc73834506f98
Gitweb:     http://git.kernel.org/tip/b83e868d0a0350c107b98417b4dcc73834506f98
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 2 Apr 2015 11:16:05 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 2 Apr 2015 13:18:43 -0300

perf db-export: No need to have ->thread twice in struct export_sample

As it comes from address_location->thread, that is already stored as
export_sample->al, where the thread can be obtained.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20150402141542.GA9630@kernel.org
Link: http://lkml.kernel.org/n/tip-bzotbl4epoztw0jd6sm2stpf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/db-export.c                            | 1 -
 tools/perf/util/db-export.h                            | 1 -
 tools/perf/util/scripting-engines/trace-event-python.c | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 5499887..bb39a3f 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -289,7 +289,6 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 		.event = event,
 		.sample = sample,
 		.evsel = evsel,
-		.thread = thread,
 		.al = al,
 	};
 	struct thread *main_thread;
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index b9faa13..25e22fd 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -34,7 +34,6 @@ struct export_sample {
 	union perf_event	*event;
 	struct perf_sample	*sample;
 	struct perf_evsel	*evsel;
-	struct thread		*thread;
 	struct addr_location	*al;
 	u64			db_id;
 	u64			comm_db_id;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 1d3cc1b..5544b8c 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -679,7 +679,7 @@ static int python_export_sample(struct db_export *dbe,
 	tuple_set_u64(t, 0, es->db_id);
 	tuple_set_u64(t, 1, es->evsel->db_id);
 	tuple_set_u64(t, 2, es->al->machine->db_id);
-	tuple_set_u64(t, 3, es->thread->db_id);
+	tuple_set_u64(t, 3, es->al->thread->db_id);
 	tuple_set_u64(t, 4, es->comm_db_id);
 	tuple_set_u64(t, 5, es->dso_db_id);
 	tuple_set_u64(t, 6, es->sym_db_id);

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

end of thread, other threads:[~2015-04-03  5:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 16:36 [RFC 0/2] perf scripting cleanups Arnaldo Carvalho de Melo
2015-04-01 16:36 ` [PATCH 1/2] perf script: No need to lookup thread twice Arnaldo Carvalho de Melo
2015-04-03  5:06   ` [tip:perf/core] " tip-bot for Arnaldo Carvalho de Melo
2015-04-01 16:36 ` [PATCH 2/2] perf scripting: No need to pass thread twice to the scripting callbacks Arnaldo Carvalho de Melo
2015-04-03  5:06   ` [tip:perf/core] " tip-bot for Arnaldo Carvalho de Melo
2015-04-02  8:16 ` [RFC 0/2] perf scripting cleanups Namhyung Kim
2015-04-02  8:35   ` Jiri Olsa
2015-04-02  9:16 ` Adrian Hunter
2015-04-02 14:15   ` Arnaldo Carvalho de Melo
2015-04-02 20:42     ` Adrian Hunter
2015-04-03  5:07     ` [tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample tip-bot for Arnaldo Carvalho de Melo

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).