Skip to contentSkip to conversation

perf scripting cleanups

RFC In review Arnaldo Carvalho de Melo 5 participants 11 messages Apr 1, 2015 – Apr 3, 2015 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

cover perf scripting cleanups

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(-)
Signature · 1 line
1.9.3
author maintainer
#1 lore raw

PATCH 1/2 perf script: No need to lookup thread twice

From: Arnaldo Carvalho de Melo <[email protected]>

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

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-script.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
tools/perf/builtin-script.c +1 -9
index 662366ceb572..c286b49c81b2 100644
@@ -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;
 }
Signature · 1 line
1.9.3
#2 lore raw

[tip:perf/core] perf script: No need to lookup thread twice

perf script: No need to lookup thread twice
Commit-ID:  79628f2cfe0f488b23e5dc99a4a9a599032fa653
Gitweb:     http://git.kernel.org/tip/79628f2cfe0f488b23e5dc99a4a9a599032fa653
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 1 Apr 2015 13:26:45 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/builtin-script.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
tools/perf/builtin-script.c +1 -9
index 662366c..c286b49 100644
@@ -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;
 }
author maintainer
#3 lore raw

PATCH 2/2 perf scripting: No need to pass thread twice to the scripting callbacks

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

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

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 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(-)
tools/perf/builtin-script.c +3 -3
index c286b49c81b2..257dd066cb1a 100644
@@ -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;
 }
tools/perf/util/scripting-engines/trace-event-perl.c +2 -3
index 8171fed4136e..430b5d27828e 100644
@@ -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);
 }
 
tools/perf/util/scripting-engines/trace-event-python.c +5 -8
index 2ec5dfb5a456..de8df1d5e1bd 100644
@@ -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);
 	}
 }
 
tools/perf/util/trace-event-scripting.c +0 -1
index 5c9bdd1591a9..9df61059a85d 100644
@@ -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)
 {
 }
tools/perf/util/trace-event.h +1 -2
index 356629a30ca9..d5168f0be4ec 100644
@@ -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);
 };
 
Signature · 1 line
1.9.3
#4 lore raw

[tip:perf/core] perf scripting: No need to pass thread twice to the scripting callbacks

perf scripting: No need to pass thread twice to the scripting callbacks
Commit-ID:  f9d5d549d2c2934be84b0bc7e5e034834459f591
Gitweb:     http://git.kernel.org/tip/f9d5d549d2c2934be84b0bc7e5e034834459f591
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 1 Apr 2015 13:29:25 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/builtin-script.c +3 -3
index c286b49..257dd06 100644
@@ -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;
 }
tools/perf/util/scripting-engines/trace-event-perl.c +2 -3
index 8171fed..430b5d2 100644
@@ -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);
 }
 
tools/perf/util/scripting-engines/trace-event-python.c +5 -8
index 2ec5dfb..de8df1d 100644
@@ -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);
 	}
 }
 
tools/perf/util/trace-event-scripting.c +0 -1
index 5c9bdd1..9df6105 100644
@@ -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)
 {
 }
tools/perf/util/trace-event.h +1 -2
index 356629a..d5168f0 100644
@@ -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);
 };
 
maintainer Acked-by on the v1 series
#5 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 11 lines · Arnaldo Carvalho de Melo

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,

Thanks,
Namhyung

Acked-by
#6 lore raw
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Arnaldo Carvalho de Melo

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);
Quoted 7 lines
Quoted 3 lines

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,

looks ok for me too

jirka

reviewer
#7 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 10 lines · Arnaldo Carvalho de Melo

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.

Quoted 1 line

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

Nope

Quoted 15 lines

- 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(-)
author maintainer Acked-by Adrian Hunter
#8 lore raw

Em Thu, Apr 02, 2015 at 12:16:40PM +0300, Adrian Hunter escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 8 lines

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);
Quoted 8 lines
Quoted 2 lines

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.

Quoted 1 line

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

Quoted 1 line

From 765b042be1054ec7b5f76b3a004e0aff503e350f Mon Sep 17 00:00:00 2001

From: Arnaldo Carvalho de Melo <[email protected]>
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.

Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
Link lkml.kernel.org/r/[email protected]
---
 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(-)
tools/perf/util/db-export.c +2 -1
index c81dae399763..5499887edc46 100644
@@ -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,
tools/perf/util/db-export.h +1 -1
index adbd22d66798..b9faa1386cf4 100644
@@ -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);
 
tools/perf/util/scripting-engines/trace-event-python.c +1 -2
index de8df1d5e1bd..1d3cc1b01731 100644
@@ -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);
 	}
Signature · 1 line
1.8.3.1
tools/perf/util/db-export.c +0 -1
index 5499887edc46..bb39a3ffc70b 100644
@@ -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;
tools/perf/util/db-export.h +0 -1
index b9faa1386cf4..25e22fd76aca 100644
@@ -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;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index 1d3cc1b01731..5544b8cdd1ee 100644
@@ -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);
reviewer
#9 lore raw
Quoted 15 lines · Arnaldo Carvalho de Melo

Em Thu, Apr 02, 2015 at 12:16:40PM +0300, Adrian Hunter escreveu:

Quoted 14 lines · Arnaldo Carvalho de Melo
Quoted 10 lines

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.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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.

#10 lore raw

[tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample

In reply to Arnaldo Carvalho de Melo
perf db-export: No need to have ->thread twice in struct export_sample
Commit-ID:  b83e868d0a0350c107b98417b4dcc73834506f98
Gitweb:     http://git.kernel.org/tip/b83e868d0a0350c107b98417b4dcc73834506f98
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 2 Apr 2015 11:16:05 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/util/db-export.c +0 -1
index 5499887..bb39a3f 100644
@@ -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;
tools/perf/util/db-export.h +0 -1
index b9faa13..25e22fd 100644
@@ -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;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index 1d3cc1b..5544b8c 100644
@@ -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);