[PATCH v5 2/5] perf script: Replace "struct thread" with "struct addr_location" as a parameter for "process_event()"
Both perl and python script start processing events other than trace points, and it's useful to pass the resolved symbol and the dso info to the event handler in script for better analysis and statistics. Struct thread is already a member of struct addr_location, using addr_location will keep the thread info, while providing additional symbol and dso info if exist, so that the script itself doesn't need to bother to do the symbol resolving and dso searching work. Signed-off-by: Feng Tang Acked-by: David Ahern Tested-by: David Ahern Cc: David Ahern Cc: Peter Zijlstra Cc: Robert Richter Cc: Andi Kleen Cc: Stephane Eranian Link: http://lkml.kernel.org/r/133839-14007-3-git-send-email-feng.t...@intel.com> Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c|5 +++-- .../perf/util/scripting-engines/trace-event-perl.c | 11 ++- .../util/scripting-engines/trace-event-python.c| 13 +++-- tools/perf/util/trace-event-scripting.c|2 +- tools/perf/util/trace-event.h |5 +++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6425612..30a9cb8 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -396,9 +396,10 @@ 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 machine *machine, - struct thread *thread) + struct addr_location *al) { struct perf_event_attr *attr = >attr; + struct thread *thread = al->thread; if (output[attr->type].fields == 0) return; @@ -511,7 +512,7 @@ static int process_sample_event(struct perf_tool *tool __used, if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) return 0; - scripting_ops->process_event(event, sample, evsel, machine, thread); + scripting_ops->process_event(event, sample, evsel, machine, ); evsel->hists.stats.total_period += sample->period; 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 20cefeb..1cde6aa 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -261,7 +261,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __unused, - struct thread *thread) + struct addr_location *al) { struct format_field *field; static char handler[256]; @@ -272,6 +272,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, int cpu = sample->cpu; void *data = sample->raw_data; unsigned long long nsecs = sample->time; + struct thread *thread = al->thread; char *comm = thread->comm; dSP; @@ -349,7 +350,7 @@ static void perl_process_event_generic(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __unused, - struct thread *thread __unused) + struct addr_location *al __unused) { dSP; @@ -375,10 +376,10 @@ static void perl_process_event(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine, - struct thread *thread) + struct addr_location *al) { - perl_process_tracepoint(event, sample, evsel, machine, thread); - perl_process_event_generic(event, sample, evsel, machine, thread); + perl_process_tracepoint(event, sample, evsel, machine, al); + perl_process_event_generic(event, sample, evsel, machine, al); } static void run_start_sub(void) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index b9010d8..24711b3 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -225,7 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event __unused, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __unused, -
[PATCH v5 2/5] perf script: Replace struct thread with struct addr_location as a parameter for process_event()
Both perl and python script start processing events other than trace points, and it's useful to pass the resolved symbol and the dso info to the event handler in script for better analysis and statistics. Struct thread is already a member of struct addr_location, using addr_location will keep the thread info, while providing additional symbol and dso info if exist, so that the script itself doesn't need to bother to do the symbol resolving and dso searching work. Signed-off-by: Feng Tang feng.t...@intel.com Acked-by: David Ahern dsah...@gmail.com Tested-by: David Ahern dsah...@gmail.com Cc: David Ahern dsah...@gmail.com Cc: Peter Zijlstra pet...@infradead.org Cc: Robert Richter robert.rich...@amd.com Cc: Andi Kleen a...@firstfloor.org Cc: Stephane Eranian eran...@google.com Link: http://lkml.kernel.org/r/133839-14007-3-git-send-email-feng.t...@intel.com Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-script.c|5 +++-- .../perf/util/scripting-engines/trace-event-perl.c | 11 ++- .../util/scripting-engines/trace-event-python.c| 13 +++-- tools/perf/util/trace-event-scripting.c|2 +- tools/perf/util/trace-event.h |5 +++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6425612..30a9cb8 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -396,9 +396,10 @@ 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 machine *machine, - struct thread *thread) + struct addr_location *al) { struct perf_event_attr *attr = evsel-attr; + struct thread *thread = al-thread; if (output[attr-type].fields == 0) return; @@ -511,7 +512,7 @@ static int process_sample_event(struct perf_tool *tool __used, if (cpu_list !test_bit(sample-cpu, cpu_bitmap)) return 0; - scripting_ops-process_event(event, sample, evsel, machine, thread); + scripting_ops-process_event(event, sample, evsel, machine, al); evsel-hists.stats.total_period += sample-period; 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 20cefeb..1cde6aa 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -261,7 +261,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __unused, - struct thread *thread) + struct addr_location *al) { struct format_field *field; static char handler[256]; @@ -272,6 +272,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, int cpu = sample-cpu; void *data = sample-raw_data; unsigned long long nsecs = sample-time; + struct thread *thread = al-thread; char *comm = thread-comm; dSP; @@ -349,7 +350,7 @@ static void perl_process_event_generic(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __unused, - struct thread *thread __unused) + struct addr_location *al __unused) { dSP; @@ -375,10 +376,10 @@ static void perl_process_event(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine, - struct thread *thread) + struct addr_location *al) { - perl_process_tracepoint(event, sample, evsel, machine, thread); - perl_process_event_generic(event, sample, evsel, machine, thread); + perl_process_tracepoint(event, sample, evsel, machine, al); + perl_process_event_generic(event, sample, evsel, machine, al); } static void run_start_sub(void) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index b9010d8..24711b3 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -225,7 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event __unused,