* [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory
@ 2012-11-13 13:30 Namhyung Kim
2012-11-13 13:30 ` [PATCH 2/6] perf ui: Introduce generic ui_progress helper Namhyung Kim
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
Current ui_progress functions are implemented for TUI only. So move
the file under the tui directory. This is needed for providing an UI-
agnostic wrapper.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Makefile | 2 +-
tools/perf/ui/progress.c | 32 --------------------------------
tools/perf/ui/tui/progress.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 33 insertions(+), 33 deletions(-)
delete mode 100644 tools/perf/ui/progress.c
create mode 100644 tools/perf/ui/tui/progress.c
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 9af012f37718..50e85c852656 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -617,11 +617,11 @@ ifndef NO_NEWT
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)ui/browsers/map.o
LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
- LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/setup.o
LIB_OBJS += $(OUTPUT)ui/tui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/tui/progress.o
LIB_H += ui/browser.h
LIB_H += ui/browsers/map.h
LIB_H += ui/keysyms.h
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
deleted file mode 100644
index 13aa64e50e11..000000000000
--- a/tools/perf/ui/progress.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "../cache.h"
-#include "progress.h"
-#include "libslang.h"
-#include "ui.h"
-#include "browser.h"
-
-void ui_progress__update(u64 curr, u64 total, const char *title)
-{
- int bar, y;
- /*
- * FIXME: We should have a per UI backend way of showing progress,
- * stdio will just show a percentage as NN%, etc.
- */
- if (use_browser <= 0)
- return;
-
- if (total == 0)
- return;
-
- ui__refresh_dimensions(true);
- pthread_mutex_lock(&ui__lock);
- y = SLtt_Screen_Rows / 2 - 2;
- SLsmg_set_color(0);
- SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
- SLsmg_gotorc(y++, 1);
- SLsmg_write_string((char *)title);
- SLsmg_set_color(HE_COLORSET_SELECTED);
- bar = ((SLtt_Screen_Cols - 2) * curr) / total;
- SLsmg_fill_region(y, 1, 1, bar, ' ');
- SLsmg_refresh();
- pthread_mutex_unlock(&ui__lock);
-}
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
new file mode 100644
index 000000000000..f8dc986e427d
--- /dev/null
+++ b/tools/perf/ui/tui/progress.c
@@ -0,0 +1,32 @@
+#include "../cache.h"
+#include "../progress.h"
+#include "../libslang.h"
+#include "../ui.h"
+#include "../browser.h"
+
+void ui_progress__update(u64 curr, u64 total, const char *title)
+{
+ int bar, y;
+ /*
+ * FIXME: We should have a per UI backend way of showing progress,
+ * stdio will just show a percentage as NN%, etc.
+ */
+ if (use_browser <= 0)
+ return;
+
+ if (total == 0)
+ return;
+
+ ui__refresh_dimensions(true);
+ pthread_mutex_lock(&ui__lock);
+ y = SLtt_Screen_Rows / 2 - 2;
+ SLsmg_set_color(0);
+ SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
+ SLsmg_gotorc(y++, 1);
+ SLsmg_write_string((char *)title);
+ SLsmg_set_color(HE_COLORSET_SELECTED);
+ bar = ((SLtt_Screen_Cols - 2) * curr) / total;
+ SLsmg_fill_region(y, 1, 1, bar, ' ');
+ SLsmg_refresh();
+ pthread_mutex_unlock(&ui__lock);
+}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/6] perf ui: Introduce generic ui_progress helper
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
@ 2012-11-13 13:30 ` Namhyung Kim
2012-12-08 15:02 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 3/6] perf ui/gtk: Implement ui_progress functions Namhyung Kim
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
Make ui_progress functions generic so that UI frontend code will add
its callbacks.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Makefile | 1 +
tools/perf/ui/gtk/util.c | 11 -----------
tools/perf/ui/progress.c | 20 ++++++++++++++++++++
tools/perf/ui/progress.h | 8 ++++++++
tools/perf/ui/tui/progress.c | 12 +++++++++++-
tools/perf/ui/tui/setup.c | 1 +
6 files changed, 41 insertions(+), 12 deletions(-)
create mode 100644 tools/perf/ui/progress.c
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 50e85c852656..f8466b49b922 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -423,6 +423,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o
LIB_OBJS += $(OUTPUT)util/stat.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
+LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/hist.o
LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index ccb046aac98b..c06942a41c78 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -111,14 +111,3 @@ struct perf_error_ops perf_gtk_eops = {
.warning = perf_gtk__warning_statusbar,
#endif
};
-
-/*
- * FIXME: Functions below should be implemented properly.
- * For now, just add stubs for NO_NEWT=1 build.
- */
-#ifndef NEWT_SUPPORT
-void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused,
- const char *title __maybe_unused)
-{
-}
-#endif
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
new file mode 100644
index 000000000000..f5e4d1b95c75
--- /dev/null
+++ b/tools/perf/ui/progress.c
@@ -0,0 +1,20 @@
+#include "../cache.h"
+#include "progress.h"
+
+static void nop_progress_update(u64 curr __maybe_unused,
+ u64 total __maybe_unused,
+ const char *title __maybe_unused)
+{
+}
+
+static struct ui_progress default_progress_fns =
+{
+ .update = nop_progress_update,
+};
+
+struct ui_progress *progress_fns = &default_progress_fns;
+
+void ui_progress__update(u64 curr, u64 total, const char *title)
+{
+ return progress_fns->update(curr, total, title);
+}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index d9c205b59aa1..717814b32169 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -3,6 +3,14 @@
#include <../types.h>
+struct ui_progress {
+ void (*update)(u64, u64, const char *);
+};
+
+extern struct ui_progress *progress_fns;
+
+void ui_progress__init(void);
+
void ui_progress__update(u64 curr, u64 total, const char *title);
#endif
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index f8dc986e427d..6c2184d53cbf 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -4,7 +4,7 @@
#include "../ui.h"
#include "../browser.h"
-void ui_progress__update(u64 curr, u64 total, const char *title)
+static void tui_progress__update(u64 curr, u64 total, const char *title)
{
int bar, y;
/*
@@ -30,3 +30,13 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock);
}
+
+static struct ui_progress tui_progress_fns =
+{
+ .update = tui_progress__update,
+};
+
+void ui_progress__init(void)
+{
+ progress_fns = &tui_progress_fns;
+}
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 60debb81537a..81efa192e86c 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -118,6 +118,7 @@ int ui__init(void)
newtSetSuspendCallback(newt_suspend, NULL);
ui_helpline__init();
ui_browser__init();
+ ui_progress__init();
signal(SIGSEGV, ui__signal);
signal(SIGFPE, ui__signal);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/6] perf ui/gtk: Implement ui_progress functions
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
2012-11-13 13:30 ` [PATCH 2/6] perf ui: Introduce generic ui_progress helper Namhyung Kim
@ 2012-11-13 13:30 ` Namhyung Kim
2012-11-15 7:47 ` Pekka Enberg
2012-12-08 15:04 ` [tip:perf/core] perf ui gtk: " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 4/6] perf ui: Add ui_progress__finish() Namhyung Kim
` (3 subsequent siblings)
5 siblings, 2 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that
we should call gtk event loop handler directly.
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Makefile | 1 +
tools/perf/ui/gtk/gtk.h | 1 +
tools/perf/ui/gtk/progress.c | 50 ++++++++++++++++++++++++++++++++++++++++++
tools/perf/ui/gtk/setup.c | 2 ++
4 files changed, 54 insertions(+)
create mode 100644 tools/perf/ui/gtk/progress.c
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f8466b49b922..5a9075ea218e 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -648,6 +648,7 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
LIB_OBJS += $(OUTPUT)ui/gtk/util.o
LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
# Make sure that it'd be included only once.
ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
LIB_OBJS += $(OUTPUT)ui/setup.o
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 687af0bba187..856320e2cc05 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -30,6 +30,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
int perf_gtk__deactivate_context(struct perf_gtk_context **ctx);
void perf_gtk__init_helpline(void);
+void perf_gtk__init_progress(void);
void perf_gtk__init_hpp(void);
#ifndef HAVE_GTK_INFO_BAR
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
new file mode 100644
index 000000000000..903426fe27cf
--- /dev/null
+++ b/tools/perf/ui/gtk/progress.c
@@ -0,0 +1,50 @@
+#include <inttypes.h>
+
+#include "gtk.h"
+#include "../progress.h"
+#include "util.h"
+
+static GtkWidget *dialog;
+static GtkWidget *progress;
+
+static void gtk_progress_update(u64 curr, u64 total, const char *title)
+{
+ double fraction = total ? 1.0 * curr / total : 0.0;
+ char buf[1024];
+
+ if (dialog == NULL) {
+ GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
+ GtkWidget *label = gtk_label_new(title);
+
+ dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ progress = gtk_progress_bar_new();
+
+ gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 3);
+
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), "perf");
+ gtk_window_resize(GTK_WINDOW(dialog), 300, 80);
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_widget_show_all(dialog);
+ }
+
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);
+ snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf);
+
+ /* we didn't call gtk_main yet, so do it manually */
+ while (gtk_events_pending())
+ gtk_main_iteration();
+}
+
+static struct ui_progress gtk_progress_fns = {
+ .update = gtk_progress_update,
+};
+
+void perf_gtk__init_progress(void)
+{
+ progress_fns = >k_progress_fns;
+}
diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c
index 3c4c6ef78283..6c2dd2e423f3 100644
--- a/tools/perf/ui/gtk/setup.c
+++ b/tools/perf/ui/gtk/setup.c
@@ -8,7 +8,9 @@ int perf_gtk__init(void)
{
perf_error__register(&perf_gtk_eops);
perf_gtk__init_helpline();
+ perf_gtk__init_progress();
perf_gtk__init_hpp();
+
return gtk_init_check(NULL, NULL) ? 0 : -1;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/6] perf ui: Add ui_progress__finish()
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
2012-11-13 13:30 ` [PATCH 2/6] perf ui: Introduce generic ui_progress helper Namhyung Kim
2012-11-13 13:30 ` [PATCH 3/6] perf ui/gtk: Implement ui_progress functions Namhyung Kim
@ 2012-11-13 13:30 ` Namhyung Kim
2012-12-08 15:05 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 5/6] perf ui: Always compile browser setup code Namhyung Kim
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
Sometimes we need to know when the progress bar should disappear.
Checking curr >= total wasn't enough since there're cases not met that
condition for the last call. So add a new ->finish callback to
identify this explicitly. Currently only GTK frontend needs it.
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/gtk/progress.c | 9 +++++++++
tools/perf/ui/progress.c | 6 ++++++
tools/perf/ui/progress.h | 2 ++
tools/perf/util/debug.h | 1 +
tools/perf/util/session.c | 1 +
5 files changed, 19 insertions(+)
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index 903426fe27cf..482bcf3df9b7 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -40,8 +40,17 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)
gtk_main_iteration();
}
+static void gtk_progress_finish(void)
+{
+ /* this will also destroy all of its children */
+ gtk_widget_destroy(dialog);
+
+ dialog = NULL;
+}
+
static struct ui_progress gtk_progress_fns = {
.update = gtk_progress_update,
+ .finish = gtk_progress_finish,
};
void perf_gtk__init_progress(void)
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index f5e4d1b95c75..3ec695607a4d 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -18,3 +18,9 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
{
return progress_fns->update(curr, total, title);
}
+
+void ui_progress__finish(void)
+{
+ if (progress_fns->finish)
+ progress_fns->finish();
+}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index 717814b32169..257cc224f9cf 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -5,6 +5,7 @@
struct ui_progress {
void (*update)(u64, u64, const char *);
+ void (*finish)(void);
};
extern struct ui_progress *progress_fns;
@@ -12,5 +13,6 @@ extern struct ui_progress *progress_fns;
void ui_progress__init(void);
void ui_progress__update(u64 curr, u64 total, const char *title);
+void ui_progress__finish(void);
#endif
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index dec98750b484..83e8d234af6b 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -26,6 +26,7 @@ int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
static inline void ui_progress__update(u64 curr __maybe_unused,
u64 total __maybe_unused,
const char *title __maybe_unused) {}
+static inline void ui_progress__finish(void) {}
#define ui__error(format, arg...) ui__warning(format, ##arg)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 15abe40dc702..ce6f51162386 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1458,6 +1458,7 @@ more:
session->ordered_samples.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool);
out_err:
+ ui_progress__finish();
perf_session__warn_about_errors(session, tool);
perf_session_free_sample_buffers(session);
return err;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/6] perf ui: Always compile browser setup code
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
` (2 preceding siblings ...)
2012-11-13 13:30 ` [PATCH 4/6] perf ui: Add ui_progress__finish() Namhyung Kim
@ 2012-11-13 13:30 ` Namhyung Kim
2012-12-08 15:06 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 6/6] perf ui: Always compile error printing code Namhyung Kim
2012-12-08 15:01 ` [tip:perf/core] perf ui tui: Move progress.c under ui/ tui directory tip-bot for Namhyung Kim
5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
We now have proper fallback logic, so always build it regardless of
TUI or GTK setting.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Makefile | 3 +--
tools/perf/ui/ui.h | 28 ++++++++++++++++++++++++++++
tools/perf/util/cache.h | 39 +--------------------------------------
3 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 5a9075ea218e..a7c6aa8d4a8b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -422,6 +422,7 @@ LIB_OBJS += $(OUTPUT)util/intlist.o
LIB_OBJS += $(OUTPUT)util/vdso.o
LIB_OBJS += $(OUTPUT)util/stat.o
+LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/hist.o
@@ -612,7 +613,6 @@ ifndef NO_NEWT
BASIC_CFLAGS += -I/usr/include/slang
BASIC_CFLAGS += -DNEWT_SUPPORT
EXTLIBS += -lnewt -lslang
- LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/browser.o
LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
@@ -651,7 +651,6 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
# Make sure that it'd be included only once.
ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
- LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/util.o
endif
endif
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index 7b67045479f6..d86359c99907 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -3,9 +3,37 @@
#include <pthread.h>
#include <stdbool.h>
+#include <linux/compiler.h>
extern pthread_mutex_t ui__lock;
+extern int use_browser;
+
+void setup_browser(bool fallback_to_pager);
+void exit_browser(bool wait_for_ok);
+
+#ifdef NEWT_SUPPORT
+int ui__init(void);
+void ui__exit(bool wait_for_ok);
+#else
+static inline int ui__init(void)
+{
+ return -1;
+}
+static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
+#endif
+
+#ifdef GTK2_SUPPORT
+int perf_gtk__init(void);
+void perf_gtk__exit(bool wait_for_ok);
+#else
+static inline int perf_gtk__init(void)
+{
+ return -1;
+}
+static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
+#endif
+
void ui__refresh_dimensions(bool force);
#endif /* _PERF_UI_H_ */
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 2bd51370ad28..26e367239873 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -5,6 +5,7 @@
#include "util.h"
#include "strbuf.h"
#include "../perf.h"
+#include "../ui/ui.h"
#define CMD_EXEC_PATH "--exec-path"
#define CMD_PERF_DIR "--perf-dir="
@@ -31,44 +32,6 @@ extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
-extern int use_browser;
-
-#if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
-void setup_browser(bool fallback_to_pager);
-void exit_browser(bool wait_for_ok);
-
-#ifdef NEWT_SUPPORT
-int ui__init(void);
-void ui__exit(bool wait_for_ok);
-#else
-static inline int ui__init(void)
-{
- return -1;
-}
-static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
-#endif
-
-#ifdef GTK2_SUPPORT
-int perf_gtk__init(void);
-void perf_gtk__exit(bool wait_for_ok);
-#else
-static inline int perf_gtk__init(void)
-{
- return -1;
-}
-static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
-#endif
-
-#else /* NEWT_SUPPORT || GTK2_SUPPORT */
-
-static inline void setup_browser(bool fallback_to_pager)
-{
- if (fallback_to_pager)
- setup_pager();
-}
-static inline void exit_browser(bool wait_for_ok __maybe_unused) {}
-#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
-
char *alias_lookup(const char *alias);
int split_cmdline(char *cmdline, const char ***argv);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/6] perf ui: Always compile error printing code
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
` (3 preceding siblings ...)
2012-11-13 13:30 ` [PATCH 5/6] perf ui: Always compile browser setup code Namhyung Kim
@ 2012-11-13 13:30 ` Namhyung Kim
2012-12-08 15:01 ` [tip:perf/core] perf ui tui: Move progress.c under ui/ tui directory tip-bot for Namhyung Kim
5 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-11-13 13:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Peter Zijlstra, Pekka Enberg, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
It is used everywhere so always build it regardless of ui engine.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Makefile | 14 +++++---------
tools/perf/ui/util.c | 10 ++++++++++
tools/perf/util/debug.c | 22 ----------------------
tools/perf/util/debug.h | 33 ++-------------------------------
4 files changed, 17 insertions(+), 62 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index a7c6aa8d4a8b..cd1f346a9f8b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -350,8 +350,11 @@ LIB_H += util/rblist.h
LIB_H += util/intlist.h
LIB_H += util/perf_regs.h
LIB_H += util/unwind.h
-LIB_H += ui/helpline.h
LIB_H += util/vdso.h
+LIB_H += ui/helpline.h
+LIB_H += ui/progress.h
+LIB_H += ui/util.h
+LIB_H += ui/ui.h
LIB_OBJS += $(OUTPUT)util/abspath.o
LIB_OBJS += $(OUTPUT)util/alias.o
@@ -425,6 +428,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o
LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
LIB_OBJS += $(OUTPUT)ui/progress.o
+LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/hist.o
LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
@@ -618,7 +622,6 @@ ifndef NO_NEWT
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)ui/browsers/map.o
LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
- LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/setup.o
LIB_OBJS += $(OUTPUT)ui/tui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
@@ -627,9 +630,6 @@ ifndef NO_NEWT
LIB_H += ui/browsers/map.h
LIB_H += ui/keysyms.h
LIB_H += ui/libslang.h
- LIB_H += ui/progress.h
- LIB_H += ui/util.h
- LIB_H += ui/ui.h
endif
endif
@@ -649,10 +649,6 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/util.o
LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
- # Make sure that it'd be included only once.
- ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
- LIB_OBJS += $(OUTPUT)ui/util.o
- endif
endif
endif
diff --git a/tools/perf/ui/util.c b/tools/perf/ui/util.c
index 4f989774c8c6..3014a7cd5271 100644
--- a/tools/perf/ui/util.c
+++ b/tools/perf/ui/util.c
@@ -52,6 +52,16 @@ int ui__warning(const char *format, ...)
return ret;
}
+int ui__error_paranoid(void)
+{
+ return ui__error("Permission error - are you root?\n"
+ "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
+ " -1 - Not paranoid at all\n"
+ " 0 - Disallow raw tracepoint access for unpriv\n"
+ " 1 - Disallow cpu events for unpriv\n"
+ " 2 - Disallow kernel profiling for unpriv\n");
+}
+
/**
* perf_error__register - Register error logging functions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 03f830b48148..39861a2a7d18 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -49,28 +49,6 @@ int dump_printf(const char *fmt, ...)
return ret;
}
-#if !defined(NEWT_SUPPORT) && !defined(GTK2_SUPPORT)
-int ui__warning(const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- return 0;
-}
-#endif
-
-int ui__error_paranoid(void)
-{
- return ui__error("Permission error - are you root?\n"
- "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
- " -1 - Not paranoid at all\n"
- " 0 - Disallow raw tracepoint access for unpriv\n"
- " 1 - Disallow cpu events for unpriv\n"
- " 2 - Disallow kernel profiling for unpriv\n");
-}
-
void trace_event(union perf_event *event)
{
unsigned char *raw_event = (void *)event;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 83e8d234af6b..6e2667fb8211 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -5,6 +5,8 @@
#include <stdbool.h>
#include "event.h"
#include "../ui/helpline.h"
+#include "../ui/progress.h"
+#include "../ui/util.h"
extern int verbose;
extern bool quiet, dump_trace;
@@ -12,38 +14,7 @@ extern bool quiet, dump_trace;
int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void trace_event(union perf_event *event);
-struct ui_progress;
-struct perf_error_ops;
-
-#if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
-
-#include "../ui/progress.h"
int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-#include "../ui/util.h"
-
-#else
-
-static inline void ui_progress__update(u64 curr __maybe_unused,
- u64 total __maybe_unused,
- const char *title __maybe_unused) {}
-static inline void ui_progress__finish(void) {}
-
-#define ui__error(format, arg...) ui__warning(format, ##arg)
-
-static inline int
-perf_error__register(struct perf_error_ops *eops __maybe_unused)
-{
- return 0;
-}
-
-static inline int
-perf_error__unregister(struct perf_error_ops *eops __maybe_unused)
-{
- return 0;
-}
-
-#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
-
int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
int ui__error_paranoid(void);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/6] perf ui/gtk: Implement ui_progress functions
2012-11-13 13:30 ` [PATCH 3/6] perf ui/gtk: Implement ui_progress functions Namhyung Kim
@ 2012-11-15 7:47 ` Pekka Enberg
2012-11-15 8:44 ` Namhyung Kim
2012-12-08 15:04 ` [tip:perf/core] perf ui gtk: " tip-bot for Namhyung Kim
1 sibling, 1 reply; 13+ messages in thread
From: Pekka Enberg @ 2012-11-15 7:47 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, LKML,
Namhyung Kim
On Tue, 13 Nov 2012, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> Implement progress update function for GTK2 front end.
>
> Note that since it will be called before gtk main loop so that
> we should call gtk event loop handler directly.
>
> Cc: Pekka Enberg <penberg@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
> new file mode 100644
> index 000000000000..903426fe27cf
> --- /dev/null
> +++ b/tools/perf/ui/gtk/progress.c
> @@ -0,0 +1,50 @@
> +#include <inttypes.h>
> +
> +#include "gtk.h"
> +#include "../progress.h"
> +#include "util.h"
> +
> +static GtkWidget *dialog;
> +static GtkWidget *progress;
> +
> +static void gtk_progress_update(u64 curr, u64 total, const char *title)
> +{
> + double fraction = total ? 1.0 * curr / total : 0.0;
> + char buf[1024];
> +
> + if (dialog == NULL) {
> + GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
> + GtkWidget *label = gtk_label_new(title);
> +
> + dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> + progress = gtk_progress_bar_new();
> +
> + gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 3);
> + gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 3);
> +
> + gtk_container_add(GTK_CONTAINER(dialog), vbox);
> +
> + gtk_window_set_title(GTK_WINDOW(dialog), "perf");
> + gtk_window_resize(GTK_WINDOW(dialog), 300, 80);
> + gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
> +
> + gtk_widget_show_all(dialog);
> + }
> +
> + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);
> + snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total);
> + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf);
> +
> + /* we didn't call gtk_main yet, so do it manually */
> + while (gtk_events_pending())
> + gtk_main_iteration();
> +}
When is the progress bar shown? Why does it need to be a separate dialog?
Can't we embed it in the current perf window (and make the other
UI components disabled if necessary)?
Pekka
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/6] perf ui/gtk: Implement ui_progress functions
2012-11-15 7:47 ` Pekka Enberg
@ 2012-11-15 8:44 ` Namhyung Kim
0 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-11-15 8:44 UTC (permalink / raw)
To: Pekka Enberg
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, LKML,
Namhyung Kim
Hi Pekka,
On Thu, 15 Nov 2012 09:47:23 +0200 (EET), Pekka Enberg wrote:
> On Tue, 13 Nov 2012, Namhyung Kim wrote:
>> From: Namhyung Kim <namhyung.kim@lge.com>
>>
>> Implement progress update function for GTK2 front end.
>>
>> Note that since it will be called before gtk main loop so that
>> we should call gtk event loop handler directly.
>>
[snip]
>
> When is the progress bar shown? Why does it need to be a separate dialog?
> Can't we embed it in the current perf window (and make the other
> UI components disabled if necessary)?
It's called during perf_session__process_events() which is executed
before creating the main window.
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 13+ messages in thread
* [tip:perf/core] perf ui tui: Move progress.c under ui/ tui directory
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
` (4 preceding siblings ...)
2012-11-13 13:30 ` [PATCH 6/6] perf ui: Always compile error printing code Namhyung Kim
@ 2012-12-08 15:01 ` tip-bot for Namhyung Kim
5 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-12-08 15:01 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
namhyung, tglx
Commit-ID: 7da5c85dd34dd67846fec965e4bf1f761eecca05
Gitweb: http://git.kernel.org/tip/7da5c85dd34dd67846fec965e4bf1f761eecca05
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 13 Nov 2012 22:30:31 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:52:33 -0300
perf ui tui: Move progress.c under ui/tui directory
Current ui_progress functions are implemented for TUI only. So move the
file under the tui directory. This is needed for providing an UI-
agnostic wrapper.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile | 2 +-
tools/perf/ui/{ => tui}/progress.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 9af012f..50e85c8 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -617,11 +617,11 @@ ifndef NO_NEWT
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)ui/browsers/map.o
LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
- LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/setup.o
LIB_OBJS += $(OUTPUT)ui/tui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/tui/progress.o
LIB_H += ui/browser.h
LIB_H += ui/browsers/map.h
LIB_H += ui/keysyms.h
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/tui/progress.c
similarity index 88%
rename from tools/perf/ui/progress.c
rename to tools/perf/ui/tui/progress.c
index 13aa64e..f8dc986 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -1,8 +1,8 @@
#include "../cache.h"
-#include "progress.h"
-#include "libslang.h"
-#include "ui.h"
-#include "browser.h"
+#include "../progress.h"
+#include "../libslang.h"
+#include "../ui.h"
+#include "../browser.h"
void ui_progress__update(u64 curr, u64 total, const char *title)
{
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf ui: Introduce generic ui_progress helper
2012-11-13 13:30 ` [PATCH 2/6] perf ui: Introduce generic ui_progress helper Namhyung Kim
@ 2012-12-08 15:02 ` tip-bot for Namhyung Kim
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-12-08 15:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
namhyung, tglx
Commit-ID: 688f2f5b99311b127ea43efdbf47bb2e3c7a2e32
Gitweb: http://git.kernel.org/tip/688f2f5b99311b127ea43efdbf47bb2e3c7a2e32
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 13 Nov 2012 22:30:32 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:52:39 -0300
perf ui: Introduce generic ui_progress helper
Make ui_progress functions generic so that UI frontend code will add its
callbacks.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile | 1 +
tools/perf/ui/gtk/util.c | 11 -----------
tools/perf/ui/progress.c | 20 ++++++++++++++++++++
tools/perf/ui/progress.h | 8 ++++++++
tools/perf/ui/tui/progress.c | 12 +++++++++++-
tools/perf/ui/tui/setup.c | 1 +
6 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 50e85c8..f8466b4 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -423,6 +423,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o
LIB_OBJS += $(OUTPUT)util/stat.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
+LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/hist.o
LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index ccb046a..c06942a 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -111,14 +111,3 @@ struct perf_error_ops perf_gtk_eops = {
.warning = perf_gtk__warning_statusbar,
#endif
};
-
-/*
- * FIXME: Functions below should be implemented properly.
- * For now, just add stubs for NO_NEWT=1 build.
- */
-#ifndef NEWT_SUPPORT
-void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused,
- const char *title __maybe_unused)
-{
-}
-#endif
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
new file mode 100644
index 0000000..f5e4d1b
--- /dev/null
+++ b/tools/perf/ui/progress.c
@@ -0,0 +1,20 @@
+#include "../cache.h"
+#include "progress.h"
+
+static void nop_progress_update(u64 curr __maybe_unused,
+ u64 total __maybe_unused,
+ const char *title __maybe_unused)
+{
+}
+
+static struct ui_progress default_progress_fns =
+{
+ .update = nop_progress_update,
+};
+
+struct ui_progress *progress_fns = &default_progress_fns;
+
+void ui_progress__update(u64 curr, u64 total, const char *title)
+{
+ return progress_fns->update(curr, total, title);
+}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index d9c205b..717814b 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -3,6 +3,14 @@
#include <../types.h>
+struct ui_progress {
+ void (*update)(u64, u64, const char *);
+};
+
+extern struct ui_progress *progress_fns;
+
+void ui_progress__init(void);
+
void ui_progress__update(u64 curr, u64 total, const char *title);
#endif
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index f8dc986..6c2184d 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -4,7 +4,7 @@
#include "../ui.h"
#include "../browser.h"
-void ui_progress__update(u64 curr, u64 total, const char *title)
+static void tui_progress__update(u64 curr, u64 total, const char *title)
{
int bar, y;
/*
@@ -30,3 +30,13 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock);
}
+
+static struct ui_progress tui_progress_fns =
+{
+ .update = tui_progress__update,
+};
+
+void ui_progress__init(void)
+{
+ progress_fns = &tui_progress_fns;
+}
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 60debb8..81efa19 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -118,6 +118,7 @@ int ui__init(void)
newtSetSuspendCallback(newt_suspend, NULL);
ui_helpline__init();
ui_browser__init();
+ ui_progress__init();
signal(SIGSEGV, ui__signal);
signal(SIGFPE, ui__signal);
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf ui gtk: Implement ui_progress functions
2012-11-13 13:30 ` [PATCH 3/6] perf ui/gtk: Implement ui_progress functions Namhyung Kim
2012-11-15 7:47 ` Pekka Enberg
@ 2012-12-08 15:04 ` tip-bot for Namhyung Kim
1 sibling, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-12-08 15:04 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
namhyung, tglx
Commit-ID: a753579c3ec096bba9d24e1594a07dbb25aca8e4
Gitweb: http://git.kernel.org/tip/a753579c3ec096bba9d24e1594a07dbb25aca8e4
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 13 Nov 2012 22:30:33 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:52:48 -0300
perf ui gtk: Implement ui_progress functions
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that we should
call gtk event loop handler directly.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile | 1 +
tools/perf/ui/gtk/gtk.h | 1 +
tools/perf/ui/gtk/progress.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/ui/gtk/setup.c | 2 ++
4 files changed, 54 insertions(+)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f8466b4..5a9075e 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -648,6 +648,7 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
LIB_OBJS += $(OUTPUT)ui/gtk/util.o
LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
# Make sure that it'd be included only once.
ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
LIB_OBJS += $(OUTPUT)ui/setup.o
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 687af0b..856320e 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -30,6 +30,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
int perf_gtk__deactivate_context(struct perf_gtk_context **ctx);
void perf_gtk__init_helpline(void);
+void perf_gtk__init_progress(void);
void perf_gtk__init_hpp(void);
#ifndef HAVE_GTK_INFO_BAR
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
new file mode 100644
index 0000000..903426f
--- /dev/null
+++ b/tools/perf/ui/gtk/progress.c
@@ -0,0 +1,50 @@
+#include <inttypes.h>
+
+#include "gtk.h"
+#include "../progress.h"
+#include "util.h"
+
+static GtkWidget *dialog;
+static GtkWidget *progress;
+
+static void gtk_progress_update(u64 curr, u64 total, const char *title)
+{
+ double fraction = total ? 1.0 * curr / total : 0.0;
+ char buf[1024];
+
+ if (dialog == NULL) {
+ GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
+ GtkWidget *label = gtk_label_new(title);
+
+ dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ progress = gtk_progress_bar_new();
+
+ gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 3);
+
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), "perf");
+ gtk_window_resize(GTK_WINDOW(dialog), 300, 80);
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_widget_show_all(dialog);
+ }
+
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);
+ snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf);
+
+ /* we didn't call gtk_main yet, so do it manually */
+ while (gtk_events_pending())
+ gtk_main_iteration();
+}
+
+static struct ui_progress gtk_progress_fns = {
+ .update = gtk_progress_update,
+};
+
+void perf_gtk__init_progress(void)
+{
+ progress_fns = >k_progress_fns;
+}
diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c
index 3c4c6ef..6c2dd2e 100644
--- a/tools/perf/ui/gtk/setup.c
+++ b/tools/perf/ui/gtk/setup.c
@@ -8,7 +8,9 @@ int perf_gtk__init(void)
{
perf_error__register(&perf_gtk_eops);
perf_gtk__init_helpline();
+ perf_gtk__init_progress();
perf_gtk__init_hpp();
+
return gtk_init_check(NULL, NULL) ? 0 : -1;
}
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf ui: Add ui_progress__finish()
2012-11-13 13:30 ` [PATCH 4/6] perf ui: Add ui_progress__finish() Namhyung Kim
@ 2012-12-08 15:05 ` tip-bot for Namhyung Kim
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-12-08 15:05 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
namhyung, tglx
Commit-ID: a5580f3ecb295a514f9522daf0ef7158f73ec2d6
Gitweb: http://git.kernel.org/tip/a5580f3ecb295a514f9522daf0ef7158f73ec2d6
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 13 Nov 2012 22:30:34 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:52:56 -0300
perf ui: Add ui_progress__finish()
Sometimes we need to know when the progress bar should disappear.
Checking curr >= total wasn't enough since there're cases not met that
condition for the last call.
So add a new ->finish callback to identify this explicitly. Currently
only GTK frontend needs it.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/gtk/progress.c | 9 +++++++++
tools/perf/ui/progress.c | 6 ++++++
tools/perf/ui/progress.h | 2 ++
tools/perf/util/debug.h | 1 +
tools/perf/util/session.c | 1 +
5 files changed, 19 insertions(+)
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index 903426f..482bcf3 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -40,8 +40,17 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)
gtk_main_iteration();
}
+static void gtk_progress_finish(void)
+{
+ /* this will also destroy all of its children */
+ gtk_widget_destroy(dialog);
+
+ dialog = NULL;
+}
+
static struct ui_progress gtk_progress_fns = {
.update = gtk_progress_update,
+ .finish = gtk_progress_finish,
};
void perf_gtk__init_progress(void)
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index f5e4d1b..3ec69560 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -18,3 +18,9 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
{
return progress_fns->update(curr, total, title);
}
+
+void ui_progress__finish(void)
+{
+ if (progress_fns->finish)
+ progress_fns->finish();
+}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index 717814b..257cc22 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -5,6 +5,7 @@
struct ui_progress {
void (*update)(u64, u64, const char *);
+ void (*finish)(void);
};
extern struct ui_progress *progress_fns;
@@ -12,5 +13,6 @@ extern struct ui_progress *progress_fns;
void ui_progress__init(void);
void ui_progress__update(u64 curr, u64 total, const char *title);
+void ui_progress__finish(void);
#endif
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index dec9875..83e8d23 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -26,6 +26,7 @@ int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
static inline void ui_progress__update(u64 curr __maybe_unused,
u64 total __maybe_unused,
const char *title __maybe_unused) {}
+static inline void ui_progress__finish(void) {}
#define ui__error(format, arg...) ui__warning(format, ##arg)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 15abe40..ce6f511 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1458,6 +1458,7 @@ more:
session->ordered_samples.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool);
out_err:
+ ui_progress__finish();
perf_session__warn_about_errors(session, tool);
perf_session_free_sample_buffers(session);
return err;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf ui: Always compile browser setup code
2012-11-13 13:30 ` [PATCH 5/6] perf ui: Always compile browser setup code Namhyung Kim
@ 2012-12-08 15:06 ` tip-bot for Namhyung Kim
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-12-08 15:06 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
namhyung, tglx
Commit-ID: 59ed16b315681a08cf8aa13ee949e9405801f442
Gitweb: http://git.kernel.org/tip/59ed16b315681a08cf8aa13ee949e9405801f442
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 13 Nov 2012 22:30:35 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:53:03 -0300
perf ui: Always compile browser setup code
We now have proper fallback logic, so always build it regardless of TUI
or GTK setting.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile | 3 +--
tools/perf/ui/ui.h | 28 ++++++++++++++++++++++++++++
tools/perf/util/cache.h | 39 +--------------------------------------
3 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 5a9075e..a7c6aa8 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -422,6 +422,7 @@ LIB_OBJS += $(OUTPUT)util/intlist.o
LIB_OBJS += $(OUTPUT)util/vdso.o
LIB_OBJS += $(OUTPUT)util/stat.o
+LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/hist.o
@@ -612,7 +613,6 @@ ifndef NO_NEWT
BASIC_CFLAGS += -I/usr/include/slang
BASIC_CFLAGS += -DNEWT_SUPPORT
EXTLIBS += -lnewt -lslang
- LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/browser.o
LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
@@ -651,7 +651,6 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
# Make sure that it'd be included only once.
ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
- LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/util.o
endif
endif
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index 7b67045..d86359c 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -3,9 +3,37 @@
#include <pthread.h>
#include <stdbool.h>
+#include <linux/compiler.h>
extern pthread_mutex_t ui__lock;
+extern int use_browser;
+
+void setup_browser(bool fallback_to_pager);
+void exit_browser(bool wait_for_ok);
+
+#ifdef NEWT_SUPPORT
+int ui__init(void);
+void ui__exit(bool wait_for_ok);
+#else
+static inline int ui__init(void)
+{
+ return -1;
+}
+static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
+#endif
+
+#ifdef GTK2_SUPPORT
+int perf_gtk__init(void);
+void perf_gtk__exit(bool wait_for_ok);
+#else
+static inline int perf_gtk__init(void)
+{
+ return -1;
+}
+static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
+#endif
+
void ui__refresh_dimensions(bool force);
#endif /* _PERF_UI_H_ */
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 2bd5137..26e3672 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -5,6 +5,7 @@
#include "util.h"
#include "strbuf.h"
#include "../perf.h"
+#include "../ui/ui.h"
#define CMD_EXEC_PATH "--exec-path"
#define CMD_PERF_DIR "--perf-dir="
@@ -31,44 +32,6 @@ extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
-extern int use_browser;
-
-#if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
-void setup_browser(bool fallback_to_pager);
-void exit_browser(bool wait_for_ok);
-
-#ifdef NEWT_SUPPORT
-int ui__init(void);
-void ui__exit(bool wait_for_ok);
-#else
-static inline int ui__init(void)
-{
- return -1;
-}
-static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
-#endif
-
-#ifdef GTK2_SUPPORT
-int perf_gtk__init(void);
-void perf_gtk__exit(bool wait_for_ok);
-#else
-static inline int perf_gtk__init(void)
-{
- return -1;
-}
-static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
-#endif
-
-#else /* NEWT_SUPPORT || GTK2_SUPPORT */
-
-static inline void setup_browser(bool fallback_to_pager)
-{
- if (fallback_to_pager)
- setup_pager();
-}
-static inline void exit_browser(bool wait_for_ok __maybe_unused) {}
-#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
-
char *alias_lookup(const char *alias);
int split_cmdline(char *cmdline, const char ***argv);
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2012-12-08 15:06 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-13 13:30 [PATCH 1/6] perf ui/tui: Move progress.c under ui/tui directory Namhyung Kim
2012-11-13 13:30 ` [PATCH 2/6] perf ui: Introduce generic ui_progress helper Namhyung Kim
2012-12-08 15:02 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 3/6] perf ui/gtk: Implement ui_progress functions Namhyung Kim
2012-11-15 7:47 ` Pekka Enberg
2012-11-15 8:44 ` Namhyung Kim
2012-12-08 15:04 ` [tip:perf/core] perf ui gtk: " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 4/6] perf ui: Add ui_progress__finish() Namhyung Kim
2012-12-08 15:05 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 5/6] perf ui: Always compile browser setup code Namhyung Kim
2012-12-08 15:06 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-13 13:30 ` [PATCH 6/6] perf ui: Always compile error printing code Namhyung Kim
2012-12-08 15:01 ` [tip:perf/core] perf ui tui: Move progress.c under ui/ tui directory tip-bot for Namhyung Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.