提交 2eaa1b40 编写于 作者: D David Ahern 提交者: Arnaldo Carvalho de Melo

perf script: Fix named threads support

Commit 73994dc1 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: NDavid 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 5a982132
...@@ -397,10 +397,10 @@ static void print_sample_bts(union perf_event *event, ...@@ -397,10 +397,10 @@ static void print_sample_bts(union perf_event *event,
static void process_event(union perf_event *event, struct perf_sample *sample, static void process_event(union perf_event *event, struct perf_sample *sample,
struct perf_evsel *evsel, struct machine *machine, struct perf_evsel *evsel, struct machine *machine,
struct addr_location *al) struct thread *thread,
struct addr_location *al __maybe_unused)
{ {
struct perf_event_attr *attr = &evsel->attr; struct perf_event_attr *attr = &evsel->attr;
struct thread *thread = al->thread;
if (output[attr->type].fields == 0) if (output[attr->type].fields == 0)
return; return;
...@@ -511,7 +511,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, ...@@ -511,7 +511,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0; return 0;
scripting_ops->process_event(event, sample, evsel, machine, &al); scripting_ops->process_event(event, sample, evsel, machine, thread, &al);
evsel->hists.stats.total_period += sample->period; evsel->hists.stats.total_period += sample->period;
return 0; return 0;
......
...@@ -261,7 +261,8 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused, ...@@ -261,7 +261,8 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine __maybe_unused, struct machine *machine __maybe_unused,
struct addr_location *al) struct thread *thread,
struct addr_location *al)
{ {
struct format_field *field; struct format_field *field;
static char handler[256]; static char handler[256];
...@@ -272,7 +273,6 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused, ...@@ -272,7 +273,6 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
int cpu = sample->cpu; int cpu = sample->cpu;
void *data = sample->raw_data; void *data = sample->raw_data;
unsigned long long nsecs = sample->time; unsigned long long nsecs = sample->time;
struct thread *thread = al->thread;
char *comm = thread->comm; char *comm = thread->comm;
dSP; dSP;
...@@ -351,7 +351,8 @@ static void perl_process_event_generic(union perf_event *event, ...@@ -351,7 +351,8 @@ static void perl_process_event_generic(union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine __maybe_unused, struct machine *machine __maybe_unused,
struct addr_location *al __maybe_unused) struct thread *thread __maybe_unused,
struct addr_location *al __maybe_unused)
{ {
dSP; dSP;
...@@ -377,10 +378,11 @@ static void perl_process_event(union perf_event *event, ...@@ -377,10 +378,11 @@ static void perl_process_event(union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine, struct machine *machine,
struct addr_location *al) struct thread *thread,
struct addr_location *al)
{ {
perl_process_tracepoint(event, sample, evsel, machine, al); perl_process_tracepoint(event, sample, evsel, machine, thread, al);
perl_process_event_generic(event, sample, evsel, machine, al); perl_process_event_generic(event, sample, evsel, machine, thread, al);
} }
static void run_start_sub(void) static void run_start_sub(void)
......
...@@ -225,6 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event ...@@ -225,6 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine __maybe_unused, struct machine *machine __maybe_unused,
struct thread *thread,
struct addr_location *al) struct addr_location *al)
{ {
PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
...@@ -238,7 +239,6 @@ static void python_process_tracepoint(union perf_event *perf_event ...@@ -238,7 +239,6 @@ static void python_process_tracepoint(union perf_event *perf_event
int cpu = sample->cpu; int cpu = sample->cpu;
void *data = sample->raw_data; void *data = sample->raw_data;
unsigned long long nsecs = sample->time; unsigned long long nsecs = sample->time;
struct thread *thread = al->thread;
char *comm = thread->comm; char *comm = thread->comm;
t = PyTuple_New(MAX_FIELDS); t = PyTuple_New(MAX_FIELDS);
...@@ -345,12 +345,12 @@ static void python_process_general_event(union perf_event *perf_event ...@@ -345,12 +345,12 @@ static void python_process_general_event(union perf_event *perf_event
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine __maybe_unused, struct machine *machine __maybe_unused,
struct thread *thread,
struct addr_location *al) struct addr_location *al)
{ {
PyObject *handler, *retval, *t, *dict; PyObject *handler, *retval, *t, *dict;
static char handler_name[64]; static char handler_name[64];
unsigned n = 0; unsigned n = 0;
struct thread *thread = al->thread;
/* /*
* Use the MAX_FIELDS to make the function expandable, though * 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,17 +404,18 @@ static void python_process_event(union perf_event *perf_event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine, struct machine *machine,
struct thread *thread,
struct addr_location *al) struct addr_location *al)
{ {
switch (evsel->attr.type) { switch (evsel->attr.type) {
case PERF_TYPE_TRACEPOINT: case PERF_TYPE_TRACEPOINT:
python_process_tracepoint(perf_event, sample, evsel, python_process_tracepoint(perf_event, sample, evsel,
machine, al); machine, thread, al);
break; break;
/* Reserve for future process_hw/sw/raw APIs */ /* Reserve for future process_hw/sw/raw APIs */
default: default:
python_process_general_event(perf_event, sample, evsel, python_process_general_event(perf_event, sample, evsel,
machine, al); machine, thread, al);
} }
} }
......
...@@ -39,7 +39,8 @@ static void process_event_unsupported(union perf_event *event __maybe_unused, ...@@ -39,7 +39,8 @@ static void process_event_unsupported(union perf_event *event __maybe_unused,
struct perf_sample *sample __maybe_unused, struct perf_sample *sample __maybe_unused,
struct perf_evsel *evsel __maybe_unused, struct perf_evsel *evsel __maybe_unused,
struct machine *machine __maybe_unused, struct machine *machine __maybe_unused,
struct addr_location *al __maybe_unused) struct thread *thread __maybe_unused,
struct addr_location *al __maybe_unused)
{ {
} }
......
...@@ -9,6 +9,7 @@ struct machine; ...@@ -9,6 +9,7 @@ struct machine;
struct perf_sample; struct perf_sample;
union perf_event; union perf_event;
struct perf_tool; struct perf_tool;
struct thread;
extern struct pevent *perf_pevent; extern struct pevent *perf_pevent;
...@@ -68,7 +69,8 @@ struct scripting_ops { ...@@ -68,7 +69,8 @@ struct scripting_ops {
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine, struct machine *machine,
struct addr_location *al); struct thread *thread,
struct addr_location *al);
int (*generate_script) (struct pevent *pevent, const char *outfile); int (*generate_script) (struct pevent *pevent, const char *outfile);
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册