aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-06-27 12:08:42 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-06-27 12:08:42 -0400
commitda3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch)
treef1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/util/scripting-engines
parent7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (diff)
perf tools: Stop using a global trace events description list
The pevent thing is per perf.data file, so I made it stop being static and become a perf_session member, so tools processing perf.data files use perf_session and _there_ we read the trace events description into session->pevent and then change everywhere to stop using that single global pevent variable and use the per session one. Note that it _doesn't_ fall backs to trace__event_id, as we're not interested at all in what is present in the /sys/kernel/debug/tracing/events in the workstation doing the analysis, just in what is in the perf.data file. This patch also introduces perf_session__set_tracepoints_handlers that is the perf perf.data/session way to associate handlers to tracepoint events by resolving their IDs using the events descriptions stored in a perf.data file. Make 'perf sched' use it. Reported-by: Dmitry Antipov <dmitry.antipov@linaro.org> Tested-by: Dmitry Antipov <dmitry.antipov@linaro.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linaro-dev@lists.linaro.org Cc: patches@linaro.org Link: http://lkml.kernel.org/r/20120625232016.GA28525@infradead.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/scripting-engines')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c28
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c21
2 files changed, 28 insertions, 21 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 4c1b3d72a1d2..b3620fe12763 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -233,7 +233,8 @@ static void define_event_symbols(struct event_format *event,
233 define_event_symbols(event, ev_name, args->next); 233 define_event_symbols(event, ev_name, args->next);
234} 234}
235 235
236static inline struct event_format *find_cache_event(int type) 236static inline
237struct event_format *find_cache_event(struct pevent *pevent, int type)
237{ 238{
238 static char ev_name[256]; 239 static char ev_name[256];
239 struct event_format *event; 240 struct event_format *event;
@@ -241,7 +242,7 @@ static inline struct event_format *find_cache_event(int type)
241 if (events[type]) 242 if (events[type])
242 return events[type]; 243 return events[type];
243 244
244 events[type] = event = trace_find_event(type); 245 events[type] = event = pevent_find_event(pevent, type);
245 if (!event) 246 if (!event)
246 return NULL; 247 return NULL;
247 248
@@ -252,7 +253,8 @@ static inline struct event_format *find_cache_event(int type)
252 return event; 253 return event;
253} 254}
254 255
255static void perl_process_tracepoint(union perf_event *pevent __unused, 256static void perl_process_tracepoint(union perf_event *perf_event __unused,
257 struct pevent *pevent,
256 struct perf_sample *sample, 258 struct perf_sample *sample,
257 struct perf_evsel *evsel, 259 struct perf_evsel *evsel,
258 struct machine *machine __unused, 260 struct machine *machine __unused,
@@ -275,13 +277,13 @@ static void perl_process_tracepoint(union perf_event *pevent __unused,
275 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) 277 if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
276 return; 278 return;
277 279
278 type = trace_parse_common_type(data); 280 type = trace_parse_common_type(pevent, data);
279 281
280 event = find_cache_event(type); 282 event = find_cache_event(pevent, type);
281 if (!event) 283 if (!event)
282 die("ug! no event found for type %d", type); 284 die("ug! no event found for type %d", type);
283 285
284 pid = trace_parse_common_pid(data); 286 pid = trace_parse_common_pid(pevent, data);
285 287
286 sprintf(handler, "%s::%s", event->system, event->name); 288 sprintf(handler, "%s::%s", event->system, event->name);
287 289
@@ -314,7 +316,8 @@ static void perl_process_tracepoint(union perf_event *pevent __unused,
314 offset = field->offset; 316 offset = field->offset;
315 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0))); 317 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));
316 } else { /* FIELD_IS_NUMERIC */ 318 } else { /* FIELD_IS_NUMERIC */
317 val = read_size(data + field->offset, field->size); 319 val = read_size(pevent, data + field->offset,
320 field->size);
318 if (field->flags & FIELD_IS_SIGNED) { 321 if (field->flags & FIELD_IS_SIGNED) {
319 XPUSHs(sv_2mortal(newSViv(val))); 322 XPUSHs(sv_2mortal(newSViv(val)));
320 } else { 323 } else {
@@ -368,14 +371,15 @@ static void perl_process_event_generic(union perf_event *pevent __unused,
368 LEAVE; 371 LEAVE;
369} 372}
370 373
371static void perl_process_event(union perf_event *pevent, 374static void perl_process_event(union perf_event *event,
375 struct pevent *pevent,
372 struct perf_sample *sample, 376 struct perf_sample *sample,
373 struct perf_evsel *evsel, 377 struct perf_evsel *evsel,
374 struct machine *machine, 378 struct machine *machine,
375 struct thread *thread) 379 struct thread *thread)
376{ 380{
377 perl_process_tracepoint(pevent, sample, evsel, machine, thread); 381 perl_process_tracepoint(event, pevent, sample, evsel, machine, thread);
378 perl_process_event_generic(pevent, sample, evsel, machine, thread); 382 perl_process_event_generic(event, sample, evsel, machine, thread);
379} 383}
380 384
381static void run_start_sub(void) 385static void run_start_sub(void)
@@ -448,7 +452,7 @@ static int perl_stop_script(void)
448 return 0; 452 return 0;
449} 453}
450 454
451static int perl_generate_script(const char *outfile) 455static int perl_generate_script(struct pevent *pevent, const char *outfile)
452{ 456{
453 struct event_format *event = NULL; 457 struct event_format *event = NULL;
454 struct format_field *f; 458 struct format_field *f;
@@ -495,7 +499,7 @@ static int perl_generate_script(const char *outfile)
495 fprintf(ofp, "sub trace_begin\n{\n\t# optional\n}\n\n"); 499 fprintf(ofp, "sub trace_begin\n{\n\t# optional\n}\n\n");
496 fprintf(ofp, "sub trace_end\n{\n\t# optional\n}\n\n"); 500 fprintf(ofp, "sub trace_end\n{\n\t# optional\n}\n\n");
497 501
498 while ((event = trace_find_next_event(event))) { 502 while ((event = trace_find_next_event(pevent, event))) {
499 fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name); 503 fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name);
500 fprintf(ofp, "\tmy ("); 504 fprintf(ofp, "\tmy (");
501 505
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index acb9795286c4..a8ca2f8179a9 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -190,7 +190,8 @@ static void define_event_symbols(struct event_format *event,
190 define_event_symbols(event, ev_name, args->next); 190 define_event_symbols(event, ev_name, args->next);
191} 191}
192 192
193static inline struct event_format *find_cache_event(int type) 193static inline
194struct event_format *find_cache_event(struct pevent *pevent, int type)
194{ 195{
195 static char ev_name[256]; 196 static char ev_name[256];
196 struct event_format *event; 197 struct event_format *event;
@@ -198,7 +199,7 @@ static inline struct event_format *find_cache_event(int type)
198 if (events[type]) 199 if (events[type])
199 return events[type]; 200 return events[type];
200 201
201 events[type] = event = trace_find_event(type); 202 events[type] = event = pevent_find_event(pevent, type);
202 if (!event) 203 if (!event)
203 return NULL; 204 return NULL;
204 205
@@ -209,7 +210,8 @@ static inline struct event_format *find_cache_event(int type)
209 return event; 210 return event;
210} 211}
211 212
212static void python_process_event(union perf_event *pevent __unused, 213static void python_process_event(union perf_event *perf_event __unused,
214 struct pevent *pevent,
213 struct perf_sample *sample, 215 struct perf_sample *sample,
214 struct perf_evsel *evsel __unused, 216 struct perf_evsel *evsel __unused,
215 struct machine *machine __unused, 217 struct machine *machine __unused,
@@ -233,13 +235,13 @@ static void python_process_event(union perf_event *pevent __unused,
233 if (!t) 235 if (!t)
234 Py_FatalError("couldn't create Python tuple"); 236 Py_FatalError("couldn't create Python tuple");
235 237
236 type = trace_parse_common_type(data); 238 type = trace_parse_common_type(pevent, data);
237 239
238 event = find_cache_event(type); 240 event = find_cache_event(pevent, type);
239 if (!event) 241 if (!event)
240 die("ug! no event found for type %d", type); 242 die("ug! no event found for type %d", type);
241 243
242 pid = trace_parse_common_pid(data); 244 pid = trace_parse_common_pid(pevent, data);
243 245
244 sprintf(handler_name, "%s__%s", event->system, event->name); 246 sprintf(handler_name, "%s__%s", event->system, event->name);
245 247
@@ -284,7 +286,8 @@ static void python_process_event(union perf_event *pevent __unused,
284 offset = field->offset; 286 offset = field->offset;
285 obj = PyString_FromString((char *)data + offset); 287 obj = PyString_FromString((char *)data + offset);
286 } else { /* FIELD_IS_NUMERIC */ 288 } else { /* FIELD_IS_NUMERIC */
287 val = read_size(data + field->offset, field->size); 289 val = read_size(pevent, data + field->offset,
290 field->size);
288 if (field->flags & FIELD_IS_SIGNED) { 291 if (field->flags & FIELD_IS_SIGNED) {
289 if ((long long)val >= LONG_MIN && 292 if ((long long)val >= LONG_MIN &&
290 (long long)val <= LONG_MAX) 293 (long long)val <= LONG_MAX)
@@ -438,7 +441,7 @@ out:
438 return err; 441 return err;
439} 442}
440 443
441static int python_generate_script(const char *outfile) 444static int python_generate_script(struct pevent *pevent, const char *outfile)
442{ 445{
443 struct event_format *event = NULL; 446 struct event_format *event = NULL;
444 struct format_field *f; 447 struct format_field *f;
@@ -487,7 +490,7 @@ static int python_generate_script(const char *outfile)
487 fprintf(ofp, "def trace_end():\n"); 490 fprintf(ofp, "def trace_end():\n");
488 fprintf(ofp, "\tprint \"in trace_end\"\n\n"); 491 fprintf(ofp, "\tprint \"in trace_end\"\n\n");
489 492
490 while ((event = trace_find_next_event(event))) { 493 while ((event = trace_find_next_event(pevent, event))) {
491 fprintf(ofp, "def %s__%s(", event->system, event->name); 494 fprintf(ofp, "def %s__%s(", event->system, event->name);
492 fprintf(ofp, "event_name, "); 495 fprintf(ofp, "event_name, ");
493 fprintf(ofp, "context, "); 496 fprintf(ofp, "context, ");