aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-09-26 11:33:28 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-07 11:11:36 -0400
commit42b28ac071a1a239d2a48965e9d6be0e061dd103 (patch)
tree5c3f001feee2da2a4d4818cc33b123190015e00b /tools
parent9d014020234525ae100879d71078a4bcb4849195 (diff)
perf hists: Stop using 'self' for struct hists
Stop using this python/OOP convention, doesn't really helps. Will do more from time to time till we get it cleaned up in all of /perf. Suggested-by: Thomas Gleixner <tglx@linutronix.de> 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-91i56jwnzq9edhsj9y2y9l3b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 677e1da6bb3..dd277897ff0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -18,56 +18,56 @@ struct callchain_param callchain_param = {
18 .order = ORDER_CALLEE 18 .order = ORDER_CALLEE
19}; 19};
20 20
21u16 hists__col_len(struct hists *self, enum hist_column col) 21u16 hists__col_len(struct hists *hists, enum hist_column col)
22{ 22{
23 return self->col_len[col]; 23 return hists->col_len[col];
24} 24}
25 25
26void hists__set_col_len(struct hists *self, enum hist_column col, u16 len) 26void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
27{ 27{
28 self->col_len[col] = len; 28 hists->col_len[col] = len;
29} 29}
30 30
31bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len) 31bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
32{ 32{
33 if (len > hists__col_len(self, col)) { 33 if (len > hists__col_len(hists, col)) {
34 hists__set_col_len(self, col, len); 34 hists__set_col_len(hists, col, len);
35 return true; 35 return true;
36 } 36 }
37 return false; 37 return false;
38} 38}
39 39
40static void hists__reset_col_len(struct hists *self) 40static void hists__reset_col_len(struct hists *hists)
41{ 41{
42 enum hist_column col; 42 enum hist_column col;
43 43
44 for (col = 0; col < HISTC_NR_COLS; ++col) 44 for (col = 0; col < HISTC_NR_COLS; ++col)
45 hists__set_col_len(self, col, 0); 45 hists__set_col_len(hists, col, 0);
46} 46}
47 47
48static void hists__calc_col_len(struct hists *self, struct hist_entry *h) 48static void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
49{ 49{
50 u16 len; 50 u16 len;
51 51
52 if (h->ms.sym) 52 if (h->ms.sym)
53 hists__new_col_len(self, HISTC_SYMBOL, h->ms.sym->namelen); 53 hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen);
54 else { 54 else {
55 const unsigned int unresolved_col_width = BITS_PER_LONG / 4; 55 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
56 56
57 if (hists__col_len(self, HISTC_DSO) < unresolved_col_width && 57 if (hists__col_len(hists, HISTC_DSO) < unresolved_col_width &&
58 !symbol_conf.col_width_list_str && !symbol_conf.field_sep && 58 !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
59 !symbol_conf.dso_list) 59 !symbol_conf.dso_list)
60 hists__set_col_len(self, HISTC_DSO, 60 hists__set_col_len(hists, HISTC_DSO,
61 unresolved_col_width); 61 unresolved_col_width);
62 } 62 }
63 63
64 len = thread__comm_len(h->thread); 64 len = thread__comm_len(h->thread);
65 if (hists__new_col_len(self, HISTC_COMM, len)) 65 if (hists__new_col_len(hists, HISTC_COMM, len))
66 hists__set_col_len(self, HISTC_THREAD, len + 6); 66 hists__set_col_len(hists, HISTC_THREAD, len + 6);
67 67
68 if (h->ms.map) { 68 if (h->ms.map) {
69 len = dso__name_len(h->ms.map->dso); 69 len = dso__name_len(h->ms.map->dso);
70 hists__new_col_len(self, HISTC_DSO, len); 70 hists__new_col_len(hists, HISTC_DSO, len);
71 } 71 }
72} 72}
73 73
@@ -113,11 +113,11 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
113 return self; 113 return self;
114} 114}
115 115
116static void hists__inc_nr_entries(struct hists *self, struct hist_entry *h) 116static void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
117{ 117{
118 if (!h->filtered) { 118 if (!h->filtered) {
119 hists__calc_col_len(self, h); 119 hists__calc_col_len(hists, h);
120 ++self->nr_entries; 120 ++hists->nr_entries;
121 } 121 }
122} 122}
123 123
@@ -128,11 +128,11 @@ static u8 symbol__parent_filter(const struct symbol *parent)
128 return 0; 128 return 0;
129} 129}
130 130
131struct hist_entry *__hists__add_entry(struct hists *self, 131struct hist_entry *__hists__add_entry(struct hists *hists,
132 struct addr_location *al, 132 struct addr_location *al,
133 struct symbol *sym_parent, u64 period) 133 struct symbol *sym_parent, u64 period)
134{ 134{
135 struct rb_node **p = &self->entries.rb_node; 135 struct rb_node **p = &hists->entries.rb_node;
136 struct rb_node *parent = NULL; 136 struct rb_node *parent = NULL;
137 struct hist_entry *he; 137 struct hist_entry *he;
138 struct hist_entry entry = { 138 struct hist_entry entry = {
@@ -172,8 +172,8 @@ struct hist_entry *__hists__add_entry(struct hists *self,
172 if (!he) 172 if (!he)
173 return NULL; 173 return NULL;
174 rb_link_node(&he->rb_node, parent, p); 174 rb_link_node(&he->rb_node, parent, p);
175 rb_insert_color(&he->rb_node, &self->entries); 175 rb_insert_color(&he->rb_node, &hists->entries);
176 hists__inc_nr_entries(self, he); 176 hists__inc_nr_entries(hists, he);
177out: 177out:
178 hist_entry__add_cpumode_period(he, al->cpumode, period); 178 hist_entry__add_cpumode_period(he, al->cpumode, period);
179 return he; 179 return he;
@@ -222,7 +222,7 @@ void hist_entry__free(struct hist_entry *he)
222 * collapse the histogram 222 * collapse the histogram
223 */ 223 */
224 224
225static bool hists__collapse_insert_entry(struct hists *self, 225static bool hists__collapse_insert_entry(struct hists *hists,
226 struct rb_root *root, 226 struct rb_root *root,
227 struct hist_entry *he) 227 struct hist_entry *he)
228{ 228{
@@ -240,8 +240,8 @@ static bool hists__collapse_insert_entry(struct hists *self,
240 if (!cmp) { 240 if (!cmp) {
241 iter->period += he->period; 241 iter->period += he->period;
242 if (symbol_conf.use_callchain) { 242 if (symbol_conf.use_callchain) {
243 callchain_cursor_reset(&self->callchain_cursor); 243 callchain_cursor_reset(&hists->callchain_cursor);
244 callchain_merge(&self->callchain_cursor, iter->callchain, 244 callchain_merge(&hists->callchain_cursor, iter->callchain,
245 he->callchain); 245 he->callchain);
246 } 246 }
247 hist_entry__free(he); 247 hist_entry__free(he);
@@ -259,7 +259,7 @@ static bool hists__collapse_insert_entry(struct hists *self,
259 return true; 259 return true;
260} 260}
261 261
262void hists__collapse_resort(struct hists *self) 262void hists__collapse_resort(struct hists *hists)
263{ 263{
264 struct rb_root tmp; 264 struct rb_root tmp;
265 struct rb_node *next; 265 struct rb_node *next;
@@ -269,20 +269,20 @@ void hists__collapse_resort(struct hists *self)
269 return; 269 return;
270 270
271 tmp = RB_ROOT; 271 tmp = RB_ROOT;
272 next = rb_first(&self->entries); 272 next = rb_first(&hists->entries);
273 self->nr_entries = 0; 273 hists->nr_entries = 0;
274 hists__reset_col_len(self); 274 hists__reset_col_len(hists);
275 275
276 while (next) { 276 while (next) {
277 n = rb_entry(next, struct hist_entry, rb_node); 277 n = rb_entry(next, struct hist_entry, rb_node);
278 next = rb_next(&n->rb_node); 278 next = rb_next(&n->rb_node);
279 279
280 rb_erase(&n->rb_node, &self->entries); 280 rb_erase(&n->rb_node, &hists->entries);
281 if (hists__collapse_insert_entry(self, &tmp, n)) 281 if (hists__collapse_insert_entry(hists, &tmp, n))
282 hists__inc_nr_entries(self, n); 282 hists__inc_nr_entries(hists, n);
283 } 283 }
284 284
285 self->entries = tmp; 285 hists->entries = tmp;
286} 286}
287 287
288/* 288/*
@@ -315,31 +315,31 @@ static void __hists__insert_output_entry(struct rb_root *entries,
315 rb_insert_color(&he->rb_node, entries); 315 rb_insert_color(&he->rb_node, entries);
316} 316}
317 317
318void hists__output_resort(struct hists *self) 318void hists__output_resort(struct hists *hists)
319{ 319{
320 struct rb_root tmp; 320 struct rb_root tmp;
321 struct rb_node *next; 321 struct rb_node *next;
322 struct hist_entry *n; 322 struct hist_entry *n;
323 u64 min_callchain_hits; 323 u64 min_callchain_hits;
324 324
325 min_callchain_hits = self->stats.total_period * (callchain_param.min_percent / 100); 325 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
326 326
327 tmp = RB_ROOT; 327 tmp = RB_ROOT;
328 next = rb_first(&self->entries); 328 next = rb_first(&hists->entries);
329 329
330 self->nr_entries = 0; 330 hists->nr_entries = 0;
331 hists__reset_col_len(self); 331 hists__reset_col_len(hists);
332 332
333 while (next) { 333 while (next) {
334 n = rb_entry(next, struct hist_entry, rb_node); 334 n = rb_entry(next, struct hist_entry, rb_node);
335 next = rb_next(&n->rb_node); 335 next = rb_next(&n->rb_node);
336 336
337 rb_erase(&n->rb_node, &self->entries); 337 rb_erase(&n->rb_node, &hists->entries);
338 __hists__insert_output_entry(&tmp, n, min_callchain_hits); 338 __hists__insert_output_entry(&tmp, n, min_callchain_hits);
339 hists__inc_nr_entries(self, n); 339 hists__inc_nr_entries(hists, n);
340 } 340 }
341 341
342 self->entries = tmp; 342 hists->entries = tmp;
343} 343}
344 344
345static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) 345static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
@@ -738,7 +738,7 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self,
738 left_margin); 738 left_margin);
739} 739}
740 740
741size_t hists__fprintf(struct hists *self, struct hists *pair, 741size_t hists__fprintf(struct hists *hists, struct hists *pair,
742 bool show_displacement, FILE *fp) 742 bool show_displacement, FILE *fp)
743{ 743{
744 struct sort_entry *se; 744 struct sort_entry *se;
@@ -803,15 +803,15 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
803 width = strlen(se->se_header); 803 width = strlen(se->se_header);
804 if (symbol_conf.col_width_list_str) { 804 if (symbol_conf.col_width_list_str) {
805 if (col_width) { 805 if (col_width) {
806 hists__set_col_len(self, se->se_width_idx, 806 hists__set_col_len(hists, se->se_width_idx,
807 atoi(col_width)); 807 atoi(col_width));
808 col_width = strchr(col_width, ','); 808 col_width = strchr(col_width, ',');
809 if (col_width) 809 if (col_width)
810 ++col_width; 810 ++col_width;
811 } 811 }
812 } 812 }
813 if (!hists__new_col_len(self, se->se_width_idx, width)) 813 if (!hists__new_col_len(hists, se->se_width_idx, width))
814 width = hists__col_len(self, se->se_width_idx); 814 width = hists__col_len(hists, se->se_width_idx);
815 fprintf(fp, " %*s", width, se->se_header); 815 fprintf(fp, " %*s", width, se->se_header);
816 } 816 }
817 fprintf(fp, "\n"); 817 fprintf(fp, "\n");
@@ -834,7 +834,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
834 continue; 834 continue;
835 835
836 fprintf(fp, " "); 836 fprintf(fp, " ");
837 width = hists__col_len(self, se->se_width_idx); 837 width = hists__col_len(hists, se->se_width_idx);
838 if (width == 0) 838 if (width == 0)
839 width = strlen(se->se_header); 839 width = strlen(se->se_header);
840 for (i = 0; i < width; i++) 840 for (i = 0; i < width; i++)
@@ -844,7 +844,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
844 fprintf(fp, "\n#\n"); 844 fprintf(fp, "\n#\n");
845 845
846print_entries: 846print_entries:
847 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 847 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
848 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 848 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
849 849
850 if (h->filtered) 850 if (h->filtered)
@@ -858,12 +858,12 @@ print_entries:
858 displacement = 0; 858 displacement = 0;
859 ++position; 859 ++position;
860 } 860 }
861 ret += hist_entry__fprintf(h, self, pair, show_displacement, 861 ret += hist_entry__fprintf(h, hists, pair, show_displacement,
862 displacement, fp, self->stats.total_period); 862 displacement, fp, hists->stats.total_period);
863 863
864 if (symbol_conf.use_callchain) 864 if (symbol_conf.use_callchain)
865 ret += hist_entry__fprintf_callchain(h, self, fp, 865 ret += hist_entry__fprintf_callchain(h, hists, fp,
866 self->stats.total_period); 866 hists->stats.total_period);
867 if (h->ms.map == NULL && verbose > 1) { 867 if (h->ms.map == NULL && verbose > 1) {
868 __map_groups__fprintf_maps(&h->thread->mg, 868 __map_groups__fprintf_maps(&h->thread->mg,
869 MAP__FUNCTION, verbose, fp); 869 MAP__FUNCTION, verbose, fp);
@@ -879,7 +879,7 @@ print_entries:
879/* 879/*
880 * See hists__fprintf to match the column widths 880 * See hists__fprintf to match the column widths
881 */ 881 */
882unsigned int hists__sort_list_width(struct hists *self) 882unsigned int hists__sort_list_width(struct hists *hists)
883{ 883{
884 struct sort_entry *se; 884 struct sort_entry *se;
885 int ret = 9; /* total % */ 885 int ret = 9; /* total % */
@@ -898,7 +898,7 @@ unsigned int hists__sort_list_width(struct hists *self)
898 898
899 list_for_each_entry(se, &hist_entry__sort_list, list) 899 list_for_each_entry(se, &hist_entry__sort_list, list)
900 if (!se->elide) 900 if (!se->elide)
901 ret += 2 + hists__col_len(self, se->se_width_idx); 901 ret += 2 + hists__col_len(hists, se->se_width_idx);
902 902
903 if (verbose) /* Addr + origin */ 903 if (verbose) /* Addr + origin */
904 ret += 3 + BITS_PER_LONG / 4; 904 ret += 3 + BITS_PER_LONG / 4;
@@ -906,32 +906,32 @@ unsigned int hists__sort_list_width(struct hists *self)
906 return ret; 906 return ret;
907} 907}
908 908
909static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h, 909static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
910 enum hist_filter filter) 910 enum hist_filter filter)
911{ 911{
912 h->filtered &= ~(1 << filter); 912 h->filtered &= ~(1 << filter);
913 if (h->filtered) 913 if (h->filtered)
914 return; 914 return;
915 915
916 ++self->nr_entries; 916 ++hists->nr_entries;
917 if (h->ms.unfolded) 917 if (h->ms.unfolded)
918 self->nr_entries += h->nr_rows; 918 hists->nr_entries += h->nr_rows;
919 h->row_offset = 0; 919 h->row_offset = 0;
920 self->stats.total_period += h->period; 920 hists->stats.total_period += h->period;
921 self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events; 921 hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
922 922
923 hists__calc_col_len(self, h); 923 hists__calc_col_len(hists, h);
924} 924}
925 925
926void hists__filter_by_dso(struct hists *self, const struct dso *dso) 926void hists__filter_by_dso(struct hists *hists, const struct dso *dso)
927{ 927{
928 struct rb_node *nd; 928 struct rb_node *nd;
929 929
930 self->nr_entries = self->stats.total_period = 0; 930 hists->nr_entries = hists->stats.total_period = 0;
931 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; 931 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
932 hists__reset_col_len(self); 932 hists__reset_col_len(hists);
933 933
934 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 934 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
935 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 935 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
936 936
937 if (symbol_conf.exclude_other && !h->parent) 937 if (symbol_conf.exclude_other && !h->parent)
@@ -942,19 +942,19 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso)
942 continue; 942 continue;
943 } 943 }
944 944
945 hists__remove_entry_filter(self, h, HIST_FILTER__DSO); 945 hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
946 } 946 }
947} 947}
948 948
949void hists__filter_by_thread(struct hists *self, const struct thread *thread) 949void hists__filter_by_thread(struct hists *hists, const struct thread *thread)
950{ 950{
951 struct rb_node *nd; 951 struct rb_node *nd;
952 952
953 self->nr_entries = self->stats.total_period = 0; 953 hists->nr_entries = hists->stats.total_period = 0;
954 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; 954 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
955 hists__reset_col_len(self); 955 hists__reset_col_len(hists);
956 956
957 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 957 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
958 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 958 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
959 959
960 if (thread != NULL && h->thread != thread) { 960 if (thread != NULL && h->thread != thread) {
@@ -962,7 +962,7 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread)
962 continue; 962 continue;
963 } 963 }
964 964
965 hists__remove_entry_filter(self, h, HIST_FILTER__THREAD); 965 hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
966 } 966 }
967} 967}
968 968
@@ -976,13 +976,13 @@ int hist_entry__annotate(struct hist_entry *he, size_t privsize)
976 return symbol__annotate(he->ms.sym, he->ms.map, privsize); 976 return symbol__annotate(he->ms.sym, he->ms.map, privsize);
977} 977}
978 978
979void hists__inc_nr_events(struct hists *self, u32 type) 979void hists__inc_nr_events(struct hists *hists, u32 type)
980{ 980{
981 ++self->stats.nr_events[0]; 981 ++hists->stats.nr_events[0];
982 ++self->stats.nr_events[type]; 982 ++hists->stats.nr_events[type];
983} 983}
984 984
985size_t hists__fprintf_nr_events(struct hists *self, FILE *fp) 985size_t hists__fprintf_nr_events(struct hists *hists, FILE *fp)
986{ 986{
987 int i; 987 int i;
988 size_t ret = 0; 988 size_t ret = 0;
@@ -990,7 +990,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
990 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { 990 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
991 const char *name; 991 const char *name;
992 992
993 if (self->stats.nr_events[i] == 0) 993 if (hists->stats.nr_events[i] == 0)
994 continue; 994 continue;
995 995
996 name = perf_event__name(i); 996 name = perf_event__name(i);
@@ -998,7 +998,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
998 continue; 998 continue;
999 999
1000 ret += fprintf(fp, "%16s events: %10d\n", name, 1000 ret += fprintf(fp, "%16s events: %10d\n", name,
1001 self->stats.nr_events[i]); 1001 hists->stats.nr_events[i]);
1002 } 1002 }
1003 1003
1004 return ret; 1004 return ret;