aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-03-01 10:43:03 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-01 10:43:03 -0300
commit5807806a92450fd57f8063868efae9d4af74db02 (patch)
tree0fe0f09e2c1c5f702adcb265ce3b552d205deea5 /tools/perf/builtin-top.c
parent374cfe56892701f062586d6a6de6cb71777a4184 (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/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0b07cc30b66..417f757e3cb 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -72,6 +72,7 @@ static struct perf_top top = {
.target_tid = -1,
.active_symbols = LIST_HEAD_INIT(top.active_symbols),
.active_symbols_lock = PTHREAD_MUTEX_INITIALIZER,
+ .active_symbols_cond = PTHREAD_COND_INITIALIZER,
.freq = 1000, /* 1 KHz */
};
@@ -577,7 +578,17 @@ static void handle_keypress(struct perf_session *session, int c)
static void *display_thread_tui(void *arg __used)
{
- perf_top__tui_browser(&top);
+ int err = 0;
+ pthread_mutex_lock(&top.active_symbols_lock);
+ while (list_empty(&top.active_symbols)) {
+ err = pthread_cond_wait(&top.active_symbols_cond,
+ &top.active_symbols_lock);
+ if (err)
+ break;
+ }
+ pthread_mutex_unlock(&top.active_symbols_lock);
+ if (!err)
+ perf_top__tui_browser(&top);
exit_browser(0);
exit(0);
return NULL;
@@ -776,8 +787,14 @@ static void perf_event__process_sample(const union perf_event *event,
syme->count[evsel->idx]++;
record_precise_ip(syme, evsel->idx, ip);
pthread_mutex_lock(&top.active_symbols_lock);
- if (list_empty(&syme->node) || !syme->node.next)
+ if (list_empty(&syme->node) || !syme->node.next) {
+ static bool first = true;
__list_insert_active_sym(syme);
+ if (first) {
+ pthread_cond_broadcast(&top.active_symbols_cond);
+ first = false;
+ }
+ }
pthread_mutex_unlock(&top.active_symbols_lock);
}
}