aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2013-11-28 11:23:05 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-12-02 07:22:46 -0500
commit66cc3ada4ec3c277a21cba9996cc0cab3409033d (patch)
treef5c4e3461ef14f719ccfaf9179d34a134d741d75 /tools
parent5e22f6d22bae494ffc23da4032c477c54fd7c2d9 (diff)
perf timechart: Move power_events list to 'struct timechart'
Removing another global variable. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stanislav Fomichev <stfomichev@yandex-team.ru> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-2akef3p9caau56itf5mugd2b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-timechart.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 0c955acc08a2..8ee0ff1777a8 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -42,10 +42,12 @@
42#define PWR_EVENT_EXIT -1 42#define PWR_EVENT_EXIT -1
43 43
44struct per_pid; 44struct per_pid;
45struct power_event;
45 46
46struct timechart { 47struct timechart {
47 struct perf_tool tool; 48 struct perf_tool tool;
48 struct per_pid *all_data; 49 struct per_pid *all_data;
50 struct power_event *power_events;
49 int proc_num; 51 int proc_num;
50 unsigned int numcpus; 52 unsigned int numcpus;
51 u64 min_freq, /* Lowest CPU frequency seen */ 53 u64 min_freq, /* Lowest CPU frequency seen */
@@ -146,7 +148,6 @@ struct wake_event {
146 const char *backtrace; 148 const char *backtrace;
147}; 149};
148 150
149static struct power_event *power_events;
150static struct wake_event *wake_events; 151static struct wake_event *wake_events;
151 152
152struct process_filter { 153struct process_filter {
@@ -312,7 +313,7 @@ static void c_state_start(int cpu, u64 timestamp, int state)
312 cpus_cstate_state[cpu] = state; 313 cpus_cstate_state[cpu] = state;
313} 314}
314 315
315static void c_state_end(int cpu, u64 timestamp) 316static void c_state_end(struct timechart *tchart, int cpu, u64 timestamp)
316{ 317{
317 struct power_event *pwr = zalloc(sizeof(*pwr)); 318 struct power_event *pwr = zalloc(sizeof(*pwr));
318 319
@@ -324,9 +325,9 @@ static void c_state_end(int cpu, u64 timestamp)
324 pwr->end_time = timestamp; 325 pwr->end_time = timestamp;
325 pwr->cpu = cpu; 326 pwr->cpu = cpu;
326 pwr->type = CSTATE; 327 pwr->type = CSTATE;
327 pwr->next = power_events; 328 pwr->next = tchart->power_events;
328 329
329 power_events = pwr; 330 tchart->power_events = pwr;
330} 331}
331 332
332static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq) 333static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq)
@@ -345,12 +346,12 @@ static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64
345 pwr->end_time = timestamp; 346 pwr->end_time = timestamp;
346 pwr->cpu = cpu; 347 pwr->cpu = cpu;
347 pwr->type = PSTATE; 348 pwr->type = PSTATE;
348 pwr->next = power_events; 349 pwr->next = tchart->power_events;
349 350
350 if (!pwr->start_time) 351 if (!pwr->start_time)
351 pwr->start_time = tchart->first_time; 352 pwr->start_time = tchart->first_time;
352 353
353 power_events = pwr; 354 tchart->power_events = pwr;
354 355
355 cpus_pstate_state[cpu] = new_freq; 356 cpus_pstate_state[cpu] = new_freq;
356 cpus_pstate_start_times[cpu] = timestamp; 357 cpus_pstate_start_times[cpu] = timestamp;
@@ -551,7 +552,7 @@ process_sample_cpu_idle(struct timechart *tchart __maybe_unused,
551 u32 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id"); 552 u32 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id");
552 553
553 if (state == (u32)PWR_EVENT_EXIT) 554 if (state == (u32)PWR_EVENT_EXIT)
554 c_state_end(cpu_id, sample->time); 555 c_state_end(tchart, cpu_id, sample->time);
555 else 556 else
556 c_state_start(cpu_id, sample->time, state); 557 c_state_start(cpu_id, sample->time, state);
557 return 0; 558 return 0;
@@ -614,12 +615,12 @@ process_sample_power_start(struct timechart *tchart __maybe_unused,
614} 615}
615 616
616static int 617static int
617process_sample_power_end(struct timechart *tchart __maybe_unused, 618process_sample_power_end(struct timechart *tchart,
618 struct perf_evsel *evsel __maybe_unused, 619 struct perf_evsel *evsel __maybe_unused,
619 struct perf_sample *sample, 620 struct perf_sample *sample,
620 const char *backtrace __maybe_unused) 621 const char *backtrace __maybe_unused)
621{ 622{
622 c_state_end(sample->cpu, sample->time); 623 c_state_end(tchart, sample->cpu, sample->time);
623 return 0; 624 return 0;
624} 625}
625 626
@@ -658,9 +659,9 @@ static void end_sample_processing(struct timechart *tchart)
658 pwr->end_time = tchart->last_time; 659 pwr->end_time = tchart->last_time;
659 pwr->cpu = cpu; 660 pwr->cpu = cpu;
660 pwr->type = CSTATE; 661 pwr->type = CSTATE;
661 pwr->next = power_events; 662 pwr->next = tchart->power_events;
662 663
663 power_events = pwr; 664 tchart->power_events = pwr;
664#endif 665#endif
665 /* P state */ 666 /* P state */
666 667
@@ -673,13 +674,13 @@ static void end_sample_processing(struct timechart *tchart)
673 pwr->end_time = tchart->last_time; 674 pwr->end_time = tchart->last_time;
674 pwr->cpu = cpu; 675 pwr->cpu = cpu;
675 pwr->type = PSTATE; 676 pwr->type = PSTATE;
676 pwr->next = power_events; 677 pwr->next = tchart->power_events;
677 678
678 if (!pwr->start_time) 679 if (!pwr->start_time)
679 pwr->start_time = tchart->first_time; 680 pwr->start_time = tchart->first_time;
680 if (!pwr->state) 681 if (!pwr->state)
681 pwr->state = tchart->min_freq; 682 pwr->state = tchart->min_freq;
682 power_events = pwr; 683 tchart->power_events = pwr;
683 } 684 }
684} 685}
685 686
@@ -735,7 +736,7 @@ static void sort_pids(struct timechart *tchart)
735static void draw_c_p_states(struct timechart *tchart) 736static void draw_c_p_states(struct timechart *tchart)
736{ 737{
737 struct power_event *pwr; 738 struct power_event *pwr;
738 pwr = power_events; 739 pwr = tchart->power_events;
739 740
740 /* 741 /*
741 * two pass drawing so that the P state bars are on top of the C state blocks 742 * two pass drawing so that the P state bars are on top of the C state blocks
@@ -746,7 +747,7 @@ static void draw_c_p_states(struct timechart *tchart)
746 pwr = pwr->next; 747 pwr = pwr->next;
747 } 748 }
748 749
749 pwr = power_events; 750 pwr = tchart->power_events;
750 while (pwr) { 751 while (pwr) {
751 if (pwr->type == PSTATE) { 752 if (pwr->type == PSTATE) {
752 if (!pwr->state) 753 if (!pwr->state)