aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-05-13 22:09:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-05-28 09:23:59 -0400
commit3a5714f8b58913ded4d9e90abdd30e7e5993f863 (patch)
tree9fb715107ffd82613bb7f2732239845c8a700ea2 /tools
parent6f29097f45f6c375f2f6a76c589577575c7feb52 (diff)
perf top: Get rid of *_threaded() functions
Those _threaded() functions are needed to make hist tree handling thread-safe, but AFAICS the only thing it does is forcing it to use the intermediate 'collapsed' tree. This can be acheived by setting sort__need_collapse to 1 in cmd_top() so no need to keep those _threaded() variants. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1368497347-9628-4-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-top.c23
-rw-r--r--tools/perf/util/hist.c44
-rw-r--r--tools/perf/util/hist.h4
3 files changed, 19 insertions, 52 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 81adcafbac8f..5cd41ec43ce1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -284,11 +284,11 @@ static void perf_top__print_sym_table(struct perf_top *top)
284 return; 284 return;
285 } 285 }
286 286
287 hists__collapse_resort_threaded(&top->sym_evsel->hists); 287 hists__collapse_resort(&top->sym_evsel->hists);
288 hists__output_resort_threaded(&top->sym_evsel->hists); 288 hists__output_resort(&top->sym_evsel->hists);
289 hists__decay_entries_threaded(&top->sym_evsel->hists, 289 hists__decay_entries(&top->sym_evsel->hists,
290 top->hide_user_symbols, 290 top->hide_user_symbols,
291 top->hide_kernel_symbols); 291 top->hide_kernel_symbols);
292 hists__output_recalc_col_len(&top->sym_evsel->hists, 292 hists__output_recalc_col_len(&top->sym_evsel->hists,
293 top->print_entries - printed); 293 top->print_entries - printed);
294 putchar('\n'); 294 putchar('\n');
@@ -549,11 +549,11 @@ static void perf_top__sort_new_samples(void *arg)
549 if (t->evlist->selected != NULL) 549 if (t->evlist->selected != NULL)
550 t->sym_evsel = t->evlist->selected; 550 t->sym_evsel = t->evlist->selected;
551 551
552 hists__collapse_resort_threaded(&t->sym_evsel->hists); 552 hists__collapse_resort(&t->sym_evsel->hists);
553 hists__output_resort_threaded(&t->sym_evsel->hists); 553 hists__output_resort(&t->sym_evsel->hists);
554 hists__decay_entries_threaded(&t->sym_evsel->hists, 554 hists__decay_entries(&t->sym_evsel->hists,
555 t->hide_user_symbols, 555 t->hide_user_symbols,
556 t->hide_kernel_symbols); 556 t->hide_kernel_symbols);
557} 557}
558 558
559static void *display_thread_tui(void *arg) 559static void *display_thread_tui(void *arg)
@@ -1126,6 +1126,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1126 if (setup_sorting() < 0) 1126 if (setup_sorting() < 0)
1127 usage_with_options(top_usage, options); 1127 usage_with_options(top_usage, options);
1128 1128
1129 /* display thread wants entries to be collapsed in a different tree */
1130 sort__need_collapse = 1;
1131
1129 if (top.use_stdio) 1132 if (top.use_stdio)
1130 use_browser = 0; 1133 use_browser = 0;
1131 else if (top.use_tui) 1134 else if (top.use_tui)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 72b4eec820c3..7e0fa628e9ab 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -240,8 +240,7 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
240 return he->stat.period == 0; 240 return he->stat.period == 0;
241} 241}
242 242
243static void __hists__decay_entries(struct hists *hists, bool zap_user, 243void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
244 bool zap_kernel, bool threaded)
245{ 244{
246 struct rb_node *next = rb_first(&hists->entries); 245 struct rb_node *next = rb_first(&hists->entries);
247 struct hist_entry *n; 246 struct hist_entry *n;
@@ -260,7 +259,7 @@ static void __hists__decay_entries(struct hists *hists, bool zap_user,
260 !n->used) { 259 !n->used) {
261 rb_erase(&n->rb_node, &hists->entries); 260 rb_erase(&n->rb_node, &hists->entries);
262 261
263 if (sort__need_collapse || threaded) 262 if (sort__need_collapse)
264 rb_erase(&n->rb_node_in, &hists->entries_collapsed); 263 rb_erase(&n->rb_node_in, &hists->entries_collapsed);
265 264
266 hist_entry__free(n); 265 hist_entry__free(n);
@@ -269,17 +268,6 @@ static void __hists__decay_entries(struct hists *hists, bool zap_user,
269 } 268 }
270} 269}
271 270
272void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
273{
274 return __hists__decay_entries(hists, zap_user, zap_kernel, false);
275}
276
277void hists__decay_entries_threaded(struct hists *hists,
278 bool zap_user, bool zap_kernel)
279{
280 return __hists__decay_entries(hists, zap_user, zap_kernel, true);
281}
282
283/* 271/*
284 * histogram, sorted on item, collects periods 272 * histogram, sorted on item, collects periods
285 */ 273 */
@@ -613,13 +601,13 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
613 hists__filter_entry_by_symbol(hists, he); 601 hists__filter_entry_by_symbol(hists, he);
614} 602}
615 603
616static void __hists__collapse_resort(struct hists *hists, bool threaded) 604void hists__collapse_resort(struct hists *hists)
617{ 605{
618 struct rb_root *root; 606 struct rb_root *root;
619 struct rb_node *next; 607 struct rb_node *next;
620 struct hist_entry *n; 608 struct hist_entry *n;
621 609
622 if (!sort__need_collapse && !threaded) 610 if (!sort__need_collapse)
623 return; 611 return;
624 612
625 root = hists__get_rotate_entries_in(hists); 613 root = hists__get_rotate_entries_in(hists);
@@ -641,16 +629,6 @@ static void __hists__collapse_resort(struct hists *hists, bool threaded)
641 } 629 }
642} 630}
643 631
644void hists__collapse_resort(struct hists *hists)
645{
646 return __hists__collapse_resort(hists, false);
647}
648
649void hists__collapse_resort_threaded(struct hists *hists)
650{
651 return __hists__collapse_resort(hists, true);
652}
653
654/* 632/*
655 * reverse the map, sort on period. 633 * reverse the map, sort on period.
656 */ 634 */
@@ -737,7 +715,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
737 rb_insert_color(&he->rb_node, entries); 715 rb_insert_color(&he->rb_node, entries);
738} 716}
739 717
740static void __hists__output_resort(struct hists *hists, bool threaded) 718void hists__output_resort(struct hists *hists)
741{ 719{
742 struct rb_root *root; 720 struct rb_root *root;
743 struct rb_node *next; 721 struct rb_node *next;
@@ -746,7 +724,7 @@ static void __hists__output_resort(struct hists *hists, bool threaded)
746 724
747 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100); 725 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
748 726
749 if (sort__need_collapse || threaded) 727 if (sort__need_collapse)
750 root = &hists->entries_collapsed; 728 root = &hists->entries_collapsed;
751 else 729 else
752 root = hists->entries_in; 730 root = hists->entries_in;
@@ -767,16 +745,6 @@ static void __hists__output_resort(struct hists *hists, bool threaded)
767 } 745 }
768} 746}
769 747
770void hists__output_resort(struct hists *hists)
771{
772 return __hists__output_resort(hists, false);
773}
774
775void hists__output_resort_threaded(struct hists *hists)
776{
777 return __hists__output_resort(hists, true);
778}
779
780static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h, 748static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
781 enum hist_filter filter) 749 enum hist_filter filter)
782{ 750{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 6be88dc12b9a..bd81d799a1bf 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -104,13 +104,9 @@ struct hist_entry *__hists__add_mem_entry(struct hists *self,
104 u64 weight); 104 u64 weight);
105 105
106void hists__output_resort(struct hists *self); 106void hists__output_resort(struct hists *self);
107void hists__output_resort_threaded(struct hists *hists);
108void hists__collapse_resort(struct hists *self); 107void hists__collapse_resort(struct hists *self);
109void hists__collapse_resort_threaded(struct hists *hists);
110 108
111void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); 109void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
112void hists__decay_entries_threaded(struct hists *hists, bool zap_user,
113 bool zap_kernel);
114void hists__output_recalc_col_len(struct hists *hists, int max_rows); 110void hists__output_recalc_col_len(struct hists *hists, int max_rows);
115 111
116void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); 112void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);