Skip to contentSkip to conversation

perf ui/tui: Show fatal error message only if exists

PATCH In review Namhyung Kim 3 participants 5 messages Jan 20, 2015 – Jan 28, 2015 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf ui/tui: Show fatal error message only if exists

When perf exits with some error it shows the error message with ui__error() or ui__warning() and then calls ui__exit() during exit_browser().

On TUI, it then shows a window titled "Fatal Error" to inform user a last message which might be related with this condition. However it sometimes contains no message and just annoyes users.

The usual case for this is running perf top as normal user. (And /proc/sys/kernel/perf_event_paranoid being 1).

---
 tools/perf/ui/tui/helpline.c | 3 +++
 tools/perf/ui/tui/setup.c    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/ui/tui/helpline.c +3 -0
index 1c8b9afd5d6e..88f5143a5981 100644
@@ -9,6 +9,7 @@
 #include "../libslang.h"
 
 char ui_helpline__last_msg[1024];
+bool tui_helpline__set;
 
 static void tui_helpline__pop(void)
 {
@@ -35,6 +36,8 @@ static int tui_helpline__show(const char *format, va_list ap)
 			sizeof(ui_helpline__last_msg) - backlog, format, ap);
 	backlog += ret;
 
+	tui_helpline__set = true;
+
 	if (ui_helpline__last_msg[backlog - 1] == '\n') {
 		ui_helpline__puts(ui_helpline__last_msg);
 		SLsmg_refresh();
tools/perf/ui/tui/setup.c +2 -1
index 3c38f25b1695..b77e1d771363 100644
@@ -17,6 +17,7 @@
 static volatile int ui__need_resize;
 
 extern struct perf_error_ops perf_tui_eops;
+extern bool tui_helpline__set;
 
 extern void hist_browser__init_hpp(void);
 
@@ -159,7 +160,7 @@ int ui__init(void)
 
 void ui__exit(bool wait_for_ok)
 {
-	if (wait_for_ok)
+	if (wait_for_ok && tui_helpline__set)
 		ui__question_window("Fatal Error",
 				    ui_helpline__last_msg,
 				    "Press any key...", 0);
Signature · 1 line
2.2.2
#1 lore raw
Quoted 10 lines · Namhyung Kim

When perf exits with some error it shows the error message with ui__error() or ui__warning() and then calls ui__exit() during exit_browser().

On TUI, it then shows a window titled "Fatal Error" to inform user a last message which might be related with this condition. However it sometimes contains no message and just annoyes users.

The usual case for this is running perf top as normal user. (And /proc/sys/kernel/perf_event_paranoid being 1).

cool, I couldn't recreate the 'no message' box but I recall seeing it

Quoted 41 lines
---
 tools/perf/ui/tui/helpline.c | 3 +++
 tools/perf/ui/tui/setup.c    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/ui/tui/helpline.c +3 -0
index 1c8b9afd5d6e..88f5143a5981 100644
@@ -9,6 +9,7 @@
 #include "../libslang.h"
 
 char ui_helpline__last_msg[1024];
+bool tui_helpline__set;
 
 static void tui_helpline__pop(void)
 {
@@ -35,6 +36,8 @@ static int tui_helpline__show(const char *format, va_list ap)
 			sizeof(ui_helpline__last_msg) - backlog, format, ap);
 	backlog += ret;
 
+	tui_helpline__set = true;
+
 	if (ui_helpline__last_msg[backlog - 1] == '\n') {
 		ui_helpline__puts(ui_helpline__last_msg);
 		SLsmg_refresh();
tools/perf/ui/tui/setup.c +1 -0
index 3c38f25b1695..b77e1d771363 100644
@@ -17,6 +17,7 @@
 static volatile int ui__need_resize;
 
 extern struct perf_error_ops perf_tui_eops;
+extern bool tui_helpline__set;
 
 extern void hist_browser__init_hpp(void);
 

tools/perf/ui/tui/setup.c int ui__init(void) · line 166

Quoted 8 lines
tools/perf/ui/tui/setup.c +1 -1
@@ -159,7 +160,7 @@ int ui__init(void)
 
 void ui__exit(bool wait_for_ok)
 {
-	if (wait_for_ok)
+	if (wait_for_ok && tui_helpline__set)
 		ui__question_window("Fatal Error",
 				    ui_helpline__last_msg,
 				    "Press any key...", 0);

looks like we display ui_helpline__last_msg also in ui/browsers/annotate.c

do we want to have some common function that unsets tui_helpline__set so we're sure we dont get the message twice?

jirka

author maintainer
#2 lore raw
Quoted 56 lines · Jiri Olsa
Quoted 10 lines · Namhyung Kim

When perf exits with some error it shows the error message with ui__error() or ui__warning() and then calls ui__exit() during exit_browser().

On TUI, it then shows a window titled "Fatal Error" to inform user a last message which might be related with this condition. However it sometimes contains no message and just annoyes users.

The usual case for this is running perf top as normal user. (And /proc/sys/kernel/perf_event_paranoid being 1).

cool, I couldn't recreate the 'no message' box but I recall seeing it

Quoted 42 lines
---
 tools/perf/ui/tui/helpline.c | 3 +++
 tools/perf/ui/tui/setup.c    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/ui/tui/helpline.c +3 -0
index 1c8b9afd5d6e..88f5143a5981 100644
@@ -9,6 +9,7 @@
 #include "../libslang.h"
 
 char ui_helpline__last_msg[1024];
+bool tui_helpline__set;
 
 static void tui_helpline__pop(void)
 {
@@ -35,6 +36,8 @@ static int tui_helpline__show(const char *format, va_list ap)
 			sizeof(ui_helpline__last_msg) - backlog, format, ap);
 	backlog += ret;
 
+	tui_helpline__set = true;
+
 	if (ui_helpline__last_msg[backlog - 1] == '\n') {
 		ui_helpline__puts(ui_helpline__last_msg);
 		SLsmg_refresh();
tools/perf/ui/tui/setup.c +1 -0
index 3c38f25b1695..b77e1d771363 100644
@@ -17,6 +17,7 @@
 static volatile int ui__need_resize;
 
 extern struct perf_error_ops perf_tui_eops;
+extern bool tui_helpline__set;
 
 extern void hist_browser__init_hpp(void);
 
@@ -159,7 +160,7 @@ int ui__init(void)
 
Quoted 9 lines

tools/perf/ui/tui/setup.c int ui__init(void) · line 166

Quoted 7 lines
tools/perf/ui/tui/setup.c +1 -1
 void ui__exit(bool wait_for_ok)
 {
-	if (wait_for_ok)
+	if (wait_for_ok && tui_helpline__set)
 		ui__question_window("Fatal Error",
 				    ui_helpline__last_msg,
 				    "Press any key...", 0);

looks like we display ui_helpline__last_msg also in ui/browsers/annotate.c

Right, I also saw it.

Quoted 3 lines

do we want to have some common function that unsets tui_helpline__set so we're sure we dont get the message twice?

I doubt that it's really needed.. The annotation code does not propagate an error so the wait_for_ok arg in ui__exit() will be always false. In addition, I think it's better to use ui__error() or ui__warning() directly at the point when something bad happened and we need to inform user.

Thanks,
Namhyung

Acked-by
#3 lore raw

On Fri, Jan 23, 2015 at 12:08:34AM +0900, Namhyung Kim wrote:

SNIP

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

"Press any key...", 0);

looks like we display ui_helpline__last_msg also in ui/browsers/annotate.c

Right, I also saw it.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

do we want to have some common function that unsets tui_helpline__set so we're sure we dont get the message twice?

I doubt that it's really needed.. The annotation code does not propagate an error so the wait_for_ok arg in ui__exit() will be always false. In addition, I think it's better to use ui__error() or ui__warning() directly at the point when something bad happened and we need to inform user.

ok..

jirka

#4 lore raw
In reply to Namhyung Kim
perf ui/tui: Show fatal error message only if exists
Commit-ID:  4397bd2f90459d550deca7f6ba32c12e382d8b57
Gitweb:     http://git.kernel.org/tip/4397bd2f90459d550deca7f6ba32c12e382d8b57
Author:     Namhyung Kim <[email protected]>
AuthorDate: Tue, 20 Jan 2015 15:40:50 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 22 Jan 2015 17:05:10 -0300

perf ui/tui: Show fatal error message only if exists

When perf exits with some error it shows the error message with ui__error() or ui__warning() and then calls ui__exit() during exit_browser().

On TUI, it then shows a window titled "Fatal Error" to inform user a last message which might be related with this condition. However it sometimes contains no message and just annoyes users.

The usual case for this is running perf top as normal user. (And /proc/sys/kernel/perf_event_paranoid being 1).

---
 tools/perf/ui/tui/helpline.c | 3 +++
 tools/perf/ui/tui/setup.c    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/ui/tui/helpline.c +3 -0
index 1c8b9af..88f5143 100644
@@ -9,6 +9,7 @@
 #include "../libslang.h"
 
 char ui_helpline__last_msg[1024];
+bool tui_helpline__set;
 
 static void tui_helpline__pop(void)
 {
@@ -35,6 +36,8 @@ static int tui_helpline__show(const char *format, va_list ap)
 			sizeof(ui_helpline__last_msg) - backlog, format, ap);
 	backlog += ret;
 
+	tui_helpline__set = true;
+
 	if (ui_helpline__last_msg[backlog - 1] == '\n') {
 		ui_helpline__puts(ui_helpline__last_msg);
 		SLsmg_refresh();
tools/perf/ui/tui/setup.c +2 -1
index 3c38f25..b77e1d7 100644
@@ -17,6 +17,7 @@
 static volatile int ui__need_resize;
 
 extern struct perf_error_ops perf_tui_eops;
+extern bool tui_helpline__set;
 
 extern void hist_browser__init_hpp(void);
 
@@ -159,7 +160,7 @@ out:
 
 void ui__exit(bool wait_for_ok)
 {
-	if (wait_for_ok)
+	if (wait_for_ok && tui_helpline__set)
 		ui__question_window("Fatal Error",
 				    ui_helpline__last_msg,
 				    "Press any key...", 0);