aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2013-07-18 18:06:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-07-22 10:55:53 -0400
commit2eaa1b407aa6592a884f1be061ef61de7012c97a (patch)
tree0d488f803b833cde76946aebda09024f5c9860a3
parent5a9821321e0a61674fd5c4b5a9e95007d0e7e052 (diff)
perf script: Fix named threads support
Commit 73994dc broke named thread support in perf-script. The thread struct in al is the main thread for a multithreaded process. The thread struct used for analysis (e.g., dumping events) should be the specific thread for the sample. Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Feng Tang <feng.tang@intel.com> Link: http://lkml.kernel.org/r/1374185175-28272-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-script.c6
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c14
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c9
-rw-r--r--tools/perf/util/trace-event-scripting.c3
-rw-r--r--tools/perf/util/trace-event.h4
5 files changed, 21 insertions, 15 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ecb697998d3b..1cad37014673 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -397,10 +397,10 @@ static void print_sample_bts(union perf_event *event,
397 397
398static void process_event(union perf_event *event, struct perf_sample *sample, 398static void process_event(union perf_event *event, struct perf_sample *sample,
399 struct perf_evsel *evsel, struct machine *machine, 399 struct perf_evsel *evsel, struct machine *machine,
400 struct addr_location *al) 400 struct thread *thread,
401 struct addr_location *al __maybe_unused)
401{ 402{
402 struct perf_event_attr *attr = &evsel->attr; 403 struct perf_event_attr *attr = &evsel->attr;
403 struct thread *thread = al->thread;
404 404
405 if (output[attr->type].fields == 0) 405 if (output[attr->type].fields == 0)
406 return; 406 return;
@@ -511,7 +511,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
511 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) 511 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
512 return 0; 512 return 0;
513 513
514 scripting_ops->process_event(event, sample, evsel, machine, &al); 514 scripting_ops->process_event(event, sample, evsel, machine, thread, &al);
515 515
516 evsel->hists.stats.total_period += sample->period; 516 evsel->hists.stats.total_period += sample->period;
517 return 0; 517 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 eacec859f299..a85e4ae5f3ac 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -261,7 +261,8 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
261 struct perf_sample *sample, 261 struct perf_sample *sample,
262 struct perf_evsel *evsel, 262 struct perf_evsel *evsel,
263 struct machine *machine __maybe_unused, 263 struct machine *machine __maybe_unused,
264 struct addr_location *al) 264 struct thread *thread,
265 struct addr_location *al)
265{ 266{
266 struct format_field *field; 267 struct format_field *field;
267 static char handler[256]; 268 static char handler[256];
@@ -272,7 +273,6 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
272 int cpu = sample->cpu; 273 int cpu = sample->cpu;
273 void *data = sample->raw_data; 274 void *data = sample->raw_data;
274 unsigned long long nsecs = sample->time; 275 unsigned long long nsecs = sample->time;
275 struct thread *thread = al->thread;
276 char *comm = thread->comm; 276 char *comm = thread->comm;
277 277
278 dSP; 278 dSP;
@@ -351,7 +351,8 @@ static void perl_process_event_generic(union perf_event *event,
351 struct perf_sample *sample, 351 struct perf_sample *sample,
352 struct perf_evsel *evsel, 352 struct perf_evsel *evsel,
353 struct machine *machine __maybe_unused, 353 struct machine *machine __maybe_unused,
354 struct addr_location *al __maybe_unused) 354 struct thread *thread __maybe_unused,
355 struct addr_location *al __maybe_unused)
355{ 356{
356 dSP; 357 dSP;
357 358
@@ -377,10 +378,11 @@ static void perl_process_event(union perf_event *event,
377 struct perf_sample *sample, 378 struct perf_sample *sample,
378 struct perf_evsel *evsel, 379 struct perf_evsel *evsel,
379 struct machine *machine, 380 struct machine *machine,
380 struct addr_location *al) 381 struct thread *thread,
382 struct addr_location *al)
381{ 383{
382 perl_process_tracepoint(event, sample, evsel, machine, al); 384 perl_process_tracepoint(event, sample, evsel, machine, thread, al);
383 perl_process_event_generic(event, sample, evsel, machine, al); 385 perl_process_event_generic(event, sample, evsel, machine, thread, al);
384} 386}
385 387
386static void run_start_sub(void) 388static 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 e87aa5d9696b..cc75a3cef388 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -225,6 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event
225 struct perf_sample *sample, 225 struct perf_sample *sample,
226 struct perf_evsel *evsel, 226 struct perf_evsel *evsel,
227 struct machine *machine __maybe_unused, 227 struct machine *machine __maybe_unused,
228 struct thread *thread,
228 struct addr_location *al) 229 struct addr_location *al)
229{ 230{
230 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; 231 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
@@ -238,7 +239,6 @@ static void python_process_tracepoint(union perf_event *perf_event
238 int cpu = sample->cpu; 239 int cpu = sample->cpu;
239 void *data = sample->raw_data; 240 void *data = sample->raw_data;
240 unsigned long long nsecs = sample->time; 241 unsigned long long nsecs = sample->time;
241 struct thread *thread = al->thread;
242 char *comm = thread->comm; 242 char *comm = thread->comm;
243 243
244 t = PyTuple_New(MAX_FIELDS); 244 t = PyTuple_New(MAX_FIELDS);
@@ -345,12 +345,12 @@ static void python_process_general_event(union perf_event *perf_event
345 struct perf_sample *sample, 345 struct perf_sample *sample,
346 struct perf_evsel *evsel, 346 struct perf_evsel *evsel,
347 struct machine *machine __maybe_unused, 347 struct machine *machine __maybe_unused,
348 struct thread *thread,
348 struct addr_location *al) 349 struct addr_location *al)
349{ 350{
350 PyObject *handler, *retval, *t, *dict; 351 PyObject *handler, *retval, *t, *dict;
351 static char handler_name[64]; 352 static char handler_name[64];
352 unsigned n = 0; 353 unsigned n = 0;
353 struct thread *thread = al->thread;
354 354
355 /* 355 /*
356 * Use the MAX_FIELDS to make the function expandable, though 356 * Use the MAX_FIELDS to make the function expandable, though
@@ -404,17 +404,18 @@ static void python_process_event(union perf_event *perf_event,
404 struct perf_sample *sample, 404 struct perf_sample *sample,
405 struct perf_evsel *evsel, 405 struct perf_evsel *evsel,
406 struct machine *machine, 406 struct machine *machine,
407 struct thread *thread,
407 struct addr_location *al) 408 struct addr_location *al)
408{ 409{
409 switch (evsel->attr.type) { 410 switch (evsel->attr.type) {
410 case PERF_TYPE_TRACEPOINT: 411 case PERF_TYPE_TRACEPOINT:
411 python_process_tracepoint(perf_event, sample, evsel, 412 python_process_tracepoint(perf_event, sample, evsel,
412 machine, al); 413 machine, thread, al);
413 break; 414 break;
414 /* Reserve for future process_hw/sw/raw APIs */ 415 /* Reserve for future process_hw/sw/raw APIs */
415 default: 416 default:
416 python_process_general_event(perf_event, sample, evsel, 417 python_process_general_event(perf_event, sample, evsel,
417 machine, al); 418 machine, thread, al);
418 } 419 }
419} 420}
420 421
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 8715a1006d00..95199e4eea97 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -39,7 +39,8 @@ static void process_event_unsupported(union perf_event *event __maybe_unused,
39 struct perf_sample *sample __maybe_unused, 39 struct perf_sample *sample __maybe_unused,
40 struct perf_evsel *evsel __maybe_unused, 40 struct perf_evsel *evsel __maybe_unused,
41 struct machine *machine __maybe_unused, 41 struct machine *machine __maybe_unused,
42 struct addr_location *al __maybe_unused) 42 struct thread *thread __maybe_unused,
43 struct addr_location *al __maybe_unused)
43{ 44{
44} 45}
45 46
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 669a64a660d7..fafe1a40444a 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -9,6 +9,7 @@ struct machine;
9struct perf_sample; 9struct perf_sample;
10union perf_event; 10union perf_event;
11struct perf_tool; 11struct perf_tool;
12struct thread;
12 13
13extern struct pevent *perf_pevent; 14extern struct pevent *perf_pevent;
14 15
@@ -68,7 +69,8 @@ struct scripting_ops {
68 struct perf_sample *sample, 69 struct perf_sample *sample,
69 struct perf_evsel *evsel, 70 struct perf_evsel *evsel,
70 struct machine *machine, 71 struct machine *machine,
71 struct addr_location *al); 72 struct thread *thread,
73 struct addr_location *al);
72 int (*generate_script) (struct pevent *pevent, const char *outfile); 74 int (*generate_script) (struct pevent *pevent, const char *outfile);
73}; 75};
74 76