aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 13:28:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 13:28:49 -0400
commit7e92daaefa68e5ef1e1732e45231e73adbb724e7 (patch)
tree8e7f8ac9d82654df4c65939c6682f95510e22977 /tools/perf/builtin-timechart.c
parent7a68294278ae714ce2632a54f0f46916dca64f56 (diff)
parent1d787d37c8ff6612b8151c6dff15bfa7347bcbdf (diff)
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf update from Ingo Molnar: "Lots of changes in this cycle as well, with hundreds of commits from over 30 contributors. Most of the activity was on the tooling side. Higher level changes: - New 'perf kvm' analysis tool, from Xiao Guangrong. - New 'perf trace' system-wide tracing tool - uprobes fixes + cleanups from Oleg Nesterov. - Lots of patches to make perf build on Android out of box, from Irina Tirdea - Extend ftrace function tracing utility to be more dynamic for its users. It allows for data passing to the callback functions, as well as reading regs as if a breakpoint were to trigger at function entry. The main goal of this patch series was to allow kprobes to use ftrace as an optimized probe point when a probe is placed on an ftrace nop. With lots of help from Masami Hiramatsu, and going through lots of iterations, we finally came up with a good solution. - Add cpumask for uncore pmu, use it in 'stat', from Yan, Zheng. - Various tracing updates from Steve Rostedt - Clean up and improve 'perf sched' performance by elliminating lots of needless calls to libtraceevent. - Event group parsing support, from Jiri Olsa - UI/gtk refactorings and improvements from Namhyung Kim - Add support for non-tracepoint events in perf script python, from Feng Tang - Add --symbols to 'script', similar to the one in 'report', from Feng Tang. Infrastructure enhancements and fixes: - Convert the trace builtins to use the growing evsel/evlist tracepoint infrastructure, removing several open coded constructs like switch like series of strcmp to dispatch events, etc. Basically what had already been showcased in 'perf sched'. - Add evsel constructor for tracepoints, that uses libtraceevent just to parse the /format events file, use it in a new 'perf test' to make sure the libtraceevent format parsing regressions can be more readily caught. - Some strange errors were happening in some builds, but not on the next, reported by several people, problem was some parser related files, generated during the build, didn't had proper make deps, fix from Eric Sandeen. - Introduce struct and cache information about the environment where a perf.data file was captured, from Namhyung Kim. - Fix handling of unresolved samples when --symbols is used in 'report', from Feng Tang. - Add union member access support to 'probe', from Hyeoncheol Lee. - Fixups to die() removal, from Namhyung Kim. - Render fixes for the TUI, from Namhyung Kim. - Don't enable annotation in non symbolic view, from Namhyung Kim. - Fix pipe mode in 'report', from Namhyung Kim. - Move related stats code from stat to util/, will be used by the 'stat' kvm tool, from Xiao Guangrong. - Remove die()/exit() calls from several tools. - Resolve vdso callchains, from Jiri Olsa - Don't pass const char pointers to basename, so that we can unconditionally use libgen.h and thus avoid ifdef BIONIC lines, from David Ahern - Refactor hist formatting so that it can be reused with the GTK browser, From Namhyung Kim - Fix build for another rbtree.c change, from Adrian Hunter. - Make 'perf diff' command work with evsel hists, from Jiri Olsa. - Use the only field_sep var that is set up: symbol_conf.field_sep, fix from Jiri Olsa. - .gitignore compiled python binaries, from Namhyung Kim. - Get rid of die() in more libtraceevent places, from Namhyung Kim. - Rename libtraceevent 'private' struct member to 'priv' so that it works in C++, from Steven Rostedt - Remove lots of exit()/die() calls from tools so that the main perf exit routine can take place, from David Ahern - Fix x86 build on x86-64, from David Ahern. - {int,str,rb}list fixes from Suzuki K Poulose - perf.data header fixes from Namhyung Kim - Allow user to indicate objdump path, needed in cross environments, from Maciek Borzecki - Fix hardware cache event name generation, fix from Jiri Olsa - Add round trip test for sw, hw and cache event names, catching the problem Jiri fixed, after Jiri's patch, the test passes successfully. - Clean target should do clean for lib/traceevent too, fix from David Ahern - Check the right variable for allocation failure, fix from Namhyung Kim - Set up evsel->tp_format regardless of evsel->name being set already, fix from Namhyung Kim - Oprofile fixes from Robert Richter. - Remove perf_event_attr needless version inflation, from Jiri Olsa - Introduce libtraceevent strerror like error reporting facility, from Namhyung Kim - Add pmu mappings to perf.data header and use event names from cmd line, from Robert Richter - Fix include order for bison/flex-generated C files, from Ben Hutchings - Build fixes and documentation corrections from David Ahern - Assorted cleanups from Robert Richter - Let O= makes handle relative paths, from Steven Rostedt - perf script python fixes, from Feng Tang. - Initial bash completion support, from Frederic Weisbecker - Allow building without libelf, from Namhyung Kim. - Support DWARF CFI based unwind to have callchains when %bp based unwinding is not possible, from Jiri Olsa. - Symbol resolution fixes, while fixing support PPC64 files with an .opt ELF section was the end goal, several fixes for code that handles all architectures and cleanups are included, from Cody Schafer. - Assorted fixes for Documentation and build in 32 bit, from Robert Richter - Cache the libtraceevent event_format associated to each evsel early, so that we avoid relookups, i.e. calling pevent_find_event repeatedly when processing tracepoint events. [ This is to reduce the surface contact with libtraceevents and make clear what is that the perf tools needs from that lib: so far parsing the common and per event fields. ] - Don't stop the build if the audit libraries are not installed, fix from Namhyung Kim. - Fix bfd.h/libbfd detection with recent binutils, from Markus Trippelsdorf. - Improve warning message when libunwind devel packages not present, from Jiri Olsa" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (282 commits) perf trace: Add aliases for some syscalls perf probe: Print an enum type variable in "enum variable-name" format when showing accessible variables perf tools: Check libaudit availability for perf-trace builtin perf hists: Add missing period_* fields when collapsing a hist entry perf trace: New tool perf evsel: Export the event_format constructor perf evsel: Introduce rawptr() method perf tools: Use perf_evsel__newtp in the event parser perf evsel: The tracepoint constructor should store sys:name perf evlist: Introduce set_filter() method perf evlist: Renane set_filters method to apply_filters perf test: Add test to check we correctly parse and match syscall open parms perf evsel: Handle endianity in intval method perf evsel: Know if byte swap is needed perf tools: Allow handling a NULL cpu_map as meaning "all cpus" perf evsel: Improve tracepoint constructor setup tools lib traceevent: Fix error path on pevent_parse_event perf test: Fix build failure trace: Move trace event enable from fs_initcall to core_initcall tracing: Add an option for disabling markers ...
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c70
1 files changed, 30 insertions, 40 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 3b75b2e21ea5..b1a8a3b841cc 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -168,9 +168,8 @@ static struct per_pid *find_create_pid(int pid)
168 return cursor; 168 return cursor;
169 cursor = cursor->next; 169 cursor = cursor->next;
170 } 170 }
171 cursor = malloc(sizeof(struct per_pid)); 171 cursor = zalloc(sizeof(*cursor));
172 assert(cursor != NULL); 172 assert(cursor != NULL);
173 memset(cursor, 0, sizeof(struct per_pid));
174 cursor->pid = pid; 173 cursor->pid = pid;
175 cursor->next = all_data; 174 cursor->next = all_data;
176 all_data = cursor; 175 all_data = cursor;
@@ -195,9 +194,8 @@ static void pid_set_comm(int pid, char *comm)
195 } 194 }
196 c = c->next; 195 c = c->next;
197 } 196 }
198 c = malloc(sizeof(struct per_pidcomm)); 197 c = zalloc(sizeof(*c));
199 assert(c != NULL); 198 assert(c != NULL);
200 memset(c, 0, sizeof(struct per_pidcomm));
201 c->comm = strdup(comm); 199 c->comm = strdup(comm);
202 p->current = c; 200 p->current = c;
203 c->next = p->all; 201 c->next = p->all;
@@ -239,17 +237,15 @@ pid_put_sample(int pid, int type, unsigned int cpu, u64 start, u64 end)
239 p = find_create_pid(pid); 237 p = find_create_pid(pid);
240 c = p->current; 238 c = p->current;
241 if (!c) { 239 if (!c) {
242 c = malloc(sizeof(struct per_pidcomm)); 240 c = zalloc(sizeof(*c));
243 assert(c != NULL); 241 assert(c != NULL);
244 memset(c, 0, sizeof(struct per_pidcomm));
245 p->current = c; 242 p->current = c;
246 c->next = p->all; 243 c->next = p->all;
247 p->all = c; 244 p->all = c;
248 } 245 }
249 246
250 sample = malloc(sizeof(struct cpu_sample)); 247 sample = zalloc(sizeof(*sample));
251 assert(sample != NULL); 248 assert(sample != NULL);
252 memset(sample, 0, sizeof(struct cpu_sample));
253 sample->start_time = start; 249 sample->start_time = start;
254 sample->end_time = end; 250 sample->end_time = end;
255 sample->type = type; 251 sample->type = type;
@@ -275,28 +271,28 @@ static int cpus_cstate_state[MAX_CPUS];
275static u64 cpus_pstate_start_times[MAX_CPUS]; 271static u64 cpus_pstate_start_times[MAX_CPUS];
276static u64 cpus_pstate_state[MAX_CPUS]; 272static u64 cpus_pstate_state[MAX_CPUS];
277 273
278static int process_comm_event(struct perf_tool *tool __used, 274static int process_comm_event(struct perf_tool *tool __maybe_unused,
279 union perf_event *event, 275 union perf_event *event,
280 struct perf_sample *sample __used, 276 struct perf_sample *sample __maybe_unused,
281 struct machine *machine __used) 277 struct machine *machine __maybe_unused)
282{ 278{
283 pid_set_comm(event->comm.tid, event->comm.comm); 279 pid_set_comm(event->comm.tid, event->comm.comm);
284 return 0; 280 return 0;
285} 281}
286 282
287static int process_fork_event(struct perf_tool *tool __used, 283static int process_fork_event(struct perf_tool *tool __maybe_unused,
288 union perf_event *event, 284 union perf_event *event,
289 struct perf_sample *sample __used, 285 struct perf_sample *sample __maybe_unused,
290 struct machine *machine __used) 286 struct machine *machine __maybe_unused)
291{ 287{
292 pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); 288 pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
293 return 0; 289 return 0;
294} 290}
295 291
296static int process_exit_event(struct perf_tool *tool __used, 292static int process_exit_event(struct perf_tool *tool __maybe_unused,
297 union perf_event *event, 293 union perf_event *event,
298 struct perf_sample *sample __used, 294 struct perf_sample *sample __maybe_unused,
299 struct machine *machine __used) 295 struct machine *machine __maybe_unused)
300{ 296{
301 pid_exit(event->fork.pid, event->fork.time); 297 pid_exit(event->fork.pid, event->fork.time);
302 return 0; 298 return 0;
@@ -373,11 +369,10 @@ static void c_state_start(int cpu, u64 timestamp, int state)
373 369
374static void c_state_end(int cpu, u64 timestamp) 370static void c_state_end(int cpu, u64 timestamp)
375{ 371{
376 struct power_event *pwr; 372 struct power_event *pwr = zalloc(sizeof(*pwr));
377 pwr = malloc(sizeof(struct power_event)); 373
378 if (!pwr) 374 if (!pwr)
379 return; 375 return;
380 memset(pwr, 0, sizeof(struct power_event));
381 376
382 pwr->state = cpus_cstate_state[cpu]; 377 pwr->state = cpus_cstate_state[cpu];
383 pwr->start_time = cpus_cstate_start_times[cpu]; 378 pwr->start_time = cpus_cstate_start_times[cpu];
@@ -392,14 +387,13 @@ static void c_state_end(int cpu, u64 timestamp)
392static void p_state_change(int cpu, u64 timestamp, u64 new_freq) 387static void p_state_change(int cpu, u64 timestamp, u64 new_freq)
393{ 388{
394 struct power_event *pwr; 389 struct power_event *pwr;
395 pwr = malloc(sizeof(struct power_event));
396 390
397 if (new_freq > 8000000) /* detect invalid data */ 391 if (new_freq > 8000000) /* detect invalid data */
398 return; 392 return;
399 393
394 pwr = zalloc(sizeof(*pwr));
400 if (!pwr) 395 if (!pwr)
401 return; 396 return;
402 memset(pwr, 0, sizeof(struct power_event));
403 397
404 pwr->state = cpus_pstate_state[cpu]; 398 pwr->state = cpus_pstate_state[cpu];
405 pwr->start_time = cpus_pstate_start_times[cpu]; 399 pwr->start_time = cpus_pstate_start_times[cpu];
@@ -429,15 +423,13 @@ static void p_state_change(int cpu, u64 timestamp, u64 new_freq)
429static void 423static void
430sched_wakeup(int cpu, u64 timestamp, int pid, struct trace_entry *te) 424sched_wakeup(int cpu, u64 timestamp, int pid, struct trace_entry *te)
431{ 425{
432 struct wake_event *we;
433 struct per_pid *p; 426 struct per_pid *p;
434 struct wakeup_entry *wake = (void *)te; 427 struct wakeup_entry *wake = (void *)te;
428 struct wake_event *we = zalloc(sizeof(*we));
435 429
436 we = malloc(sizeof(struct wake_event));
437 if (!we) 430 if (!we)
438 return; 431 return;
439 432
440 memset(we, 0, sizeof(struct wake_event));
441 we->time = timestamp; 433 we->time = timestamp;
442 we->waker = pid; 434 we->waker = pid;
443 435
@@ -491,11 +483,11 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
491} 483}
492 484
493 485
494static int process_sample_event(struct perf_tool *tool __used, 486static int process_sample_event(struct perf_tool *tool __maybe_unused,
495 union perf_event *event __used, 487 union perf_event *event __maybe_unused,
496 struct perf_sample *sample, 488 struct perf_sample *sample,
497 struct perf_evsel *evsel, 489 struct perf_evsel *evsel,
498 struct machine *machine __used) 490 struct machine *machine __maybe_unused)
499{ 491{
500 struct trace_entry *te; 492 struct trace_entry *te;
501 493
@@ -579,13 +571,12 @@ static void end_sample_processing(void)
579 struct power_event *pwr; 571 struct power_event *pwr;
580 572
581 for (cpu = 0; cpu <= numcpus; cpu++) { 573 for (cpu = 0; cpu <= numcpus; cpu++) {
582 pwr = malloc(sizeof(struct power_event)); 574 /* C state */
575#if 0
576 pwr = zalloc(sizeof(*pwr));
583 if (!pwr) 577 if (!pwr)
584 return; 578 return;
585 memset(pwr, 0, sizeof(struct power_event));
586 579
587 /* C state */
588#if 0
589 pwr->state = cpus_cstate_state[cpu]; 580 pwr->state = cpus_cstate_state[cpu];
590 pwr->start_time = cpus_cstate_start_times[cpu]; 581 pwr->start_time = cpus_cstate_start_times[cpu];
591 pwr->end_time = last_time; 582 pwr->end_time = last_time;
@@ -597,10 +588,9 @@ static void end_sample_processing(void)
597#endif 588#endif
598 /* P state */ 589 /* P state */
599 590
600 pwr = malloc(sizeof(struct power_event)); 591 pwr = zalloc(sizeof(*pwr));
601 if (!pwr) 592 if (!pwr)
602 return; 593 return;
603 memset(pwr, 0, sizeof(struct power_event));
604 594
605 pwr->state = cpus_pstate_state[cpu]; 595 pwr->state = cpus_pstate_state[cpu];
606 pwr->start_time = cpus_pstate_start_times[cpu]; 596 pwr->start_time = cpus_pstate_start_times[cpu];
@@ -830,11 +820,9 @@ static void draw_process_bars(void)
830 820
831static void add_process_filter(const char *string) 821static void add_process_filter(const char *string)
832{ 822{
833 struct process_filter *filt; 823 int pid = strtoull(string, NULL, 10);
834 int pid; 824 struct process_filter *filt = malloc(sizeof(*filt));
835 825
836 pid = strtoull(string, NULL, 10);
837 filt = malloc(sizeof(struct process_filter));
838 if (!filt) 826 if (!filt)
839 return; 827 return;
840 828
@@ -1081,7 +1069,8 @@ static int __cmd_record(int argc, const char **argv)
1081} 1069}
1082 1070
1083static int 1071static int
1084parse_process(const struct option *opt __used, const char *arg, int __used unset) 1072parse_process(const struct option *opt __maybe_unused, const char *arg,
1073 int __maybe_unused unset)
1085{ 1074{
1086 if (arg) 1075 if (arg)
1087 add_process_filter(arg); 1076 add_process_filter(arg);
@@ -1106,7 +1095,8 @@ static const struct option options[] = {
1106}; 1095};
1107 1096
1108 1097
1109int cmd_timechart(int argc, const char **argv, const char *prefix __used) 1098int cmd_timechart(int argc, const char **argv,
1099 const char *prefix __maybe_unused)
1110{ 1100{
1111 argc = parse_options(argc, argv, options, timechart_usage, 1101 argc = parse_options(argc, argv, options, timechart_usage,
1112 PARSE_OPT_STOP_AT_NON_OPTION); 1102 PARSE_OPT_STOP_AT_NON_OPTION);