Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234476
b: refs/heads/master
c: 5807806
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Mar 1, 2011
1 parent eb59b6d commit 8010e77
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 374cfe56892701f062586d6a6de6cb71777a4184
refs/heads/master: 5807806a92450fd57f8063868efae9d4af74db02
21 changes: 19 additions & 2 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/top.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct perf_top {
*/
struct list_head active_symbols;
pthread_mutex_t active_symbols_lock;
pthread_cond_t active_symbols_cond;
u64 samples;
u64 kernel_samples, us_samples;
u64 exact_samples;
Expand Down

0 comments on commit 8010e77

Please sign in to comment.