aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/event.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 02:56:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 02:56:32 -0500
commitfcd7476f9e03a36e709e0807198d47a826cc4e3a (patch)
tree1a9017988a864fae9ec62fd9e08e18cdc42d06cf /tools/perf/util/event.c
parentd320e203bad4cfcef3613e83a52f8c70a77e8a60 (diff)
parentd969135aae1434547f41853f0e8eaa622e8b8816 (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "A number of fixes: - Fix segfault on perf trace -i perf.data, from Namhyung Kim. - Fix segfault with --no-mmap-pages, from David Ahern. - Don't force a refresh during progress update in the TUI, greatly reducing startup costs, fix from Patrick Palka. - Fix sw clock event period test wrt not checking if using > max_sample_freq. - Handle throttle events in 'object code reading' test, fix from Adrian Hunter. - Prevent condition that all sort keys are elided, fix from Namhyung Kim. - Round mmap pages to power 2, from David Ahern. And a number of late arrival changes: - Add summary only option to 'perf trace', suppressing the decoding of events, from David Ahern - 'perf trace --summary' formatting simplifications, from Pekka Enberg. - Beautify fifth argument of mmap() as fd, in 'perf trace', from Namhyung Kim. - Add direct access to dynamic arrays in libtraceevent, from Steven Rostedt. - Synthesize non-exec MMAP records when --data used, allowing the resolution of data addresses to symbols (global variables, etc), by Arnaldo Carvalho de Melo. - Code cleanups by David Ahern and Adrian Hunter" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits) tools lib traceevent: Add direct access to dynamic arrays perf target: Shorten perf_target__ to target__ perf tests: Handle throttle events in 'object code reading' test perf evlist: Refactor mmap_pages parsing perf evlist: Round mmap pages to power 2 - v2 perf record: Fix segfault with --no-mmap-pages perf trace: Add summary only option perf trace: Simplify '--summary' output perf trace: Change syscall summary duration order perf tests: Compensate lower sample freq with longer test loop perf trace: Fix segfault on perf trace -i perf.data perf trace: Separate tp syscall field caching into init routine to be reused perf trace: Beautify fifth argument of mmap() as fd perf tests: Use lower sample_freq in sw clock event period test perf tests: Check return of perf_evlist__open sw clock event period test perf record: Move existing write_output into helper function perf record: Use correct return type for write() perf tools: Prevent condition that all sort keys are elided perf machine: Simplify synthesize_threads method perf machine: Introduce synthesize_threads method out of open coded equivalent ...
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r--tools/perf/util/event.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index ec9ae1114ed4..6e3a846aed0e 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -170,7 +170,8 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
170 union perf_event *event, 170 union perf_event *event,
171 pid_t pid, pid_t tgid, 171 pid_t pid, pid_t tgid,
172 perf_event__handler_t process, 172 perf_event__handler_t process,
173 struct machine *machine) 173 struct machine *machine,
174 bool mmap_data)
174{ 175{
175 char filename[PATH_MAX]; 176 char filename[PATH_MAX];
176 FILE *fp; 177 FILE *fp;
@@ -188,10 +189,6 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
188 } 189 }
189 190
190 event->header.type = PERF_RECORD_MMAP; 191 event->header.type = PERF_RECORD_MMAP;
191 /*
192 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
193 */
194 event->header.misc = PERF_RECORD_MISC_USER;
195 192
196 while (1) { 193 while (1) {
197 char bf[BUFSIZ]; 194 char bf[BUFSIZ];
@@ -215,9 +212,17 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
215 212
216 if (n != 5) 213 if (n != 5)
217 continue; 214 continue;
215 /*
216 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
217 */
218 event->header.misc = PERF_RECORD_MISC_USER;
218 219
219 if (prot[2] != 'x') 220 if (prot[2] != 'x') {
220 continue; 221 if (!mmap_data || prot[0] != 'r')
222 continue;
223
224 event->header.misc |= PERF_RECORD_MISC_MMAP_DATA;
225 }
221 226
222 if (!strcmp(execname, "")) 227 if (!strcmp(execname, ""))
223 strcpy(execname, anonstr); 228 strcpy(execname, anonstr);
@@ -304,20 +309,21 @@ static int __event__synthesize_thread(union perf_event *comm_event,
304 pid_t pid, int full, 309 pid_t pid, int full,
305 perf_event__handler_t process, 310 perf_event__handler_t process,
306 struct perf_tool *tool, 311 struct perf_tool *tool,
307 struct machine *machine) 312 struct machine *machine, bool mmap_data)
308{ 313{
309 pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, full, 314 pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, full,
310 process, machine); 315 process, machine);
311 if (tgid == -1) 316 if (tgid == -1)
312 return -1; 317 return -1;
313 return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, 318 return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
314 process, machine); 319 process, machine, mmap_data);
315} 320}
316 321
317int perf_event__synthesize_thread_map(struct perf_tool *tool, 322int perf_event__synthesize_thread_map(struct perf_tool *tool,
318 struct thread_map *threads, 323 struct thread_map *threads,
319 perf_event__handler_t process, 324 perf_event__handler_t process,
320 struct machine *machine) 325 struct machine *machine,
326 bool mmap_data)
321{ 327{
322 union perf_event *comm_event, *mmap_event; 328 union perf_event *comm_event, *mmap_event;
323 int err = -1, thread, j; 329 int err = -1, thread, j;
@@ -334,7 +340,8 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
334 for (thread = 0; thread < threads->nr; ++thread) { 340 for (thread = 0; thread < threads->nr; ++thread) {
335 if (__event__synthesize_thread(comm_event, mmap_event, 341 if (__event__synthesize_thread(comm_event, mmap_event,
336 threads->map[thread], 0, 342 threads->map[thread], 0,
337 process, tool, machine)) { 343 process, tool, machine,
344 mmap_data)) {
338 err = -1; 345 err = -1;
339 break; 346 break;
340 } 347 }
@@ -356,10 +363,10 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
356 363
357 /* if not, generate events for it */ 364 /* if not, generate events for it */
358 if (need_leader && 365 if (need_leader &&
359 __event__synthesize_thread(comm_event, 366 __event__synthesize_thread(comm_event, mmap_event,
360 mmap_event, 367 comm_event->comm.pid, 0,
361 comm_event->comm.pid, 0, 368 process, tool, machine,
362 process, tool, machine)) { 369 mmap_data)) {
363 err = -1; 370 err = -1;
364 break; 371 break;
365 } 372 }
@@ -374,7 +381,7 @@ out:
374 381
375int perf_event__synthesize_threads(struct perf_tool *tool, 382int perf_event__synthesize_threads(struct perf_tool *tool,
376 perf_event__handler_t process, 383 perf_event__handler_t process,
377 struct machine *machine) 384 struct machine *machine, bool mmap_data)
378{ 385{
379 DIR *proc; 386 DIR *proc;
380 struct dirent dirent, *next; 387 struct dirent dirent, *next;
@@ -404,7 +411,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
404 * one thread couldn't be synthesized. 411 * one thread couldn't be synthesized.
405 */ 412 */
406 __event__synthesize_thread(comm_event, mmap_event, pid, 1, 413 __event__synthesize_thread(comm_event, mmap_event, pid, 1,
407 process, tool, machine); 414 process, tool, machine, mmap_data);
408 } 415 }
409 416
410 err = 0; 417 err = 0;
@@ -528,19 +535,22 @@ int perf_event__process_lost(struct perf_tool *tool __maybe_unused,
528 535
529size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) 536size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
530{ 537{
531 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", 538 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n",
532 event->mmap.pid, event->mmap.tid, event->mmap.start, 539 event->mmap.pid, event->mmap.tid, event->mmap.start,
533 event->mmap.len, event->mmap.pgoff, event->mmap.filename); 540 event->mmap.len, event->mmap.pgoff,
541 (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
542 event->mmap.filename);
534} 543}
535 544
536size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) 545size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp)
537{ 546{
538 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 547 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64
539 " %02x:%02x %"PRIu64" %"PRIu64"]: %s\n", 548 " %02x:%02x %"PRIu64" %"PRIu64"]: %c %s\n",
540 event->mmap2.pid, event->mmap2.tid, event->mmap2.start, 549 event->mmap2.pid, event->mmap2.tid, event->mmap2.start,
541 event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, 550 event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj,
542 event->mmap2.min, event->mmap2.ino, 551 event->mmap2.min, event->mmap2.ino,
543 event->mmap2.ino_generation, 552 event->mmap2.ino_generation,
553 (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
544 event->mmap2.filename); 554 event->mmap2.filename);
545} 555}
546 556