diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-01 08:43:03 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-01 08:43:03 -0500 |
commit | 5807806a92450fd57f8063868efae9d4af74db02 (patch) | |
tree | 0fe0f09e2c1c5f702adcb265ce3b552d205deea5 /tools | |
parent | 374cfe56892701f062586d6a6de6cb71777a4184 (diff) |
perf top tui: Wait till the first sample to refresh the screen.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-top.c | 21 | ||||
-rw-r--r-- | tools/perf/util/top.h | 1 |
2 files changed, 20 insertions, 2 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 0b07cc30b669..417f757e3cbe 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -72,6 +72,7 @@ static struct perf_top top = { | |||
72 | .target_tid = -1, | 72 | .target_tid = -1, |
73 | .active_symbols = LIST_HEAD_INIT(top.active_symbols), | 73 | .active_symbols = LIST_HEAD_INIT(top.active_symbols), |
74 | .active_symbols_lock = PTHREAD_MUTEX_INITIALIZER, | 74 | .active_symbols_lock = PTHREAD_MUTEX_INITIALIZER, |
75 | .active_symbols_cond = PTHREAD_COND_INITIALIZER, | ||
75 | .freq = 1000, /* 1 KHz */ | 76 | .freq = 1000, /* 1 KHz */ |
76 | }; | 77 | }; |
77 | 78 | ||
@@ -577,7 +578,17 @@ static void handle_keypress(struct perf_session *session, int c) | |||
577 | 578 | ||
578 | static void *display_thread_tui(void *arg __used) | 579 | static void *display_thread_tui(void *arg __used) |
579 | { | 580 | { |
580 | perf_top__tui_browser(&top); | 581 | int err = 0; |
582 | pthread_mutex_lock(&top.active_symbols_lock); | ||
583 | while (list_empty(&top.active_symbols)) { | ||
584 | err = pthread_cond_wait(&top.active_symbols_cond, | ||
585 | &top.active_symbols_lock); | ||
586 | if (err) | ||
587 | break; | ||
588 | } | ||
589 | pthread_mutex_unlock(&top.active_symbols_lock); | ||
590 | if (!err) | ||
591 | perf_top__tui_browser(&top); | ||
581 | exit_browser(0); | 592 | exit_browser(0); |
582 | exit(0); | 593 | exit(0); |
583 | return NULL; | 594 | return NULL; |
@@ -776,8 +787,14 @@ static void perf_event__process_sample(const union perf_event *event, | |||
776 | syme->count[evsel->idx]++; | 787 | syme->count[evsel->idx]++; |
777 | record_precise_ip(syme, evsel->idx, ip); | 788 | record_precise_ip(syme, evsel->idx, ip); |
778 | pthread_mutex_lock(&top.active_symbols_lock); | 789 | pthread_mutex_lock(&top.active_symbols_lock); |
779 | if (list_empty(&syme->node) || !syme->node.next) | 790 | if (list_empty(&syme->node) || !syme->node.next) { |
791 | static bool first = true; | ||
780 | __list_insert_active_sym(syme); | 792 | __list_insert_active_sym(syme); |
793 | if (first) { | ||
794 | pthread_cond_broadcast(&top.active_symbols_cond); | ||
795 | first = false; | ||
796 | } | ||
797 | } | ||
781 | pthread_mutex_unlock(&top.active_symbols_lock); | 798 | pthread_mutex_unlock(&top.active_symbols_lock); |
782 | } | 799 | } |
783 | } | 800 | } |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index e8d28e2ecdba..96d1cb78af01 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
@@ -35,6 +35,7 @@ struct perf_top { | |||
35 | */ | 35 | */ |
36 | struct list_head active_symbols; | 36 | struct list_head active_symbols; |
37 | pthread_mutex_t active_symbols_lock; | 37 | pthread_mutex_t active_symbols_lock; |
38 | pthread_cond_t active_symbols_cond; | ||
38 | u64 samples; | 39 | u64 samples; |
39 | u64 kernel_samples, us_samples; | 40 | u64 kernel_samples, us_samples; |
40 | u64 exact_samples; | 41 | u64 exact_samples; |