aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c10
-rw-r--r--tools/perf/util/sort.h1
-rw-r--r--tools/perf/util/ui/browsers/hists.c6
3 files changed, 14 insertions, 3 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 50c8fece1681..9b9d12bbdc1d 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -100,6 +100,8 @@ static void hist_entry__decay(struct hist_entry *he)
100 100
101static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) 101static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
102{ 102{
103 if (he->period == 0)
104 return true;
103 hists->stats.total_period -= he->period; 105 hists->stats.total_period -= he->period;
104 hist_entry__decay(he); 106 hist_entry__decay(he);
105 hists->stats.total_period += he->period; 107 hists->stats.total_period += he->period;
@@ -114,8 +116,12 @@ void hists__decay_entries(struct hists *hists)
114 while (next) { 116 while (next) {
115 n = rb_entry(next, struct hist_entry, rb_node); 117 n = rb_entry(next, struct hist_entry, rb_node);
116 next = rb_next(&n->rb_node); 118 next = rb_next(&n->rb_node);
117 119 /*
118 if (hists__decay_entry(hists, n)) { 120 * We may be annotating this, for instance, so keep it here in
121 * case some it gets new samples, we'll eventually free it when
122 * the user stops browsing and it agains gets fully decayed.
123 */
124 if (hists__decay_entry(hists, n) && !n->used) {
119 rb_erase(&n->rb_node, &hists->entries); 125 rb_erase(&n->rb_node, &hists->entries);
120 126
121 if (sort__need_collapse) 127 if (sort__need_collapse)
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 03851e301721..3f67ae395752 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -64,6 +64,7 @@ struct hist_entry {
64 64
65 bool init_have_children; 65 bool init_have_children;
66 char level; 66 char level;
67 bool used;
67 u8 filtered; 68 u8 filtered;
68 struct symbol *parent; 69 struct symbol *parent;
69 union { 70 union {
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 9ece84353538..fdc3c90696dc 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -976,9 +976,13 @@ do_annotate:
976 he = hist_browser__selected_entry(browser); 976 he = hist_browser__selected_entry(browser);
977 if (he == NULL) 977 if (he == NULL)
978 continue; 978 continue;
979 979 /*
980 * Don't let this be freed, say, by hists__decay_entry.
981 */
982 he->used = true;
980 hist_entry__tui_annotate(he, evsel->idx, nr_events, 983 hist_entry__tui_annotate(he, evsel->idx, nr_events,
981 timer, arg, delay_secs); 984 timer, arg, delay_secs);
985 he->used = false;
982 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); 986 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
983 } else if (choice == browse_map) 987 } else if (choice == browse_map)
984 map__browse(browser->selection->map); 988 map__browse(browser->selection->map);