2013-06-04 09:22:21

by Namhyung Kim

[permalink] [raw]
Subject: [PATCHSET 0/6] perf report: Add support for callchains on GTK browser (v2)

Hi,

This patchset implements callchain support in GTK report browser as
Pekka requested. Please take a look and give me comments.

v2 changes)
* fix a bug on percent calculation of children nodes
* show topmost symbol only when multiple paths exist for a node
* add alternating background colors (Ingo)
* put callchain info into existing overhead and symbol column (Arnaldo)

You can get it from 'perf/callchain-gtk-v2' branch on my tree at

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git


Any comments are welcome, thanks!
Namhyung

Namhyung Kim (6):
perf gtk/hists: Use GtkTreeStore instead of GtkListStore
perf gtk/hists: Add support for callchains
perf gtk/hists: Display callchain overhead also
perf gtk/hists: Make column headers resizable
perf gtk/hists: Add a double-click handler for callchains
perf gtk/hists: Set rules hint for the hist browser

tools/perf/ui/gtk/hists.c | 117 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 112 insertions(+), 5 deletions(-)

--
1.7.11.7


2013-06-04 09:22:24

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 3/6] perf gtk/hists: Display callchain overhead also

From: Namhyung Kim <[email protected]>

Display callchain percent value in the overhead column.

Cc: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 226c7e10f3cc..fa9f8a09233e 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -134,7 +134,7 @@ static void callchain_list__sym_name(struct callchain_list *cl,
}

static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
- GtkTreeIter *parent, int col)
+ GtkTreeIter *parent, int col, u64 total)
{
struct rb_node *nd;
bool has_single_node = (rb_first(root) == rb_last(root));
@@ -144,9 +144,14 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
struct callchain_list *chain;
GtkTreeIter iter, new_parent;
bool need_new_parent;
+ double percent;
+ u64 hits, child_total;

node = rb_entry(nd, struct callchain_node, rb_node);

+ hits = callchain_cumul_hits(node);
+ percent = 100.0 * hits / total;
+
new_parent = *parent;
need_new_parent = !has_single_node && (node->val_nr > 1);

@@ -155,6 +160,9 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,

gtk_tree_store_append(store, &iter, &new_parent);

+ scnprintf(buf, sizeof(buf), "%5.2f%%", percent);
+ gtk_tree_store_set(store, &iter, 0, buf, -1);
+
callchain_list__sym_name(chain, buf, sizeof(buf));
gtk_tree_store_set(store, &iter, col, buf, -1);

@@ -168,8 +176,14 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
}
}

+ if (callchain_param.mode == CHAIN_GRAPH_REL)
+ child_total = node->children_hit;
+ else
+ child_total = total;
+
/* Now 'iter' contains info of the last callchain_list */
- perf_gtk__add_callchain(&node->rb_root, store, &iter, col);
+ perf_gtk__add_callchain(&node->rb_root, store, &iter, col,
+ child_total);
}
}

@@ -283,8 +297,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}

if (symbol_conf.use_callchain && sort__has_sym) {
+ u64 total;
+
+ if (callchain_param.mode == CHAIN_GRAPH_REL)
+ total = h->stat.period;
+ else
+ total = hists->stats.total_period;
+
perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
- sym_col);
+ sym_col, total);
}
}

--
1.7.11.7

2013-06-04 09:22:23

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 4/6] perf gtk/hists: Make column headers resizable

From: Namhyung Kim <[email protected]>

Sometimes it's annoying to see when some symbols have very wierd long
names. So it might be a good idea to make column size changable.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index fa9f8a09233e..b4a0dd2404a2 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -250,11 +250,16 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_idx++, NULL);
}

- if (symbol_conf.use_callchain && sort__has_sym) {
+ for (col_idx = 0; col_idx < nr_cols; col_idx++) {
GtkTreeViewColumn *column;

- column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), sym_col);
- gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), column);
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ if (col_idx == sym_col) {
+ gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
+ column);
+ }
}

gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
--
1.7.11.7

2013-06-04 09:22:26

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 6/6] perf gtk/hists: Set rules hint for the hist browser

From: Namhyung Kim <[email protected]>

The 'rules' means that every second line of the tree view has a shaded
background, which makes it easier to see which cell belongs to which
row in the tree view. It can be useful for a tree view that has a lot
of rows.

Cc: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 3a5d01319988..32549035f50d 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -326,6 +326,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}
}

+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
+
g_signal_connect(view, "row-activated",
G_CALLBACK(on_row_activated), NULL);
gtk_container_add(GTK_CONTAINER(window), view);
--
1.7.11.7

2013-06-04 09:23:01

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 5/6] perf gtk/hists: Add a double-click handler for callchains

From: Namhyung Kim <[email protected]>

If callchain is displayed, add "row-activated" signal handler for
handling double-click or pressing ENTER key action.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index b4a0dd2404a2..3a5d01319988 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -187,6 +187,18 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
}
}

+static void on_row_activated(GtkTreeView *view, GtkTreePath *path,
+ GtkTreeViewColumn *col __maybe_unused,
+ gpointer user_data __maybe_unused)
+{
+ bool expanded = gtk_tree_view_row_expanded(view, path);
+
+ if (expanded)
+ gtk_tree_view_collapse_row(view, path);
+ else
+ gtk_tree_view_expand_row(view, path, FALSE);
+}
+
static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
float min_pcnt)
{
@@ -314,6 +326,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}
}

+ g_signal_connect(view, "row-activated",
+ G_CALLBACK(on_row_activated), NULL);
gtk_container_add(GTK_CONTAINER(window), view);
}

--
1.7.11.7

2013-06-04 09:23:25

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 2/6] perf gtk/hists: Add support for callchains

From: Namhyung Kim <[email protected]>

Display callchain information in the symbol column. It's only enabled
when recorded with -g and has symbol sort key.

Cc: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index cb6a9b45f789..226c7e10f3cc 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -124,6 +124,55 @@ void perf_gtk__init_hpp(void)
perf_gtk__hpp_color_overhead_guest_us;
}

+static void callchain_list__sym_name(struct callchain_list *cl,
+ char *bf, size_t bfsize)
+{
+ if (cl->ms.sym)
+ scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
+ else
+ scnprintf(bf, bfsize, "%#" PRIx64, cl->ip);
+}
+
+static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
+ GtkTreeIter *parent, int col)
+{
+ struct rb_node *nd;
+ bool has_single_node = (rb_first(root) == rb_last(root));
+
+ for (nd = rb_first(root); nd; nd = rb_next(nd)) {
+ struct callchain_node *node;
+ struct callchain_list *chain;
+ GtkTreeIter iter, new_parent;
+ bool need_new_parent;
+
+ node = rb_entry(nd, struct callchain_node, rb_node);
+
+ new_parent = *parent;
+ need_new_parent = !has_single_node && (node->val_nr > 1);
+
+ list_for_each_entry(chain, &node->val, list) {
+ char buf[128];
+
+ gtk_tree_store_append(store, &iter, &new_parent);
+
+ callchain_list__sym_name(chain, buf, sizeof(buf));
+ gtk_tree_store_set(store, &iter, col, buf, -1);
+
+ if (need_new_parent) {
+ /*
+ * Only show the top-most symbol in a callchain
+ * if it's not the only callchain.
+ */
+ new_parent = iter;
+ need_new_parent = false;
+ }
+ }
+
+ /* Now 'iter' contains info of the last callchain_list */
+ perf_gtk__add_callchain(&node->rb_root, store, &iter, col);
+ }
+}
+
static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
float min_pcnt)
{
@@ -135,6 +184,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
struct rb_node *nd;
GtkWidget *view;
int col_idx;
+ int sym_col = -1;
int nr_cols;
char s[512];

@@ -153,6 +203,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
if (se->elide)
continue;

+ if (se == &sort_sym)
+ sym_col = nr_cols;
+
col_types[nr_cols++] = G_TYPE_STRING;
}

@@ -183,6 +236,13 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_idx++, NULL);
}

+ if (symbol_conf.use_callchain && sort__has_sym) {
+ GtkTreeViewColumn *column;
+
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), sym_col);
+ gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), column);
+ }
+
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));

g_object_unref(GTK_TREE_MODEL(store));
@@ -221,6 +281,11 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,

gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}
+
+ if (symbol_conf.use_callchain && sort__has_sym) {
+ perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
+ sym_col);
+ }
}

gtk_container_add(GTK_CONTAINER(window), view);
--
1.7.11.7

2013-06-04 09:23:27

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 1/6] perf gtk/hists: Use GtkTreeStore instead of GtkListStore

From: Namhyung Kim <[email protected]>

The GtkTreeStore can save items in a tree-like way. This is a
preparation for supporting callgraphs in the hist browser.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/gtk/hists.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 9708dd5fb8f3..cb6a9b45f789 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -131,7 +131,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
GType col_types[MAX_COLUMNS];
GtkCellRenderer *renderer;
struct sort_entry *se;
- GtkListStore *store;
+ GtkTreeStore *store;
struct rb_node *nd;
GtkWidget *view;
int col_idx;
@@ -156,7 +156,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_types[nr_cols++] = G_TYPE_STRING;
}

- store = gtk_list_store_newv(nr_cols, col_types);
+ store = gtk_tree_store_newv(nr_cols, col_types);

view = gtk_tree_view_new();

@@ -199,7 +199,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
if (percent < min_pcnt)
continue;

- gtk_list_store_append(store, &iter);
+ gtk_tree_store_append(store, &iter, NULL);

col_idx = 0;

@@ -209,7 +209,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
else
fmt->entry(&hpp, h);

- gtk_list_store_set(store, &iter, col_idx++, s, -1);
+ gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}

list_for_each_entry(se, &hist_entry__sort_list, list) {
@@ -219,7 +219,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
se->se_snprintf(h, s, ARRAY_SIZE(s),
hists__col_len(hists, se->se_width_idx));

- gtk_list_store_set(store, &iter, col_idx++, s, -1);
+ gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}
}

--
1.7.11.7

2013-06-04 09:34:41

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH 2/6] perf gtk/hists: Add support for callchains

On Tue, Jun 4, 2013 at 12:22 PM, Namhyung Kim <[email protected]> wrote:
> From: Namhyung Kim <[email protected]>
>
> Display callchain information in the symbol column. It's only enabled
> when recorded with -g and has symbol sort key.
>
> Cc: Pekka Enberg <[email protected]>
> Signed-off-by: Namhyung Kim <[email protected]>

Reviewed-by: Pekka Enberg <[email protected]>

2013-06-04 09:35:24

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH 3/6] perf gtk/hists: Display callchain overhead also

On Tue, Jun 4, 2013 at 12:22 PM, Namhyung Kim <[email protected]> wrote:
> From: Namhyung Kim <[email protected]>
>
> Display callchain percent value in the overhead column.
>
> Cc: Pekka Enberg <[email protected]>
> Signed-off-by: Namhyung Kim <[email protected]>

Reviewed-by: Pekka Enberg <[email protected]>

2013-06-04 09:35:55

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH 6/6] perf gtk/hists: Set rules hint for the hist browser

On Tue, Jun 4, 2013 at 12:22 PM, Namhyung Kim <[email protected]> wrote:
> From: Namhyung Kim <[email protected]>
>
> The 'rules' means that every second line of the tree view has a shaded
> background, which makes it easier to see which cell belongs to which
> row in the tree view. It can be useful for a tree view that has a lot
> of rows.
>
> Cc: Pekka Enberg <[email protected]>
> Signed-off-by: Namhyung Kim <[email protected]>

Reviewed-by: Pekka Enberg <[email protected]>

2013-07-04 08:39:38

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCHSET 0/6] perf report: Add support for callchains on GTK browser (v2)

Ping!

On Tue, 4 Jun 2013 18:22:11 +0900, Namhyung Kim wrote:
> Hi,
>
> This patchset implements callchain support in GTK report browser as
> Pekka requested. Please take a look and give me comments.
>
> v2 changes)
> * fix a bug on percent calculation of children nodes
> * show topmost symbol only when multiple paths exist for a node
> * add alternating background colors (Ingo)
> * put callchain info into existing overhead and symbol column (Arnaldo)
>
> You can get it from 'perf/callchain-gtk-v2' branch on my tree at
>
> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
>
> Any comments are welcome, thanks!
> Namhyung
>
> Namhyung Kim (6):
> perf gtk/hists: Use GtkTreeStore instead of GtkListStore
> perf gtk/hists: Add support for callchains
> perf gtk/hists: Display callchain overhead also
> perf gtk/hists: Make column headers resizable
> perf gtk/hists: Add a double-click handler for callchains
> perf gtk/hists: Set rules hint for the hist browser
>
> tools/perf/ui/gtk/hists.c | 117 ++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 112 insertions(+), 5 deletions(-)

2013-07-05 15:04:16

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCHSET 0/6] perf report: Add support for callchains on GTK browser (v2)

Em Tue, Jun 04, 2013 at 06:22:11PM +0900, Namhyung Kim escreveu:
> Hi,
>
> This patchset implements callchain support in GTK report browser as
> Pekka requested. Please take a look and give me comments.
>
> v2 changes)
> * fix a bug on percent calculation of children nodes
> * show topmost symbol only when multiple paths exist for a node
> * add alternating background colors (Ingo)
> * put callchain info into existing overhead and symbol column (Arnaldo)

Thanks, applied.

- Arnaldo

Subject: [tip:perf/core] perf gtk/hists: Add support for callchains

Commit-ID: 2bbc5874251830fee170a0fc97fa5788717d2fd9
Gitweb: http://git.kernel.org/tip/2bbc5874251830fee170a0fc97fa5788717d2fd9
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:13 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:38 -0300

perf gtk/hists: Add support for callchains

Display callchain information in the symbol column. It's only enabled
when recorded with -g and has symbol sort key.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index cb6a9b4..226c7e1 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -124,6 +124,55 @@ void perf_gtk__init_hpp(void)
perf_gtk__hpp_color_overhead_guest_us;
}

+static void callchain_list__sym_name(struct callchain_list *cl,
+ char *bf, size_t bfsize)
+{
+ if (cl->ms.sym)
+ scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
+ else
+ scnprintf(bf, bfsize, "%#" PRIx64, cl->ip);
+}
+
+static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
+ GtkTreeIter *parent, int col)
+{
+ struct rb_node *nd;
+ bool has_single_node = (rb_first(root) == rb_last(root));
+
+ for (nd = rb_first(root); nd; nd = rb_next(nd)) {
+ struct callchain_node *node;
+ struct callchain_list *chain;
+ GtkTreeIter iter, new_parent;
+ bool need_new_parent;
+
+ node = rb_entry(nd, struct callchain_node, rb_node);
+
+ new_parent = *parent;
+ need_new_parent = !has_single_node && (node->val_nr > 1);
+
+ list_for_each_entry(chain, &node->val, list) {
+ char buf[128];
+
+ gtk_tree_store_append(store, &iter, &new_parent);
+
+ callchain_list__sym_name(chain, buf, sizeof(buf));
+ gtk_tree_store_set(store, &iter, col, buf, -1);
+
+ if (need_new_parent) {
+ /*
+ * Only show the top-most symbol in a callchain
+ * if it's not the only callchain.
+ */
+ new_parent = iter;
+ need_new_parent = false;
+ }
+ }
+
+ /* Now 'iter' contains info of the last callchain_list */
+ perf_gtk__add_callchain(&node->rb_root, store, &iter, col);
+ }
+}
+
static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
float min_pcnt)
{
@@ -135,6 +184,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
struct rb_node *nd;
GtkWidget *view;
int col_idx;
+ int sym_col = -1;
int nr_cols;
char s[512];

@@ -153,6 +203,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
if (se->elide)
continue;

+ if (se == &sort_sym)
+ sym_col = nr_cols;
+
col_types[nr_cols++] = G_TYPE_STRING;
}

@@ -183,6 +236,13 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_idx++, NULL);
}

+ if (symbol_conf.use_callchain && sort__has_sym) {
+ GtkTreeViewColumn *column;
+
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), sym_col);
+ gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), column);
+ }
+
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));

g_object_unref(GTK_TREE_MODEL(store));
@@ -221,6 +281,11 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,

gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}
+
+ if (symbol_conf.use_callchain && sort__has_sym) {
+ perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
+ sym_col);
+ }
}

gtk_container_add(GTK_CONTAINER(window), view);

Subject: [tip:perf/core] perf gtk/hists: Use GtkTreeStore instead of GtkListStore

Commit-ID: f1d9a530553eed9e598d1597a2a348f01810dd4a
Gitweb: http://git.kernel.org/tip/f1d9a530553eed9e598d1597a2a348f01810dd4a
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:12 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:36 -0300

perf gtk/hists: Use GtkTreeStore instead of GtkListStore

The GtkTreeStore can save items in a tree-like way. This is a
preparation for supporting callgraphs in the hist browser.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 9708dd5..cb6a9b4 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -131,7 +131,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
GType col_types[MAX_COLUMNS];
GtkCellRenderer *renderer;
struct sort_entry *se;
- GtkListStore *store;
+ GtkTreeStore *store;
struct rb_node *nd;
GtkWidget *view;
int col_idx;
@@ -156,7 +156,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_types[nr_cols++] = G_TYPE_STRING;
}

- store = gtk_list_store_newv(nr_cols, col_types);
+ store = gtk_tree_store_newv(nr_cols, col_types);

view = gtk_tree_view_new();

@@ -199,7 +199,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
if (percent < min_pcnt)
continue;

- gtk_list_store_append(store, &iter);
+ gtk_tree_store_append(store, &iter, NULL);

col_idx = 0;

@@ -209,7 +209,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
else
fmt->entry(&hpp, h);

- gtk_list_store_set(store, &iter, col_idx++, s, -1);
+ gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}

list_for_each_entry(se, &hist_entry__sort_list, list) {
@@ -219,7 +219,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
se->se_snprintf(h, s, ARRAY_SIZE(s),
hists__col_len(hists, se->se_width_idx));

- gtk_list_store_set(store, &iter, col_idx++, s, -1);
+ gtk_tree_store_set(store, &iter, col_idx++, s, -1);
}
}

Subject: [tip:perf/core] perf gtk/hists: Display callchain overhead also

Commit-ID: cc60f24e225e50a0b57398f9ba105fd8ffcf4bb3
Gitweb: http://git.kernel.org/tip/cc60f24e225e50a0b57398f9ba105fd8ffcf4bb3
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:14 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:40 -0300

perf gtk/hists: Display callchain overhead also

Display callchain percent value in the overhead column.

Signed-off-by: Namhyung Kim <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 226c7e1..fa9f8a0 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -134,7 +134,7 @@ static void callchain_list__sym_name(struct callchain_list *cl,
}

static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
- GtkTreeIter *parent, int col)
+ GtkTreeIter *parent, int col, u64 total)
{
struct rb_node *nd;
bool has_single_node = (rb_first(root) == rb_last(root));
@@ -144,9 +144,14 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
struct callchain_list *chain;
GtkTreeIter iter, new_parent;
bool need_new_parent;
+ double percent;
+ u64 hits, child_total;

node = rb_entry(nd, struct callchain_node, rb_node);

+ hits = callchain_cumul_hits(node);
+ percent = 100.0 * hits / total;
+
new_parent = *parent;
need_new_parent = !has_single_node && (node->val_nr > 1);

@@ -155,6 +160,9 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,

gtk_tree_store_append(store, &iter, &new_parent);

+ scnprintf(buf, sizeof(buf), "%5.2f%%", percent);
+ gtk_tree_store_set(store, &iter, 0, buf, -1);
+
callchain_list__sym_name(chain, buf, sizeof(buf));
gtk_tree_store_set(store, &iter, col, buf, -1);

@@ -168,8 +176,14 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
}
}

+ if (callchain_param.mode == CHAIN_GRAPH_REL)
+ child_total = node->children_hit;
+ else
+ child_total = total;
+
/* Now 'iter' contains info of the last callchain_list */
- perf_gtk__add_callchain(&node->rb_root, store, &iter, col);
+ perf_gtk__add_callchain(&node->rb_root, store, &iter, col,
+ child_total);
}
}

@@ -283,8 +297,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}

if (symbol_conf.use_callchain && sort__has_sym) {
+ u64 total;
+
+ if (callchain_param.mode == CHAIN_GRAPH_REL)
+ total = h->stat.period;
+ else
+ total = hists->stats.total_period;
+
perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
- sym_col);
+ sym_col, total);
}
}

Subject: [tip:perf/core] perf gtk/hists: Make column headers resizable

Commit-ID: 1a309426b4fae258dbd86ac0c575a849bf163b7b
Gitweb: http://git.kernel.org/tip/1a309426b4fae258dbd86ac0c575a849bf163b7b
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:15 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:42 -0300

perf gtk/hists: Make column headers resizable

Sometimes it's annoying to see when some symbols have very wierd long
names. So it might be a good idea to make column size changable.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index fa9f8a0..b4a0dd2 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -250,11 +250,16 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_idx++, NULL);
}

- if (symbol_conf.use_callchain && sort__has_sym) {
+ for (col_idx = 0; col_idx < nr_cols; col_idx++) {
GtkTreeViewColumn *column;

- column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), sym_col);
- gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), column);
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ if (col_idx == sym_col) {
+ gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
+ column);
+ }
}

gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));

Subject: [tip:perf/core] perf gtk/hists: Add a double-click handler for callchains

Commit-ID: 450f390ad2538c5e35d830fa5c624708a77dce0a
Gitweb: http://git.kernel.org/tip/450f390ad2538c5e35d830fa5c624708a77dce0a
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:16 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:43 -0300

perf gtk/hists: Add a double-click handler for callchains

If callchain is displayed, add "row-activated" signal handler for
handling double-click or pressing ENTER key action.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index b4a0dd2..3a5d013 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -187,6 +187,18 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
}
}

+static void on_row_activated(GtkTreeView *view, GtkTreePath *path,
+ GtkTreeViewColumn *col __maybe_unused,
+ gpointer user_data __maybe_unused)
+{
+ bool expanded = gtk_tree_view_row_expanded(view, path);
+
+ if (expanded)
+ gtk_tree_view_collapse_row(view, path);
+ else
+ gtk_tree_view_expand_row(view, path, FALSE);
+}
+
static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
float min_pcnt)
{
@@ -314,6 +326,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}
}

+ g_signal_connect(view, "row-activated",
+ G_CALLBACK(on_row_activated), NULL);
gtk_container_add(GTK_CONTAINER(window), view);
}

Subject: [tip:perf/core] perf gtk/hists: Set rules hint for the hist browser

Commit-ID: 9d58d2f66c92fe47dd395947a3d51b9ace7dcc92
Gitweb: http://git.kernel.org/tip/9d58d2f66c92fe47dd395947a3d51b9ace7dcc92
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 4 Jun 2013 18:22:17 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jul 2013 13:52:45 -0300

perf gtk/hists: Set rules hint for the hist browser

The 'rules' means that every second line of the tree view has a shaded
background, which makes it easier to see which cell belongs to which
row in the tree view. It can be useful for a tree view that has a lot
of rows.

Reviewed-by: Pekka Enberg <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/gtk/hists.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 3a5d013..3254903 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -326,6 +326,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
}
}

+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
+
g_signal_connect(view, "row-activated",
G_CALLBACK(on_row_activated), NULL);
gtk_container_add(GTK_CONTAINER(window), view);