2011-03-01 17:05:46

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 0/6] perf/core top tui fixes and improvements

Hi Ingo,

Please consider pulling from:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core

Regards,

- Arnaldo

Arnaldo Carvalho de Melo (6):
perf top browser: Fix up exit keys
perf ui browser: Introduce ui_browser__show_title
perf top browser: Handle empty active symbols list
perf tui: Make ui__warning modal
perf top: Fix reporting of invalid --vmlinux
perf top tui: Wait till the first sample to refresh the screen.

tools/perf/builtin-top.c | 26 ++++++++++++++++++++++----
tools/perf/util/top.h | 1 +
tools/perf/util/ui/browser.c | 18 +++++++++++++++---
tools/perf/util/ui/browser.h | 3 ++-
tools/perf/util/ui/browsers/top.c | 13 +++++++++++++
tools/perf/util/ui/util.c | 7 +++++--
6 files changed, 58 insertions(+), 10 deletions(-)


2011-03-01 17:04:09

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 6/6] perf top tui: Wait till the first sample to refresh the screen.

From: Arnaldo Carvalho de Melo <[email protected]>

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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-top.c | 21 +++++++++++++++++++--
tools/perf/util/top.h | 1 +
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0b07cc3..417f757 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -72,6 +72,7 @@ static struct perf_top top = {
.target_tid = -1,
.active_symbols = LIST_HEAD_INIT(top.active_symbols),
.active_symbols_lock = PTHREAD_MUTEX_INITIALIZER,
+ .active_symbols_cond = PTHREAD_COND_INITIALIZER,
.freq = 1000, /* 1 KHz */
};

@@ -577,7 +578,17 @@ static void handle_keypress(struct perf_session *session, int c)

static void *display_thread_tui(void *arg __used)
{
- perf_top__tui_browser(&top);
+ int err = 0;
+ pthread_mutex_lock(&top.active_symbols_lock);
+ while (list_empty(&top.active_symbols)) {
+ err = pthread_cond_wait(&top.active_symbols_cond,
+ &top.active_symbols_lock);
+ if (err)
+ break;
+ }
+ pthread_mutex_unlock(&top.active_symbols_lock);
+ if (!err)
+ perf_top__tui_browser(&top);
exit_browser(0);
exit(0);
return NULL;
@@ -776,8 +787,14 @@ static void perf_event__process_sample(const union perf_event *event,
syme->count[evsel->idx]++;
record_precise_ip(syme, evsel->idx, ip);
pthread_mutex_lock(&top.active_symbols_lock);
- if (list_empty(&syme->node) || !syme->node.next)
+ if (list_empty(&syme->node) || !syme->node.next) {
+ static bool first = true;
__list_insert_active_sym(syme);
+ if (first) {
+ pthread_cond_broadcast(&top.active_symbols_cond);
+ first = false;
+ }
+ }
pthread_mutex_unlock(&top.active_symbols_lock);
}
}
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index e8d28e2..96d1cb7 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -35,6 +35,7 @@ struct perf_top {
*/
struct list_head active_symbols;
pthread_mutex_t active_symbols_lock;
+ pthread_cond_t active_symbols_cond;
u64 samples;
u64 kernel_samples, us_samples;
u64 exact_samples;
--
1.6.2.5

2011-03-01 17:04:07

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 5/6] perf top: Fix reporting of invalid --vmlinux

From: Arnaldo Carvalho de Melo <[email protected]>

Using ui__warning, that will, in --tui, show a window with the message,
waiting for the user to press Ok.

Also run exit_browser() to let newt do its final cleaning of 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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-top.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index f88a263..0b07cc3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -740,8 +740,9 @@ static void perf_event__process_sample(const union perf_event *event,
*/
if (al.map == machine->vmlinux_maps[MAP__FUNCTION] &&
RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) {
- pr_err("The %s file can't be used\n",
- symbol_conf.vmlinux_name);
+ ui__warning("The %s file can't be used\n",
+ symbol_conf.vmlinux_name);
+ exit_browser(0);
exit(1);
}

--
1.6.2.5

2011-03-01 17:04:25

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 4/6] perf tui: Make ui__warning modal

From: Arnaldo Carvalho de Melo <[email protected]>

By taking the ui__lock so that no other screen updates take place while
waiting for the user.

That was happening when handling an invalid --vmlinux parameter in 'perf
top --tui', with the screen refresh routine repainting the screen and
removing the warning window.

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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/ui/util.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/ui/util.c b/tools/perf/util/ui/util.c
index 7b5a892..fdf1fc8 100644
--- a/tools/perf/util/ui/util.c
+++ b/tools/perf/util/ui/util.c
@@ -9,6 +9,7 @@
#include "../debug.h"
#include "browser.h"
#include "helpline.h"
+#include "ui.h"
#include "util.h"

static void newt_form__set_exit_keys(newtComponent self)
@@ -118,10 +119,12 @@ void ui__warning(const char *format, ...)
va_list args;

va_start(args, format);
- if (use_browser > 0)
+ if (use_browser > 0) {
+ pthread_mutex_lock(&ui__lock);
newtWinMessagev((char *)warning_str, (char *)ok,
(char *)format, args);
- else
+ pthread_mutex_unlock(&ui__lock);
+ } else
vfprintf(stderr, format, args);
va_end(args);
}
--
1.6.2.5

2011-03-01 17:04:06

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/6] perf top browser: Fix up exit keys

From: Arnaldo Carvalho de Melo <[email protected]>

The left key was exiting 'perf top --tui' when it really shouldn't, it
was too easy to leave the live annotation window and then press one too
many <- and get out of the tool altogether.

Do just like the report TUI does, ignore the left key for exit and also
ask the user when pressing ESC if that is really what is wanted.

Reported-by: Mike Galbraith <[email protected]>
Suggested-by: Ingo Molnar <[email protected]>
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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/ui/browsers/top.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/ui/browsers/top.c b/tools/perf/util/ui/browsers/top.c
index 2f47224..e9381ec 100644
--- a/tools/perf/util/ui/browsers/top.c
+++ b/tools/perf/util/ui/browsers/top.c
@@ -10,6 +10,7 @@
#include "../../annotate.h"
#include "../helpline.h"
#include "../libslang.h"
+#include "../util.h"
#include "../../evlist.h"
#include "../../hist.h"
#include "../../sort.h"
@@ -174,6 +175,12 @@ static int perf_top_browser__run(struct perf_top_browser *browser)
if (browser->selection)
perf_top_browser__annotate(browser);
break;
+ case NEWT_KEY_LEFT:
+ continue;
+ case NEWT_KEY_ESCAPE:
+ if (!ui__dialog_yesno("Do you really want to exit?"))
+ continue;
+ /* Fall thru */
default:
goto out;
}
--
1.6.2.5

2011-03-01 17:04:05

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/6] perf ui browser: Introduce ui_browser__show_title

From: Arnaldo Carvalho de Melo <[email protected]>

Needed because we were only showing the title in ui_browser__show,
not in ui_browser__run, and in the run loop we may be calling other
browsers that would then change the title, when we go back to the
previous browser, we need to redraw the title.

We could have done this as the Newt help line, with pop, etc, but I
don't think its worth, doing it explicitely, when needed (some browsers
may not use the title area at all) seems enough/more flexible.

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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/ui/browser.c | 18 +++++++++++++++---
tools/perf/util/ui/browser.h | 3 ++-
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 60d6c81..611219f 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -157,6 +157,20 @@ void ui_browser__add_exit_keys(struct ui_browser *self, int keys[])
}
}

+void __ui_browser__show_title(struct ui_browser *browser, const char *title)
+{
+ SLsmg_gotorc(0, 0);
+ ui_browser__set_color(browser, NEWT_COLORSET_ROOT);
+ slsmg_write_nstring(title, browser->width);
+}
+
+void ui_browser__show_title(struct ui_browser *browser, const char *title)
+{
+ pthread_mutex_lock(&ui__lock);
+ __ui_browser__show_title(browser, title);
+ pthread_mutex_unlock(&ui__lock);
+}
+
int ui_browser__show(struct ui_browser *self, const char *title,
const char *helpline, ...)
{
@@ -180,9 +194,7 @@ int ui_browser__show(struct ui_browser *self, const char *title,
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);
+ __ui_browser__show_title(self, title);

ui_browser__add_exit_keys(self, keys);
newtFormAddComponent(self->form, self->sb);
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h
index 0dc7e4d..fc63dda 100644
--- a/tools/perf/util/ui/browser.h
+++ b/tools/perf/util/ui/browser.h
@@ -24,7 +24,6 @@ struct ui_browser {
u32 nr_entries;
};

-
void ui_browser__set_color(struct ui_browser *self, int color);
void ui_browser__set_percent_color(struct ui_browser *self,
double percent, bool current);
@@ -35,6 +34,8 @@ void ui_browser__reset_index(struct ui_browser *self);
void ui_browser__gotorc(struct ui_browser *self, int y, int x);
void ui_browser__add_exit_key(struct ui_browser *self, int key);
void ui_browser__add_exit_keys(struct ui_browser *self, int keys[]);
+void __ui_browser__show_title(struct ui_browser *browser, const char *title);
+void ui_browser__show_title(struct ui_browser *browser, const char *title);
int ui_browser__show(struct ui_browser *self, const char *title,
const char *helpline, ...);
void ui_browser__hide(struct ui_browser *self);
--
1.6.2.5

2011-03-01 17:04:04

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/6] perf top browser: Handle empty active symbols list

From: Arnaldo Carvalho de Melo <[email protected]>

Fixing a SEGV. An empty list could happen when not being able to resolve
symbols, for instance when --vmlinux invalid-file is used.

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>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/ui/browsers/top.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/ui/browsers/top.c b/tools/perf/util/ui/browsers/top.c
index e9381ec..5a06538 100644
--- a/tools/perf/util/ui/browsers/top.c
+++ b/tools/perf/util/ui/browsers/top.c
@@ -76,6 +76,12 @@ static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser)
browser->root = RB_ROOT;
browser->b.top = NULL;
browser->sum_ksamples = perf_top__decay_samples(top, &browser->root);
+ /*
+ * No active symbols
+ */
+ if (top->rb_entries == 0)
+ return;
+
perf_top__find_widths(top, &browser->root, &browser->dso_width,
&browser->dso_short_width,
&browser->sym_width);
--
1.6.2.5

2011-03-02 07:07:43

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 0/6] perf/core top tui fixes and improvements


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> Hi Ingo,
>
> Please consider pulling from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
>
> Regards,
>
> - Arnaldo
>
> Arnaldo Carvalho de Melo (6):
> perf top browser: Fix up exit keys
> perf ui browser: Introduce ui_browser__show_title
> perf top browser: Handle empty active symbols list
> perf tui: Make ui__warning modal
> perf top: Fix reporting of invalid --vmlinux
> perf top tui: Wait till the first sample to refresh the screen.
>
> tools/perf/builtin-top.c | 26 ++++++++++++++++++++++----
> tools/perf/util/top.h | 1 +
> tools/perf/util/ui/browser.c | 18 +++++++++++++++---
> tools/perf/util/ui/browser.h | 3 ++-
> tools/perf/util/ui/browsers/top.c | 13 +++++++++++++
> tools/perf/util/ui/util.c | 7 +++++--
> 6 files changed, 58 insertions(+), 10 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo