aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/ui/browsers/top.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/util/ui/browsers/top.c b/tools/perf/util/ui/browsers/top.c
index 377ff58c9ae9..2f47224426b6 100644
--- a/tools/perf/util/ui/browsers/top.c
+++ b/tools/perf/util/ui/browsers/top.c
@@ -70,6 +70,7 @@ static void perf_top_browser__write(struct ui_browser *browser, void *entry, int
70static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser) 70static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser)
71{ 71{
72 struct perf_top *top = browser->b.priv; 72 struct perf_top *top = browser->b.priv;
73 u64 top_idx = browser->b.top_idx;
73 74
74 browser->root = RB_ROOT; 75 browser->root = RB_ROOT;
75 browser->b.top = NULL; 76 browser->b.top = NULL;
@@ -82,7 +83,29 @@ static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser)
82 if (browser->sym_width + browser->dso_width > browser->b.width - 29) 83 if (browser->sym_width + browser->dso_width > browser->b.width - 29)
83 browser->sym_width = browser->b.width - browser->dso_width - 29; 84 browser->sym_width = browser->b.width - browser->dso_width - 29;
84 } 85 }
86
87 /*
88 * Adjust the ui_browser indexes since the entries in the browser->root
89 * rb_tree may have changed, then seek it from start, so that we get a
90 * possible new top of the screen.
91 */
85 browser->b.nr_entries = top->rb_entries; 92 browser->b.nr_entries = top->rb_entries;
93
94 if (top_idx >= browser->b.nr_entries) {
95 if (browser->b.height >= browser->b.nr_entries)
96 top_idx = browser->b.nr_entries - browser->b.height;
97 else
98 top_idx = 0;
99 }
100
101 if (browser->b.index >= top_idx + browser->b.height)
102 browser->b.index = top_idx + browser->b.index - browser->b.top_idx;
103
104 if (browser->b.index >= browser->b.nr_entries)
105 browser->b.index = browser->b.nr_entries - 1;
106
107 browser->b.top_idx = top_idx;
108 browser->b.seek(&browser->b, top_idx, SEEK_SET);
86} 109}
87 110
88static void perf_top_browser__annotate(struct perf_top_browser *browser) 111static void perf_top_browser__annotate(struct perf_top_browser *browser)