aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
authorStanislav Fomichev <stfomichev@yandex-team.ru>2013-12-02 09:37:35 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-12-16 14:34:27 -0500
commit58b9a18ecd251cbd6e666ad792023ab77c7d100e (patch)
tree80305634815f67be8b8ddd620fdbc32bcc68af26 /tools/perf/builtin-timechart.c
parentde996228dedc74d9e72b749bbc8225f5e2bf19d8 (diff)
perf timechart: Get number of CPUs from perf header
Print all CPUs, even if there were no events (use perf header to get number of CPUs). This is required to support topology in the next patch. Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Ramkumar Ramachandra <artagnon@gmail.com> Link: http://lkml.kernel.org/r/1385995056-20158-4-git-send-email-stfomichev@yandex-team.ru Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 99fe363f1de8..db9c4c172587 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -531,12 +531,10 @@ static int process_sample_event(struct perf_tool *tool,
531 tchart->last_time = sample->time; 531 tchart->last_time = sample->time;
532 } 532 }
533 533
534 if (sample->cpu > tchart->numcpus)
535 tchart->numcpus = sample->cpu;
536
537 if (evsel->handler != NULL) { 534 if (evsel->handler != NULL) {
538 tracepoint_handler f = evsel->handler; 535 tracepoint_handler f = evsel->handler;
539 return f(tchart, evsel, sample, cat_backtrace(event, sample, machine)); 536 return f(tchart, evsel, sample,
537 cat_backtrace(event, sample, machine));
540 } 538 }
541 539
542 return 0; 540 return 0;
@@ -1038,8 +1036,6 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
1038 int count; 1036 int count;
1039 int thresh = TIME_THRESH; 1037 int thresh = TIME_THRESH;
1040 1038
1041 tchart->numcpus++;
1042
1043 if (tchart->power_only) 1039 if (tchart->power_only)
1044 tchart->proc_num = 0; 1040 tchart->proc_num = 0;
1045 1041
@@ -1069,6 +1065,25 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
1069 svg_close(); 1065 svg_close();
1070} 1066}
1071 1067
1068static int process_header(struct perf_file_section *section __maybe_unused,
1069 struct perf_header *ph,
1070 int feat,
1071 int fd __maybe_unused,
1072 void *data)
1073{
1074 struct timechart *tchart = data;
1075
1076 switch (feat) {
1077 case HEADER_NRCPUS:
1078 tchart->numcpus = ph->env.nr_cpus_avail;
1079 break;
1080 default:
1081 break;
1082 }
1083
1084 return 0;
1085}
1086
1072static int __cmd_timechart(struct timechart *tchart, const char *output_name) 1087static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1073{ 1088{
1074 const struct perf_evsel_str_handler power_tracepoints[] = { 1089 const struct perf_evsel_str_handler power_tracepoints[] = {
@@ -1094,6 +1109,11 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1094 if (session == NULL) 1109 if (session == NULL)
1095 return -ENOMEM; 1110 return -ENOMEM;
1096 1111
1112 (void)perf_header__process_sections(&session->header,
1113 perf_data_file__fd(session->file),
1114 tchart,
1115 process_header);
1116
1097 if (!perf_session__has_traces(session, "timechart record")) 1117 if (!perf_session__has_traces(session, "timechart record"))
1098 goto out_delete; 1118 goto out_delete;
1099 1119