aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-13 08:06:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-13 09:29:17 -0400
commite345fa185ad805cbd3be3397b3cba32bc42ef571 (patch)
treeaa548f1267b6ecf63f22cd036c75b28a5be375f6
parented7e5662ddff6a60bdae830ff65547c2eeed6f9a (diff)
perf top: Remove entries from entries_collapsed on decay
We were removing only when using a --sort order that needs collapsing, while we also use it in the threaded case, causing memory corruption because we were scribbling freed hist entries, oops. 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-k16fb4jsulr7x0ixv43amb6d@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-top.c4
-rw-r--r--tools/perf/util/hist.c14
-rw-r--r--tools/perf/util/hist.h1
3 files changed, 15 insertions, 4 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index de3cb1e00f9e..e211304a0dd7 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -304,7 +304,7 @@ static void print_sym_table(void)
304 304
305 hists__collapse_resort_threaded(&top.sym_evsel->hists); 305 hists__collapse_resort_threaded(&top.sym_evsel->hists);
306 hists__output_resort_threaded(&top.sym_evsel->hists); 306 hists__output_resort_threaded(&top.sym_evsel->hists);
307 hists__decay_entries(&top.sym_evsel->hists); 307 hists__decay_entries_threaded(&top.sym_evsel->hists);
308 hists__output_recalc_col_len(&top.sym_evsel->hists, winsize.ws_row - 3); 308 hists__output_recalc_col_len(&top.sym_evsel->hists, winsize.ws_row - 3);
309 putchar('\n'); 309 putchar('\n');
310 hists__fprintf(&top.sym_evsel->hists, NULL, false, false, 310 hists__fprintf(&top.sym_evsel->hists, NULL, false, false,
@@ -555,7 +555,7 @@ static void perf_top__sort_new_samples(void *arg)
555 555
556 hists__collapse_resort_threaded(&t->sym_evsel->hists); 556 hists__collapse_resort_threaded(&t->sym_evsel->hists);
557 hists__output_resort_threaded(&t->sym_evsel->hists); 557 hists__output_resort_threaded(&t->sym_evsel->hists);
558 hists__decay_entries(&t->sym_evsel->hists); 558 hists__decay_entries_threaded(&t->sym_evsel->hists);
559 hists__output_recalc_col_len(&t->sym_evsel->hists, winsize.ws_row - 3); 559 hists__output_recalc_col_len(&t->sym_evsel->hists, winsize.ws_row - 3);
560} 560}
561 561
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 9b9d12bbdc1d..a7193c5a0422 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -108,7 +108,7 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
108 return he->period == 0; 108 return he->period == 0;
109} 109}
110 110
111void hists__decay_entries(struct hists *hists) 111static void __hists__decay_entries(struct hists *hists, bool threaded)
112{ 112{
113 struct rb_node *next = rb_first(&hists->entries); 113 struct rb_node *next = rb_first(&hists->entries);
114 struct hist_entry *n; 114 struct hist_entry *n;
@@ -124,7 +124,7 @@ void hists__decay_entries(struct hists *hists)
124 if (hists__decay_entry(hists, n) && !n->used) { 124 if (hists__decay_entry(hists, n) && !n->used) {
125 rb_erase(&n->rb_node, &hists->entries); 125 rb_erase(&n->rb_node, &hists->entries);
126 126
127 if (sort__need_collapse) 127 if (sort__need_collapse || threaded)
128 rb_erase(&n->rb_node_in, &hists->entries_collapsed); 128 rb_erase(&n->rb_node_in, &hists->entries_collapsed);
129 129
130 hist_entry__free(n); 130 hist_entry__free(n);
@@ -133,6 +133,16 @@ void hists__decay_entries(struct hists *hists)
133 } 133 }
134} 134}
135 135
136void hists__decay_entries(struct hists *hists)
137{
138 return __hists__decay_entries(hists, false);
139}
140
141void hists__decay_entries_threaded(struct hists *hists)
142{
143 return __hists__decay_entries(hists, true);
144}
145
136/* 146/*
137 * histogram, sorted on item, collects periods 147 * histogram, sorted on item, collects periods
138 */ 148 */
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 7416521f7fea..bcc8ab91e26f 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -79,6 +79,7 @@ void hists__collapse_resort(struct hists *self);
79void hists__collapse_resort_threaded(struct hists *hists); 79void hists__collapse_resort_threaded(struct hists *hists);
80 80
81void hists__decay_entries(struct hists *hists); 81void hists__decay_entries(struct hists *hists);
82void hists__decay_entries_threaded(struct hists *hists);
82void hists__output_recalc_col_len(struct hists *hists, int max_rows); 83void hists__output_recalc_col_len(struct hists *hists, int max_rows);
83 84
84void hists__inc_nr_events(struct hists *self, u32 type); 85void hists__inc_nr_events(struct hists *self, u32 type);