]> nv-tegra.nvidia Code Review - linux-3.10.git/commitdiff
perf hists browser: Invalidate ui_browser->top after timer calls
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 14 Oct 2011 12:31:53 +0000 (09:31 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 14 Oct 2011 15:48:14 +0000 (12:48 -0300)
With underlying dynamic data structures we need to invalidate pointers
to them after a timer, as that entry may have vanished (decayed in top,
for instance).

I forgot about browser_ui->top. Fix it by resetting it to null after a
timer. The seek operation from SEEK_SET will then set it to a valid
entry because it starts from rb_first(&hists->entries).

Reported-by: Ingo Molnar <mingo@elte.hu>
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-2ssjm0ouh9tsz4dwkcu7c40n@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/ui/browser.c
tools/perf/util/ui/browsers/hists.c

index 2923c493fb6ad20c0ffa7e91a628c399544841a7..078ceaf5f8c108930398b87cfd2df72222adc22e 100644 (file)
@@ -249,6 +249,7 @@ void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries)
                browser->top_idx += offset;
        }
 
+       browser->top = NULL;
        browser->seek(browser, browser->top_idx, SEEK_SET);
 }
 
index 4a3a7c96b9b630d9f52bcbe3c57502880cb1d738..b144b108029a120cd2388f85993370c1579c6526 100644 (file)
@@ -600,14 +600,23 @@ static int hist_browser__show_entry(struct hist_browser *self,
        return printed;
 }
 
+static void ui_browser__hists_init_top(struct ui_browser *browser)
+{
+       if (browser->top == NULL) {
+               struct hist_browser *hb;
+
+               hb = container_of(browser, struct hist_browser, b);
+               browser->top = rb_first(&hb->hists->entries);
+       }
+}
+
 static unsigned int hist_browser__refresh(struct ui_browser *self)
 {
        unsigned row = 0;
        struct rb_node *nd;
        struct hist_browser *hb = container_of(self, struct hist_browser, b);
 
-       if (self->top == NULL)
-               self->top = rb_first(&hb->hists->entries);
+       ui_browser__hists_init_top(self);
 
        for (nd = self->top; nd; nd = rb_next(nd)) {
                struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
@@ -659,6 +668,8 @@ static void ui_browser__hists_seek(struct ui_browser *self,
        if (self->nr_entries == 0)
                return;
 
+       ui_browser__hists_init_top(self);
+
        switch (whence) {
        case SEEK_SET:
                nd = hists__filter_entries(rb_first(self->entries));