perf annotate: Fix annotate context lines regression
Commit-ID: d5e3d747007fdb541e57ed72e020ff0b94db3470 Gitweb: http://git.kernel.org/tip/d5e3d747007fdb541e57ed72e020ff0b94db3470 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 8 Feb 2011 15:29:25 -0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 8 Feb 2011 15:29:25 -0200
perf annotate: Fix annotate context lines regression
The live annotation done in 'perf top' needs to limit the context before lines that aren't filtered out by the min percent filter, if we don't do that, the screen in a tty often is not enough for showing what is
interesting: lines with hits and a few source code lines before it.
LKML-Reference: <new-submission>
--- tools/perf/builtin-top.c | 2 +- tools/perf/util/annotate.c | 47 +++++++++++++++++++++++++++++++++++++------ tools/perf/util/annotate.h | 3 +- 3 files changed, 43 insertions(+), 9 deletions(-)
tools/perf/builtin-top.c +1 -1
@@ -231,7 +231,7 @@ static void show_details(struct sym_entry *syme)printf (" Events Pcnt (>=%d%%)\n" , sym_pcnt_filter); more =symbol__annotate_printf (symbol, syme->map, top.sym_evsel->idx, -0 , sym_pcnt_filter, top.print_entries); +0 , sym_pcnt_filter, top.print_entries,4 );if (top.zero)symbol__annotate_zero_histogram (symbol, top.sym_evsel->idx);else
tools/perf/util/annotate.c +40 -7
96 lines not on this page · raw message
tools/perf/util/annotate.h +2 -1
@@ -78,7 +78,8 @@ void symbol__annotate_zero_histograms(struct symbol *sym);int symbol__annotate (struct symbol *sym,struct map *map,size_t privsize);int symbol__annotate_init (struct map *map__used ,struct symbol *sym);int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx, -bool full_paths,int min_pcnt,int max_lines); +bool full_paths,int min_pcnt,int max_lines, +int context);void symbol__annotate_zero_histogram (struct symbol *sym,int evidx);void symbol__annotate_decay_histogram (struct symbol *sym,int evidx);void objdump_line_list__purge (struct list_head *head);
Quoted 7 lines · tip-bot for Arnaldo Carvalho de Melo
Commit-ID: d5e3d747007fdb541e57ed72e020ff0b94db3470 Gitweb: http://git.kernel.org/tip/d5e3d747007fdb541e57ed72e020ff0b94db3470 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 8 Feb 2011 15:29:25 -0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 8 Feb 2011 15:29:25 -0200
Quoted 6 lines
perf annotate: Fix annotate context lines regression
The live annotation done in 'perf top' needs to limit the context before lines that aren't filtered out by the min percent filter, if we don't do that, the screen in a tty often is not enough for showing what is
interesting: lines with hits and a few source code lines before it.
Looks to me like this went from regress a bit while waiting for tui thing to progress a bit immediately :)
-Mike
Em Wed, Feb 09, 2011 at 05:06:18AM +0100, Mike Galbraith escreveu:
Quoted 6 lines
On Wed, 2011-02-09 at 00:43 +0000, tip-bot for Arnaldo Carvalho de Melo wrote
Quoted 5 lines
Gitweb: http://git.kernel.org/tip/d5e3d747007fdb541e57ed72e020ff0b94db3470 Author: Arnaldo Carvalho de Melo <[email protected]>perf annotate: Fix annotate context lines regression
Quoted 7 lines
Quoted 4 lines
The live annotation done in 'perf top' needs to limit the context before lines that aren't filtered out by the min percent filter, if we don't do that, the screen in a tty often is not enough for showing what is
interesting: lines with hits and a few source code lines before it.Looks to me like this went from regress a bit while waiting for tui thing to progress a bit immediately :)
:-) Can you please apply the two patches and give 'perf top --tui' live annotation a shot? Just press enter or -> (right key) on a symbol you want to annotate.
I'm still polishing it a bit, want to avoid trying the notes->lock on each time record_precise_ip is called, for that I need to share the current symbol being annotated (sym_filter_entry) with the annotate browser, the timer should not always run, etc, but just so that I can get some feedback on how it is shaping up, please try it and report your impressions :-)
Also when enter is pressed and one is monitoring multiple events, a popup menu with the event names should be presented, etc.
- Arnaldo
Quoted 1 line
From
c11a24e210b10543a29258f1b86918bb3f15092fMon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 9 Feb 2011 11:38:43 -0200
Subject: [PATCH 1/1] perf ui: Serialize screen updates
The ui operations so far were used by just one thread, but 'perf top --tui' now has two threads updating the screen, so we need to use a mutex to avoid garbling the screen.
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <new-submission>
--- tools/perf/Makefile | 1 + tools/perf/util/ui/browser.c | 7 +++++++ tools/perf/util/ui/helpline.c | 5 ++++- tools/perf/util/ui/libslang.h | 1 + tools/perf/util/ui/setup.c | 3 +++ tools/perf/util/ui/ui.h | 8 ++++++++ 6 files changed, 24 insertions(+), 1 deletions(-) create mode 100644 tools/perf/util/ui/ui.h
tools/perf/Makefile +1 -0
@@ -635,6 +635,7 @@ else LIB_H += util/ui/libslang.h LIB_H += util/ui/progress.h LIB_H += util/ui/util.h + LIB_H += util/ui/ui.h endif endif
tools/perf/util/ui/browser.c +7 -0
@@ -1,4 +1,5 @@#include "libslang.h" +#include "ui.h" #include <linux/compiler.h> #include <linux/list.h> #include <linux/rbtree.h>
@@ -178,6 +179,7 @@ int ui_browser__show(struct ui_browser *self, const char *title,if (self->sb ==NULL )return -1 ; +pthread_mutex_lock (&ui__lock);SLsmg_gotorc (0 ,0 );ui_browser__set_color (self,NEWT_COLORSET_ROOT );slsmg_write_nstring (title, self->width);
@@ -188,25 +190,30 @@ int ui_browser__show(struct ui_browser *self, const char *title,va_start (ap, helpline);ui_helpline__vpush (helpline, ap);va_end (ap); +pthread_mutex_unlock (&ui__lock);return 0 ; }void ui_browser__hide (struct ui_browser *self) { +pthread_mutex_lock (&ui__lock);newtFormDestroy (self->form); self->form =NULL ;ui_helpline__pop (); +pthread_mutex_unlock (&ui__lock); }int ui_browser__refresh (struct ui_browser *self) {int row; +pthread_mutex_lock (&ui__lock);newtScrollbarSet (self->sb, self->index, self->nr_entries -1 ); row = self->refresh (self);ui_browser__set_color (self,HE_COLORSET_NORMAL );SLsmg_fill_region (self->y + row, self->x, self->height - row, self->width,' ' ); +pthread_mutex_unlock (&ui__lock);return 0 ; }
tools/perf/util/ui/helpline.c +4 -1
@@ -5,6 +5,7 @@#include "../debug.h" #include "helpline.h" +#include "ui.h" void ui_helpline__pop (void ) {
@@ -55,7 +56,8 @@ int ui_helpline__show_help(const char *format, va_list ap)int ret;static int backlog; - ret =vsnprintf (ui_helpline__last_msg + backlog, +pthread_mutex_lock (&ui__lock); + ret =vsnprintf (ui_helpline__last_msg + backlog,sizeof (ui_helpline__last_msg) - backlog, format, ap); backlog += ret;
@@ -64,6 +66,7 @@ int ui_helpline__show_help(const char *format, va_list ap)newtRefresh (); backlog =0 ; } +pthread_mutex_unlock (&ui__lock);return ret; }
tools/perf/util/ui/libslang.h +1 -0
@@ -1,5 +1,6 @@#ifndef _PERF_UI_SLANG_H_#define _PERF_UI_SLANG_H_ 1 +/* * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks * the build if it isn't defined. Use the equivalent one that glibc
tools/perf/util/ui/setup.c +3 -0
@@ -6,6 +6,9 @@#include "../debug.h" #include "browser.h" #include "helpline.h" +#include "ui.h" + +pthread_mutex_t ui__lock =PTHREAD_MUTEX_INITIALIZER ;static void newt_suspend (void *d__used ) {
tools/perf/util/ui/ui.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _PERF_UI_H_ +#define _PERF_UI_H_ 1 + +#include <pthread.h> + +extern pthread_mutex_t ui__lock; + +#endif /* _PERF_UI_H_ */
Signature · 1 line
1.7.1
tools/perf/builtin-top.c +3 -4
@@ -195,18 +195,17 @@ static void record_precise_ip(struct sym_entry *syme, int counter, u64 ip)struct annotation *notes;struct symbol *sym; -if (syme != sym_filter_entry) -return ; - sym =sym_entry__symbol (syme); notes =symbol__annotation (sym);if (pthread_mutex_trylock (¬es->lock))return ; +if (notes->src ==NULL ) + goto out_unlock; ip = syme->map->map_ip (syme->map, ip);symbol__inc_addr_samples (sym, syme->map, counter, ip); - +out_unlock:pthread_mutex_unlock (¬es->lock); }
tools/perf/util/ui/browsers/annotate.c +64 -28
157 lines not on this page · raw message
tools/perf/util/ui/browsers/top.c +38 -1
@@ -7,6 +7,7 @@* Released under the GPL v2. (and only v2, not any later version) */ #include "../browser.h" +#include "../../annotate.h" #include "../helpline.h" #include "../libslang.h" #include "../../evlist.h"
@@ -18,6 +19,7 @@struct perf_top_browser {struct ui_browser b;struct rb_root root; +struct sym_entry *selection;float sum_ksamples;int dso_width;int dso_short_width;
@@ -60,6 +62,9 @@ static void perf_top_browser__write(struct ui_browser *browser, void *entry, intslsmg_write_nstring (width >= syme->map->dso->long_name_len ? syme->map->dso->long_name : syme->map->dso->short_name, width); + +if (current_entry) + top_browser->selection = syme; }static void perf_top_browser__update_rb_tree (struct perf_top_browser *browser)
@@ -80,12 +85,39 @@ static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser) browser->b.nr_entries = top->rb_entries; } +static void perf_top_browser__annotate (struct perf_top_browser *browser) +{ +struct sym_entry *syme = browser->selection; +struct symbol *sym =sym_entry__symbol (syme); +struct annotation *notes =symbol__annotation (sym); +struct perf_top *top = browser->b.priv; + +if (notes->src !=NULL ) { +pthread_mutex_lock (¬es->lock); + goto do_annotation; + } + +pthread_mutex_lock (¬es->lock); + +if (symbol__alloc_hist (sym, top->evlist->nr_entries) <0 ) { +pr_err ("Not enough memory for annotating '%s' symbol!\n" , + sym->name); +pthread_mutex_unlock (¬es->lock); +return ; + } + +pthread_mutex_unlock (¬es->lock); +do_annotation: +symbol__tui_annotate (sym, syme->map,0 ); +} +static int perf_top_browser__run (struct perf_top_browser *browser) {int key;char title[160 ];struct perf_top *top = browser->b.priv;int delay_msecs = top->delay_secs *1000 ; +int exit_keys[] = {'a' ,NEWT_KEY_ENTER ,NEWT_KEY_RIGHT ,0 , };perf_top_browser__update_rb_tree (browser);perf_top__header_snprintf (top, title,sizeof (title));
@@ -95,6 +127,7 @@ static int perf_top_browser__run(struct perf_top_browser *browser)return -1 ;newtFormSetTimer (browser->b.form, delay_msecs); +ui_browser__add_exit_keys (&browser->b, exit_keys);while (1 ) { key =ui_browser__run (&browser->b);
@@ -109,7 +142,11 @@ static int perf_top_browser__run(struct perf_top_browser *browser)SLsmg_gotorc (0 ,0 );slsmg_write_nstring (title, browser->b.width);break ; -case NEWT_KEY_TAB : +case NEWT_KEY_RIGHT : +case NEWT_KEY_ENTER : +if (browser->selection) +perf_top_browser__annotate (browser); +break ;default : goto out; }
Quoted 19 lines · Arnaldo Carvalho de Melo
Em Wed, Feb 09, 2011 at 05:06:18AM +0100, Mike Galbraith escreveu:
Quoted 6 lines
On Wed, 2011-02-09 at 00:43 +0000, tip-bot for Arnaldo Carvalho de Melo wrote
Quoted 5 lines
Gitweb: http://git.kernel.org/tip/d5e3d747007fdb541e57ed72e020ff0b94db3470 Author: Arnaldo Carvalho de Melo <[email protected]>perf annotate: Fix annotate context lines regression
Quoted 7 lines
Quoted 4 lines
The live annotation done in 'perf top' needs to limit the context before lines that aren't filtered out by the min percent filter, if we don't do that, the screen in a tty often is not enough for showing what is
interesting: lines with hits and a few source code lines before it.Looks to me like this went from regress a bit while waiting for tui thing to progress a bit immediately :)
:-) Can you please apply the two patches and give 'perf top --tui' live annotation a shot? Just press enter or -> (right key) on a symbol you want to annotate.
Quoted 6 lines
I'm still polishing it a bit, want to avoid trying the
notes->lockon each timerecord_precise_ipis called, for that I need to share the current symbol being annotated (sym_filter_entry) with the annotate browser, the timer should not always run, etc, but just so that I can get some feedback on how it is shaping up, please try it and report your impressions :-)
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help
with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
I managed to lock it up once, but shiny new gizmos usually do hiccup.
-Mike
Quoted 2 lines · Mike Galbraith
I like this a lot, great for live rummaging. One thing that would help
with large files maybe - a jump to next spot hotter than N%, but as is
(and callgraphs, and a snapshot logger with notes insertion and and... boy, tui thingy adds a _lot_ of potential to top:)
perf annotate: new TUI features
Em Thu, Feb 10, 2011 at 04:51:31AM +0100, Mike Galbraith escreveu:
Quoted 6 lines · Mike Galbraith
Quoted 3 lines
I like this a lot, great for live rummaging. One thing that would help
with large files maybe - a jump to next spot hotter than N%, but as is(and callgraphs, and a snapshot logger with notes insertion and and...
Right, when testing the top TUI I keep trying to use the same menu we have on the report, to filter by DSO or thread (the Zoom/Unzoom operations in report TUI).
So eventually I want to get that struct sym_entry used by top merged with hist_entry, used by report, in an efficient fashion, so that we can merge all these interfaces.
Live callgraphs if one presses enter on a annotate line seems like a nice thing to have, indeed, exactly as we have statically in the perf report TUI :)
Quoted 1 line
boy, tui thingy adds a _lot_ of potential to top:)
Yeah, and all the work done to have it working on a TUI paves the way for a GUI, but I want to have the TUI streamlined first, so that the GUI becomes just a boilerplatish matter :-)
- Arnaldo
Quoted 6 lines · Mike Galbraith
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
I managed to lock it up once, but shiny new gizmos usually do hiccup.
The TUI locked up or the kernel? If it's the TUI then a gdb dump of the lockup would be nice.
Thanks,
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 6 lines · Mike Galbraith
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
I managed to lock it up once, but shiny new gizmos usually do hiccup.
The TUI locked up or the kernel? If it's the TUI then a gdb dump of the lockup would be nice.
TUI stopped responding to my key poking. I'll see if it'll repeat (weekend).
-Mike
Em Thu, Feb 10, 2011 at 01:43:31PM +0100, Mike Galbraith escreveu:
Quoted 7 lines · Ingo Molnar
Quoted 6 lines · Mike Galbraith
Quoted 5 lines
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
It already does that if you use TAB/shift-TAB, first one goes to the hottest line, next one to the 2nd place, etc, shift-TAB goes the other direction.
There are some problems with that as on the first snapshot, just after parsing the sources, all lines have zero hits, I plan to fix that doing something like 'top' does, which is to wait a bit, say 2 seconds collecting samples, then show the annotation centered on the hottest line so far.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I managed to lock it up once, but shiny new gizmos usually do hiccup.
The TUI locked up or the kernel? If it's the TUI then a gdb dump of the lockup would be nice.
TUI stopped responding to my key poking. I'll see if it'll repeat (weekend).
Probably is something I already noticed and fixed, some mutex lock inbalance, I'll repost it soon.
- Arnaldo
Quoted 4 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 10, 2011 at 01:43:31PM +0100, Mike Galbraith escreveu:
Quoted 3 lines · Ingo Molnar
Quoted 2 lines · Mike Galbraith
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
It already does that if you use TAB/shift-TAB, first one goes to the hottest line, next one to the 2nd place, etc, shift-TAB goes the other direction.
A minor request: could we also make it an intuitive shift+arrow-keys thing as well perhaps? I.e. Shift will 'modify' the meaning of regular navigation of the lines from 'next' to 'next highest', etc.
Thanks,
Ingo
Quoted 4 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 10, 2011 at 01:43:31PM +0100, Mike Galbraith escreveu:
Quoted 3 lines · Ingo Molnar
Quoted 2 lines · Mike Galbraith
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Initial impression: can I have a pony too? :)
I like this a lot, great for live rummaging. One thing that would help with large files maybe - a jump to next spot hotter than N%, but as is is quite nice.
It already does that if you use TAB/shift-TAB, first one goes to the hottest line, next one to the 2nd place, etc, shift-TAB goes the other direction.
Cool, exactly what I was thinking. Intuitive already built in, I just didn't know it.
Quoted 5 lines
There are some problems with that as on the first snapshot, just after parsing the sources, all lines have zero hits, I plan to fix that doing something like 'top' does, which is to wait a bit, say 2 seconds collecting samples, then show the annotation centered on the hottest line so far.
Rock on :)
-Mike