aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 17:07:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-19 07:28:19 -0400
commitd7b76f0935d294e9abaac1577cdc2137eff15a49 (patch)
treef5775c52f68db3490961eced7a9e8e8ede28f969 /tools/perf
parent82e0af8710ceed57a2233b9652a3878b103084d8 (diff)
perf hists: Move the dso and thread filters from hist_browser
Since with dynamic addition of new hist entries we need to apply those filters as we merge new batches of hist_entry instances, for instance in perf top. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-zjhhf8kh9w1buty9p10od6rz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/hist.c10
-rw-r--r--tools/perf/util/hist.h9
-rw-r--r--tools/perf/util/ui/browsers/hists.c48
3 files changed, 35 insertions, 32 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 8d15e9f72f00..fdff2a8288b4 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1087,7 +1087,7 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h
1087 hists__calc_col_len(hists, h); 1087 hists__calc_col_len(hists, h);
1088} 1088}
1089 1089
1090void hists__filter_by_dso(struct hists *hists, const struct dso *dso) 1090void hists__filter_by_dso(struct hists *hists)
1091{ 1091{
1092 struct rb_node *nd; 1092 struct rb_node *nd;
1093 1093
@@ -1101,7 +1101,8 @@ void hists__filter_by_dso(struct hists *hists, const struct dso *dso)
1101 if (symbol_conf.exclude_other && !h->parent) 1101 if (symbol_conf.exclude_other && !h->parent)
1102 continue; 1102 continue;
1103 1103
1104 if (dso != NULL && (h->ms.map == NULL || h->ms.map->dso != dso)) { 1104 if (hists->dso_filter != NULL &&
1105 (h->ms.map == NULL || h->ms.map->dso != hists->dso_filter)) {
1105 h->filtered |= (1 << HIST_FILTER__DSO); 1106 h->filtered |= (1 << HIST_FILTER__DSO);
1106 continue; 1107 continue;
1107 } 1108 }
@@ -1110,7 +1111,7 @@ void hists__filter_by_dso(struct hists *hists, const struct dso *dso)
1110 } 1111 }
1111} 1112}
1112 1113
1113void hists__filter_by_thread(struct hists *hists, const struct thread *thread) 1114void hists__filter_by_thread(struct hists *hists)
1114{ 1115{
1115 struct rb_node *nd; 1116 struct rb_node *nd;
1116 1117
@@ -1121,7 +1122,8 @@ void hists__filter_by_thread(struct hists *hists, const struct thread *thread)
1121 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 1122 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1122 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 1123 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1123 1124
1124 if (thread != NULL && h->thread != thread) { 1125 if (hists->thread_filter != NULL &&
1126 h->thread != hists->thread_filter) {
1125 h->filtered |= (1 << HIST_FILTER__THREAD); 1127 h->filtered |= (1 << HIST_FILTER__THREAD);
1126 continue; 1128 continue;
1127 } 1129 }
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f338cb025671..575bcbc41355 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -43,12 +43,17 @@ enum hist_column {
43 HISTC_NR_COLS, /* Last entry */ 43 HISTC_NR_COLS, /* Last entry */
44}; 44};
45 45
46struct thread;
47struct dso;
48
46struct hists { 49struct hists {
47 struct rb_root entries_in_array[2]; 50 struct rb_root entries_in_array[2];
48 struct rb_root *entries_in; 51 struct rb_root *entries_in;
49 struct rb_root entries; 52 struct rb_root entries;
50 struct rb_root entries_collapsed; 53 struct rb_root entries_collapsed;
51 u64 nr_entries; 54 u64 nr_entries;
55 const struct thread *thread_filter;
56 const struct dso *dso_filter;
52 pthread_mutex_t lock; 57 pthread_mutex_t lock;
53 struct events_stats stats; 58 struct events_stats stats;
54 u64 event_stream; 59 u64 event_stream;
@@ -91,8 +96,8 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
91int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); 96int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr);
92int hist_entry__annotate(struct hist_entry *self, size_t privsize); 97int hist_entry__annotate(struct hist_entry *self, size_t privsize);
93 98
94void hists__filter_by_dso(struct hists *self, const struct dso *dso); 99void hists__filter_by_dso(struct hists *hists);
95void hists__filter_by_thread(struct hists *self, const struct thread *thread); 100void hists__filter_by_thread(struct hists *hists);
96 101
97u16 hists__col_len(struct hists *self, enum hist_column col); 102u16 hists__col_len(struct hists *self, enum hist_column col);
98void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); 103void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 936e641e9f86..94e1ab0badb1 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -24,14 +24,11 @@ struct hist_browser {
24 struct hists *hists; 24 struct hists *hists;
25 struct hist_entry *he_selection; 25 struct hist_entry *he_selection;
26 struct map_symbol *selection; 26 struct map_symbol *selection;
27 const struct thread *thread_filter;
28 const struct dso *dso_filter;
29 bool has_symbols; 27 bool has_symbols;
30}; 28};
31 29
32static int hists__browser_title(struct hists *self, char *bf, size_t size, 30static int hists__browser_title(struct hists *self, char *bf, size_t size,
33 const char *ev_name, const struct dso *dso, 31 const char *ev_name);
34 const struct thread *thread);
35 32
36static void hist_browser__refresh_dimensions(struct hist_browser *self) 33static void hist_browser__refresh_dimensions(struct hist_browser *self)
37{ 34{
@@ -307,8 +304,7 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name,
307 self->b.nr_entries = self->hists->nr_entries; 304 self->b.nr_entries = self->hists->nr_entries;
308 305
309 hist_browser__refresh_dimensions(self); 306 hist_browser__refresh_dimensions(self);
310 hists__browser_title(self->hists, title, sizeof(title), ev_name, 307 hists__browser_title(self->hists, title, sizeof(title), ev_name);
311 self->dso_filter, self->thread_filter);
312 308
313 if (ui_browser__show(&self->b, title, 309 if (ui_browser__show(&self->b, title,
314 "Press '?' for help on key bindings") < 0) 310 "Press '?' for help on key bindings") < 0)
@@ -323,8 +319,7 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name,
323 timer(arg); 319 timer(arg);
324 ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); 320 ui_browser__update_nr_entries(&self->b, self->hists->nr_entries);
325 hists__browser_title(self->hists, title, sizeof(title), 321 hists__browser_title(self->hists, title, sizeof(title),
326 ev_name, self->dso_filter, 322 ev_name);
327 self->thread_filter);
328 ui_browser__show_title(&self->b, title); 323 ui_browser__show_title(&self->b, title);
329 continue; 324 continue;
330 case 'D': { /* Debug */ 325 case 'D': { /* Debug */
@@ -809,11 +804,12 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *self)
809} 804}
810 805
811static int hists__browser_title(struct hists *self, char *bf, size_t size, 806static int hists__browser_title(struct hists *self, char *bf, size_t size,
812 const char *ev_name, const struct dso *dso, 807 const char *ev_name)
813 const struct thread *thread)
814{ 808{
815 char unit; 809 char unit;
816 int printed; 810 int printed;
811 const struct dso *dso = self->dso_filter;
812 const struct thread *thread = self->thread_filter;
817 unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE]; 813 unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
818 814
819 nr_events = convert_unit(nr_events, &unit); 815 nr_events = convert_unit(nr_events, &unit);
@@ -917,9 +913,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
917 continue; 913 continue;
918 } 914 }
919 top = pstack__pop(fstack); 915 top = pstack__pop(fstack);
920 if (top == &browser->dso_filter) 916 if (top == &browser->hists->dso_filter)
921 goto zoom_out_dso; 917 goto zoom_out_dso;
922 if (top == &browser->thread_filter) 918 if (top == &browser->hists->thread_filter)
923 goto zoom_out_thread; 919 goto zoom_out_thread;
924 continue; 920 continue;
925 } 921 }
@@ -947,14 +943,14 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
947 943
948 if (thread != NULL && 944 if (thread != NULL &&
949 asprintf(&options[nr_options], "Zoom %s %s(%d) thread", 945 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
950 (browser->thread_filter ? "out of" : "into"), 946 (browser->hists->thread_filter ? "out of" : "into"),
951 (thread->comm_set ? thread->comm : ""), 947 (thread->comm_set ? thread->comm : ""),
952 thread->pid) > 0) 948 thread->pid) > 0)
953 zoom_thread = nr_options++; 949 zoom_thread = nr_options++;
954 950
955 if (dso != NULL && 951 if (dso != NULL &&
956 asprintf(&options[nr_options], "Zoom %s %s DSO", 952 asprintf(&options[nr_options], "Zoom %s %s DSO",
957 (browser->dso_filter ? "out of" : "into"), 953 (browser->hists->dso_filter ? "out of" : "into"),
958 (dso->kernel ? "the Kernel" : dso->short_name)) > 0) 954 (dso->kernel ? "the Kernel" : dso->short_name)) > 0)
959 zoom_dso = nr_options++; 955 zoom_dso = nr_options++;
960 956
@@ -994,36 +990,36 @@ do_annotate:
994 map__browse(browser->selection->map); 990 map__browse(browser->selection->map);
995 else if (choice == zoom_dso) { 991 else if (choice == zoom_dso) {
996zoom_dso: 992zoom_dso:
997 if (browser->dso_filter) { 993 if (browser->hists->dso_filter) {
998 pstack__remove(fstack, &browser->dso_filter); 994 pstack__remove(fstack, &browser->hists->dso_filter);
999zoom_out_dso: 995zoom_out_dso:
1000 ui_helpline__pop(); 996 ui_helpline__pop();
1001 browser->dso_filter = NULL; 997 browser->hists->dso_filter = NULL;
1002 } else { 998 } else {
1003 if (dso == NULL) 999 if (dso == NULL)
1004 continue; 1000 continue;
1005 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"", 1001 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
1006 dso->kernel ? "the Kernel" : dso->short_name); 1002 dso->kernel ? "the Kernel" : dso->short_name);
1007 browser->dso_filter = dso; 1003 browser->hists->dso_filter = dso;
1008 pstack__push(fstack, &browser->dso_filter); 1004 pstack__push(fstack, &browser->hists->dso_filter);
1009 } 1005 }
1010 hists__filter_by_dso(self, browser->dso_filter); 1006 hists__filter_by_dso(self);
1011 hist_browser__reset(browser); 1007 hist_browser__reset(browser);
1012 } else if (choice == zoom_thread) { 1008 } else if (choice == zoom_thread) {
1013zoom_thread: 1009zoom_thread:
1014 if (browser->thread_filter) { 1010 if (browser->hists->thread_filter) {
1015 pstack__remove(fstack, &browser->thread_filter); 1011 pstack__remove(fstack, &browser->hists->thread_filter);
1016zoom_out_thread: 1012zoom_out_thread:
1017 ui_helpline__pop(); 1013 ui_helpline__pop();
1018 browser->thread_filter = NULL; 1014 browser->hists->thread_filter = NULL;
1019 } else { 1015 } else {
1020 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"", 1016 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1021 thread->comm_set ? thread->comm : "", 1017 thread->comm_set ? thread->comm : "",
1022 thread->pid); 1018 thread->pid);
1023 browser->thread_filter = thread; 1019 browser->hists->thread_filter = thread;
1024 pstack__push(fstack, &browser->thread_filter); 1020 pstack__push(fstack, &browser->hists->thread_filter);
1025 } 1021 }
1026 hists__filter_by_thread(self, browser->thread_filter); 1022 hists__filter_by_thread(self);
1027 hist_browser__reset(browser); 1023 hist_browser__reset(browser);
1028 } 1024 }
1029 } 1025 }