diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
commit | da3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch) | |
tree | f1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/util/trace-event-read.c | |
parent | 7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (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/trace-event-read.c')
-rw-r--r-- | tools/perf/util/trace-event-read.c | 97 |
1 files changed, 50 insertions, 47 deletions
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index f097e0dd6c5c..719ed74a8565 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c | |||
@@ -114,20 +114,20 @@ static void skip(int size) | |||
114 | }; | 114 | }; |
115 | } | 115 | } |
116 | 116 | ||
117 | static unsigned int read4(void) | 117 | static unsigned int read4(struct pevent *pevent) |
118 | { | 118 | { |
119 | unsigned int data; | 119 | unsigned int data; |
120 | 120 | ||
121 | read_or_die(&data, 4); | 121 | read_or_die(&data, 4); |
122 | return __data2host4(perf_pevent, data); | 122 | return __data2host4(pevent, data); |
123 | } | 123 | } |
124 | 124 | ||
125 | static unsigned long long read8(void) | 125 | static unsigned long long read8(struct pevent *pevent) |
126 | { | 126 | { |
127 | unsigned long long data; | 127 | unsigned long long data; |
128 | 128 | ||
129 | read_or_die(&data, 8); | 129 | read_or_die(&data, 8); |
130 | return __data2host8(perf_pevent, data); | 130 | return __data2host8(pevent, data); |
131 | } | 131 | } |
132 | 132 | ||
133 | static char *read_string(void) | 133 | static char *read_string(void) |
@@ -168,12 +168,12 @@ static char *read_string(void) | |||
168 | return str; | 168 | return str; |
169 | } | 169 | } |
170 | 170 | ||
171 | static void read_proc_kallsyms(void) | 171 | static void read_proc_kallsyms(struct pevent *pevent) |
172 | { | 172 | { |
173 | unsigned int size; | 173 | unsigned int size; |
174 | char *buf; | 174 | char *buf; |
175 | 175 | ||
176 | size = read4(); | 176 | size = read4(pevent); |
177 | if (!size) | 177 | if (!size) |
178 | return; | 178 | return; |
179 | 179 | ||
@@ -181,29 +181,29 @@ static void read_proc_kallsyms(void) | |||
181 | read_or_die(buf, size); | 181 | read_or_die(buf, size); |
182 | buf[size] = '\0'; | 182 | buf[size] = '\0'; |
183 | 183 | ||
184 | parse_proc_kallsyms(buf, size); | 184 | parse_proc_kallsyms(pevent, buf, size); |
185 | 185 | ||
186 | free(buf); | 186 | free(buf); |
187 | } | 187 | } |
188 | 188 | ||
189 | static void read_ftrace_printk(void) | 189 | static void read_ftrace_printk(struct pevent *pevent) |
190 | { | 190 | { |
191 | unsigned int size; | 191 | unsigned int size; |
192 | char *buf; | 192 | char *buf; |
193 | 193 | ||
194 | size = read4(); | 194 | size = read4(pevent); |
195 | if (!size) | 195 | if (!size) |
196 | return; | 196 | return; |
197 | 197 | ||
198 | buf = malloc_or_die(size); | 198 | buf = malloc_or_die(size); |
199 | read_or_die(buf, size); | 199 | read_or_die(buf, size); |
200 | 200 | ||
201 | parse_ftrace_printk(buf, size); | 201 | parse_ftrace_printk(pevent, buf, size); |
202 | 202 | ||
203 | free(buf); | 203 | free(buf); |
204 | } | 204 | } |
205 | 205 | ||
206 | static void read_header_files(void) | 206 | static void read_header_files(struct pevent *pevent) |
207 | { | 207 | { |
208 | unsigned long long size; | 208 | unsigned long long size; |
209 | char *header_event; | 209 | char *header_event; |
@@ -214,7 +214,7 @@ static void read_header_files(void) | |||
214 | if (memcmp(buf, "header_page", 12) != 0) | 214 | if (memcmp(buf, "header_page", 12) != 0) |
215 | die("did not read header page"); | 215 | die("did not read header page"); |
216 | 216 | ||
217 | size = read8(); | 217 | size = read8(pevent); |
218 | skip(size); | 218 | skip(size); |
219 | 219 | ||
220 | /* | 220 | /* |
@@ -227,47 +227,48 @@ static void read_header_files(void) | |||
227 | if (memcmp(buf, "header_event", 13) != 0) | 227 | if (memcmp(buf, "header_event", 13) != 0) |
228 | die("did not read header event"); | 228 | die("did not read header event"); |
229 | 229 | ||
230 | size = read8(); | 230 | size = read8(pevent); |
231 | header_event = malloc_or_die(size); | 231 | header_event = malloc_or_die(size); |
232 | read_or_die(header_event, size); | 232 | read_or_die(header_event, size); |
233 | free(header_event); | 233 | free(header_event); |
234 | } | 234 | } |
235 | 235 | ||
236 | static void read_ftrace_file(unsigned long long size) | 236 | static void read_ftrace_file(struct pevent *pevent, unsigned long long size) |
237 | { | 237 | { |
238 | char *buf; | 238 | char *buf; |
239 | 239 | ||
240 | buf = malloc_or_die(size); | 240 | buf = malloc_or_die(size); |
241 | read_or_die(buf, size); | 241 | read_or_die(buf, size); |
242 | parse_ftrace_file(buf, size); | 242 | parse_ftrace_file(pevent, buf, size); |
243 | free(buf); | 243 | free(buf); |
244 | } | 244 | } |
245 | 245 | ||
246 | static void read_event_file(char *sys, unsigned long long size) | 246 | static void read_event_file(struct pevent *pevent, char *sys, |
247 | unsigned long long size) | ||
247 | { | 248 | { |
248 | char *buf; | 249 | char *buf; |
249 | 250 | ||
250 | buf = malloc_or_die(size); | 251 | buf = malloc_or_die(size); |
251 | read_or_die(buf, size); | 252 | read_or_die(buf, size); |
252 | parse_event_file(buf, size, sys); | 253 | parse_event_file(pevent, buf, size, sys); |
253 | free(buf); | 254 | free(buf); |
254 | } | 255 | } |
255 | 256 | ||
256 | static void read_ftrace_files(void) | 257 | static void read_ftrace_files(struct pevent *pevent) |
257 | { | 258 | { |
258 | unsigned long long size; | 259 | unsigned long long size; |
259 | int count; | 260 | int count; |
260 | int i; | 261 | int i; |
261 | 262 | ||
262 | count = read4(); | 263 | count = read4(pevent); |
263 | 264 | ||
264 | for (i = 0; i < count; i++) { | 265 | for (i = 0; i < count; i++) { |
265 | size = read8(); | 266 | size = read8(pevent); |
266 | read_ftrace_file(size); | 267 | read_ftrace_file(pevent, size); |
267 | } | 268 | } |
268 | } | 269 | } |
269 | 270 | ||
270 | static void read_event_files(void) | 271 | static void read_event_files(struct pevent *pevent) |
271 | { | 272 | { |
272 | unsigned long long size; | 273 | unsigned long long size; |
273 | char *sys; | 274 | char *sys; |
@@ -275,15 +276,15 @@ static void read_event_files(void) | |||
275 | int count; | 276 | int count; |
276 | int i,x; | 277 | int i,x; |
277 | 278 | ||
278 | systems = read4(); | 279 | systems = read4(pevent); |
279 | 280 | ||
280 | for (i = 0; i < systems; i++) { | 281 | for (i = 0; i < systems; i++) { |
281 | sys = read_string(); | 282 | sys = read_string(); |
282 | 283 | ||
283 | count = read4(); | 284 | count = read4(pevent); |
284 | for (x=0; x < count; x++) { | 285 | for (x=0; x < count; x++) { |
285 | size = read8(); | 286 | size = read8(pevent); |
286 | read_event_file(sys, size); | 287 | read_event_file(pevent, sys, size); |
287 | } | 288 | } |
288 | } | 289 | } |
289 | } | 290 | } |
@@ -377,7 +378,7 @@ static int calc_index(void *ptr, int cpu) | |||
377 | return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page; | 378 | return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page; |
378 | } | 379 | } |
379 | 380 | ||
380 | struct pevent_record *trace_peek_data(int cpu) | 381 | struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu) |
381 | { | 382 | { |
382 | struct pevent_record *data; | 383 | struct pevent_record *data; |
383 | void *page = cpu_data[cpu].page; | 384 | void *page = cpu_data[cpu].page; |
@@ -399,15 +400,15 @@ struct pevent_record *trace_peek_data(int cpu) | |||
399 | /* FIXME: handle header page */ | 400 | /* FIXME: handle header page */ |
400 | if (header_page_ts_size != 8) | 401 | if (header_page_ts_size != 8) |
401 | die("expected a long long type for timestamp"); | 402 | die("expected a long long type for timestamp"); |
402 | cpu_data[cpu].timestamp = data2host8(perf_pevent, ptr); | 403 | cpu_data[cpu].timestamp = data2host8(pevent, ptr); |
403 | ptr += 8; | 404 | ptr += 8; |
404 | switch (header_page_size_size) { | 405 | switch (header_page_size_size) { |
405 | case 4: | 406 | case 4: |
406 | cpu_data[cpu].page_size = data2host4(perf_pevent, ptr); | 407 | cpu_data[cpu].page_size = data2host4(pevent, ptr); |
407 | ptr += 4; | 408 | ptr += 4; |
408 | break; | 409 | break; |
409 | case 8: | 410 | case 8: |
410 | cpu_data[cpu].page_size = data2host8(perf_pevent, ptr); | 411 | cpu_data[cpu].page_size = data2host8(pevent, ptr); |
411 | ptr += 8; | 412 | ptr += 8; |
412 | break; | 413 | break; |
413 | default: | 414 | default: |
@@ -421,10 +422,10 @@ read_again: | |||
421 | 422 | ||
422 | if (idx >= cpu_data[cpu].page_size) { | 423 | if (idx >= cpu_data[cpu].page_size) { |
423 | get_next_page(cpu); | 424 | get_next_page(cpu); |
424 | return trace_peek_data(cpu); | 425 | return trace_peek_data(pevent, cpu); |
425 | } | 426 | } |
426 | 427 | ||
427 | type_len_ts = data2host4(perf_pevent, ptr); | 428 | type_len_ts = data2host4(pevent, ptr); |
428 | ptr += 4; | 429 | ptr += 4; |
429 | 430 | ||
430 | type_len = type_len4host(type_len_ts); | 431 | type_len = type_len4host(type_len_ts); |
@@ -434,14 +435,14 @@ read_again: | |||
434 | case RINGBUF_TYPE_PADDING: | 435 | case RINGBUF_TYPE_PADDING: |
435 | if (!delta) | 436 | if (!delta) |
436 | die("error, hit unexpected end of page"); | 437 | die("error, hit unexpected end of page"); |
437 | length = data2host4(perf_pevent, ptr); | 438 | length = data2host4(pevent, ptr); |
438 | ptr += 4; | 439 | ptr += 4; |
439 | length *= 4; | 440 | length *= 4; |
440 | ptr += length; | 441 | ptr += length; |
441 | goto read_again; | 442 | goto read_again; |
442 | 443 | ||
443 | case RINGBUF_TYPE_TIME_EXTEND: | 444 | case RINGBUF_TYPE_TIME_EXTEND: |
444 | extend = data2host4(perf_pevent, ptr); | 445 | extend = data2host4(pevent, ptr); |
445 | ptr += 4; | 446 | ptr += 4; |
446 | extend <<= TS_SHIFT; | 447 | extend <<= TS_SHIFT; |
447 | extend += delta; | 448 | extend += delta; |
@@ -452,7 +453,7 @@ read_again: | |||
452 | ptr += 12; | 453 | ptr += 12; |
453 | break; | 454 | break; |
454 | case 0: | 455 | case 0: |
455 | length = data2host4(perf_pevent, ptr); | 456 | length = data2host4(pevent, ptr); |
456 | ptr += 4; | 457 | ptr += 4; |
457 | die("here! length=%d", length); | 458 | die("here! length=%d", length); |
458 | break; | 459 | break; |
@@ -477,17 +478,17 @@ read_again: | |||
477 | return data; | 478 | return data; |
478 | } | 479 | } |
479 | 480 | ||
480 | struct pevent_record *trace_read_data(int cpu) | 481 | struct pevent_record *trace_read_data(struct pevent *pevent, int cpu) |
481 | { | 482 | { |
482 | struct pevent_record *data; | 483 | struct pevent_record *data; |
483 | 484 | ||
484 | data = trace_peek_data(cpu); | 485 | data = trace_peek_data(pevent, cpu); |
485 | cpu_data[cpu].next = NULL; | 486 | cpu_data[cpu].next = NULL; |
486 | 487 | ||
487 | return data; | 488 | return data; |
488 | } | 489 | } |
489 | 490 | ||
490 | ssize_t trace_report(int fd, bool __repipe) | 491 | ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe) |
491 | { | 492 | { |
492 | char buf[BUFSIZ]; | 493 | char buf[BUFSIZ]; |
493 | char test[] = { 23, 8, 68 }; | 494 | char test[] = { 23, 8, 68 }; |
@@ -519,30 +520,32 @@ ssize_t trace_report(int fd, bool __repipe) | |||
519 | file_bigendian = buf[0]; | 520 | file_bigendian = buf[0]; |
520 | host_bigendian = bigendian(); | 521 | host_bigendian = bigendian(); |
521 | 522 | ||
522 | read_trace_init(file_bigendian, host_bigendian); | 523 | *ppevent = read_trace_init(file_bigendian, host_bigendian); |
524 | if (*ppevent == NULL) | ||
525 | die("read_trace_init failed"); | ||
523 | 526 | ||
524 | read_or_die(buf, 1); | 527 | read_or_die(buf, 1); |
525 | long_size = buf[0]; | 528 | long_size = buf[0]; |
526 | 529 | ||
527 | page_size = read4(); | 530 | page_size = read4(*ppevent); |
528 | 531 | ||
529 | read_header_files(); | 532 | read_header_files(*ppevent); |
530 | 533 | ||
531 | read_ftrace_files(); | 534 | read_ftrace_files(*ppevent); |
532 | read_event_files(); | 535 | read_event_files(*ppevent); |
533 | read_proc_kallsyms(); | 536 | read_proc_kallsyms(*ppevent); |
534 | read_ftrace_printk(); | 537 | read_ftrace_printk(*ppevent); |
535 | 538 | ||
536 | size = calc_data_size - 1; | 539 | size = calc_data_size - 1; |
537 | calc_data_size = 0; | 540 | calc_data_size = 0; |
538 | repipe = false; | 541 | repipe = false; |
539 | 542 | ||
540 | if (show_funcs) { | 543 | if (show_funcs) { |
541 | pevent_print_funcs(perf_pevent); | 544 | pevent_print_funcs(*ppevent); |
542 | return size; | 545 | return size; |
543 | } | 546 | } |
544 | if (show_printk) { | 547 | if (show_printk) { |
545 | pevent_print_printk(perf_pevent); | 548 | pevent_print_printk(*ppevent); |
546 | return size; | 549 | return size; |
547 | } | 550 | } |
548 | 551 | ||