2010-06-25 13:59:47

by Arnaldo Carvalho de Melo

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

Hi Ingo,

Please pull from:

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

Regards,

- Arnaldo

Arnaldo Carvalho de Melo (4):
perf ui: Introduce routine ui_browser__is_current_entry
perf ui: Introduce ui_browser->seek to support multiple list structures
perf ui: Separate showing the entries from running the browser
perf ui: Move objdump_line specific stuff out of ui_browser

Gui Jianfeng (1):
perf kvm: Get rid of unused guest_kallsyms

Tom Zanussi (1):
perf scripts perl: Makefile fix

tools/perf/Makefile | 2 +-
tools/perf/builtin-record.c | 9 --
tools/perf/util/newt.c | 185 +++++++++++++++++++++++++------------------
3 files changed, 109 insertions(+), 87 deletions(-)


2010-06-25 13:59:56

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/6] perf ui: Introduce ui_browser->seek to support multiple list structures

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

So that we can use the ui_browser on things like an rb_tree, etc.

Cc: Frédéric Weisbecker <[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/newt.c | 69 ++++++++++++++++++++++++++++++------------------
1 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 1e774e7..0ffc828 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -267,9 +267,42 @@ struct ui_browser {
void *first_visible_entry, *entries;
u16 top, left, width, height;
void *priv;
+ void (*seek)(struct ui_browser *self,
+ off_t offset, int whence);
u32 nr_entries;
};

+static void ui_browser__list_head_seek(struct ui_browser *self,
+ off_t offset, int whence)
+{
+ struct list_head *head = self->entries;
+ struct list_head *pos;
+
+ switch (whence) {
+ case SEEK_SET:
+ pos = head->next;
+ break;
+ case SEEK_CUR:
+ pos = self->first_visible_entry;
+ break;
+ case SEEK_END:
+ pos = head->prev;
+ break;
+ default:
+ return;
+ }
+
+ if (offset > 0) {
+ while (offset-- != 0)
+ pos = pos->next;
+ } else {
+ while (offset++ != 0)
+ pos = pos->prev;
+ }
+
+ self->first_visible_entry = pos;
+}
+
static bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row)
{
return (self->first_visible_entry_idx + row) == self->index;
@@ -292,7 +325,7 @@ static void ui_browser__refresh_dimensions(struct ui_browser *self)
static void ui_browser__reset_index(struct ui_browser *self)
{
self->index = self->first_visible_entry_idx = 0;
- self->first_visible_entry = NULL;
+ self->seek(self, 0, SEEK_SET);
}

static int objdump_line__show(struct objdump_line *self, struct list_head *head,
@@ -408,7 +441,7 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
newtFormAddComponent(self->form, self->sb);

while (1) {
- unsigned int offset;
+ off_t offset;

newtFormRun(self->form, es);

@@ -422,9 +455,8 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
break;
++self->index;
if (self->index == self->first_visible_entry_idx + self->height) {
- struct list_head *pos = self->first_visible_entry;
++self->first_visible_entry_idx;
- self->first_visible_entry = pos->next;
+ self->seek(self, +1, SEEK_CUR);
}
break;
case NEWT_KEY_UP:
@@ -432,9 +464,8 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
break;
--self->index;
if (self->index < self->first_visible_entry_idx) {
- struct list_head *pos = self->first_visible_entry;
--self->first_visible_entry_idx;
- self->first_visible_entry = pos->prev;
+ self->seek(self, -1, SEEK_CUR);
}
break;
case NEWT_KEY_PGDN:
@@ -447,12 +478,7 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
offset = self->nr_entries - 1 - self->index;
self->index += offset;
self->first_visible_entry_idx += offset;
-
- while (offset--) {
- struct list_head *pos = self->first_visible_entry;
- self->first_visible_entry = pos->next;
- }
-
+ self->seek(self, +offset, SEEK_CUR);
break;
case NEWT_KEY_PGUP:
if (self->first_visible_entry_idx == 0)
@@ -465,29 +491,19 @@ static int ui_browser__run(struct ui_browser *self, const char *title,

self->index -= offset;
self->first_visible_entry_idx -= offset;
-
- while (offset--) {
- struct list_head *pos = self->first_visible_entry;
- self->first_visible_entry = pos->prev;
- }
+ self->seek(self, -offset, SEEK_CUR);
break;
case NEWT_KEY_HOME:
ui_browser__reset_index(self);
break;
- case NEWT_KEY_END: {
- struct list_head *head = self->entries;
+ case NEWT_KEY_END:
offset = self->height - 1;

if (offset > self->nr_entries)
offset = self->nr_entries;

self->index = self->first_visible_entry_idx = self->nr_entries - 1 - offset;
- self->first_visible_entry = head->prev;
- while (offset-- != 0) {
- struct list_head *pos = self->first_visible_entry;
- self->first_visible_entry = pos->prev;
- }
- }
+ self->seek(self, -offset, SEEK_END);
break;
case NEWT_KEY_RIGHT:
case NEWT_KEY_LEFT:
@@ -706,7 +722,8 @@ int hist_entry__tui_annotate(struct hist_entry *self)
ui_helpline__push("Press <- or ESC to exit");

memset(&browser, 0, sizeof(browser));
- browser.entries = &head;
+ browser.entries = &head;
+ browser.seek = ui_browser__list_head_seek;
browser.priv = self;
list_for_each_entry(pos, &head, node) {
size_t line_len = strlen(pos->line);
--
1.6.2.5

2010-06-25 13:59:45

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 4/6] perf ui: Separate showing the entries from running the browser

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

Another patch eroding the changes I had to move to a tree widget that
doesn't requires adding all entries in an existing list/tree structure
to a generic tree widget, but instead allows traversing just the entries
that should appear on the screen on a given moment.

Cc: Frédéric Weisbecker <[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/newt.c | 60 +++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 0ffc828..9fa5b20 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -328,6 +328,32 @@ static void ui_browser__reset_index(struct ui_browser *self)
self->seek(self, 0, SEEK_SET);
}

+static int ui_browser__show(struct ui_browser *self, const char *title)
+{
+ if (self->form != NULL)
+ return 0;
+ ui_browser__refresh_dimensions(self);
+ newtCenteredWindow(self->width + 2, self->height, title);
+ self->form = newt_form__new();
+ if (self->form == NULL)
+ return -1;
+
+ self->sb = newtVerticalScrollbar(self->width + 1, 0, self->height,
+ HE_COLORSET_NORMAL,
+ HE_COLORSET_SELECTED);
+ if (self->sb == NULL)
+ return -1;
+
+ newtFormAddHotKey(self->form, NEWT_KEY_UP);
+ newtFormAddHotKey(self->form, NEWT_KEY_DOWN);
+ newtFormAddHotKey(self->form, NEWT_KEY_PGUP);
+ newtFormAddHotKey(self->form, NEWT_KEY_PGDN);
+ newtFormAddHotKey(self->form, NEWT_KEY_HOME);
+ newtFormAddHotKey(self->form, NEWT_KEY_END);
+ newtFormAddComponent(self->form, self->sb);
+ return 0;
+}
+
static int objdump_line__show(struct objdump_line *self, struct list_head *head,
int width, struct hist_entry *he, int len,
bool current_entry)
@@ -406,39 +432,10 @@ static int ui_browser__refresh_entries(struct ui_browser *self)
return 0;
}

-static int ui_browser__run(struct ui_browser *self, const char *title,
- struct newtExitStruct *es)
+static int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
{
- if (self->form) {
- newtFormDestroy(self->form);
- newtPopWindow();
- }
-
- ui_browser__refresh_dimensions(self);
- newtCenteredWindow(self->width + 2, self->height, title);
- self->form = newt_form__new();
- if (self->form == NULL)
- return -1;
-
- self->sb = newtVerticalScrollbar(self->width + 1, 0, self->height,
- HE_COLORSET_NORMAL,
- HE_COLORSET_SELECTED);
- if (self->sb == NULL)
- return -1;
-
- newtFormAddHotKey(self->form, NEWT_KEY_UP);
- newtFormAddHotKey(self->form, NEWT_KEY_DOWN);
- newtFormAddHotKey(self->form, NEWT_KEY_PGUP);
- newtFormAddHotKey(self->form, NEWT_KEY_PGDN);
- newtFormAddHotKey(self->form, ' ');
- newtFormAddHotKey(self->form, NEWT_KEY_HOME);
- newtFormAddHotKey(self->form, NEWT_KEY_END);
- newtFormAddHotKey(self->form, NEWT_KEY_TAB);
- newtFormAddHotKey(self->form, NEWT_KEY_RIGHT);
-
if (ui_browser__refresh_entries(self) < 0)
return -1;
- newtFormAddComponent(self->form, self->sb);

while (1) {
off_t offset;
@@ -733,7 +730,8 @@ int hist_entry__tui_annotate(struct hist_entry *self)
}

browser.width += 18; /* Percentage */
- ret = ui_browser__run(&browser, self->ms.sym->name, &es);
+ ui_browser__show(&browser, self->ms.sym->name);
+ ui_browser__run(&browser, &es);
newtFormDestroy(browser.form);
newtPopWindow();
list_for_each_entry_safe(pos, n, &head, node) {
--
1.6.2.5

2010-06-25 13:59:42

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/6] perf ui: Introduce routine ui_browser__is_current_entry

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

Will be used in more places in the new tree widget.

Cc: Frédéric Weisbecker <[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/newt.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index cf182ca..1e774e7 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -270,6 +270,11 @@ struct ui_browser {
u32 nr_entries;
};

+static bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row)
+{
+ return (self->first_visible_entry_idx + row) == self->index;
+}
+
static void ui_browser__refresh_dimensions(struct ui_browser *self)
{
int cols, rows;
@@ -286,8 +291,8 @@ static void ui_browser__refresh_dimensions(struct ui_browser *self)

static void ui_browser__reset_index(struct ui_browser *self)
{
- self->index = self->first_visible_entry_idx = 0;
- self->first_visible_entry = NULL;
+ self->index = self->first_visible_entry_idx = 0;
+ self->first_visible_entry = NULL;
}

static int objdump_line__show(struct objdump_line *self, struct list_head *head,
@@ -353,7 +358,7 @@ static int ui_browser__refresh_entries(struct ui_browser *self)
pos = list_entry(self->first_visible_entry, struct objdump_line, node);

list_for_each_entry_from(pos, head, node) {
- bool current_entry = (self->first_visible_entry_idx + row) == self->index;
+ bool current_entry = ui_browser__is_current_entry(self, row);
SLsmg_gotorc(self->top + row, self->left);
objdump_line__show(pos, head, self->width,
he, len, current_entry);
--
1.6.2.5

2010-06-25 14:00:30

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 6/6] perf kvm: Get rid of unused guest_kallsyms

From: Gui Jianfeng <[email protected]>

guest_kallsyms is redundant here, remove it.

Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Yanmin Zhang <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Gui Jianfeng <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-record.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 86b1c3b..0df6408 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -445,8 +445,6 @@ static void atexit_header(void)
static void event__synthesize_guest_os(struct machine *machine, void *data)
{
int err;
- char *guest_kallsyms;
- char path[PATH_MAX];
struct perf_session *psession = data;

if (machine__is_host(machine))
@@ -466,13 +464,6 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid);

- if (machine__is_default_guest(machine))
- guest_kallsyms = (char *) symbol_conf.default_guest_kallsyms;
- else {
- sprintf(path, "%s/proc/kallsyms", machine->root_dir);
- guest_kallsyms = path;
- }
-
/*
* We use _stext for guest kernel because guest kernel's /proc/kallsyms
* have no _text sometimes.
--
1.6.2.5

2010-06-25 13:59:40

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/6] perf scripts perl: Makefile fix

From: Tom Zanussi <[email protected]>

Fix a typo introduced by recent Makefile changes, in f9af3a4. Without it, Perl
scripting support won't get compiled in.

Cc: Frédéric Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <1276836006.7762.15.camel@tropicana>
Signed-off-by: Tom Zanussi <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 6aa2fe3..17a3692 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -577,7 +577,7 @@ ifdef NO_LIBPERL
else
PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
- PERL_EMBED_FLAGS=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
+ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)

ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
BASIC_CFLAGS += -DNO_LIBPERL
--
1.6.2.5

2010-06-25 14:00:51

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 5/6] perf ui: Move objdump_line specific stuff out of ui_browser

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

By adding a ui_browser->refresh_entries() pure virtual member.

Cc: Frédéric Weisbecker <[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/newt.c | 49 +++++++++++++++++++++++++++++------------------
1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 9fa5b20..7bdbfd3 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -267,6 +267,7 @@ struct ui_browser {
void *first_visible_entry, *entries;
u16 top, left, width, height;
void *priv;
+ unsigned int (*refresh_entries)(struct ui_browser *self);
void (*seek)(struct ui_browser *self,
off_t offset, int whence);
u32 nr_entries;
@@ -405,26 +406,10 @@ static int objdump_line__show(struct objdump_line *self, struct list_head *head,

static int ui_browser__refresh_entries(struct ui_browser *self)
{
- struct objdump_line *pos;
- struct list_head *head = self->entries;
- struct hist_entry *he = self->priv;
- int row = 0;
- int len = he->ms.sym->end - he->ms.sym->start;
-
- if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries)
- self->first_visible_entry = head->next;
-
- pos = list_entry(self->first_visible_entry, struct objdump_line, node);
-
- list_for_each_entry_from(pos, head, node) {
- bool current_entry = ui_browser__is_current_entry(self, row);
- SLsmg_gotorc(self->top + row, self->left);
- objdump_line__show(pos, head, self->width,
- he, len, current_entry);
- if (++row == self->height)
- break;
- }
+ int row;

+ newtScrollbarSet(self->sb, self->index, self->nr_entries - 1);
+ row = self->refresh_entries(self);
SLsmg_set_color(HE_COLORSET_NORMAL);
SLsmg_fill_region(self->top + row, self->left,
self->height - row, self->width, ' ');
@@ -557,6 +542,31 @@ static char *callchain_list__sym_name(struct callchain_list *self,
return bf;
}

+static unsigned int hist_entry__annotate_browser_refresh(struct ui_browser *self)
+{
+ struct objdump_line *pos;
+ struct list_head *head = self->entries;
+ struct hist_entry *he = self->priv;
+ int row = 0;
+ int len = he->ms.sym->end - he->ms.sym->start;
+
+ if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries)
+ self->first_visible_entry = head->next;
+
+ pos = list_entry(self->first_visible_entry, struct objdump_line, node);
+
+ list_for_each_entry_from(pos, head, node) {
+ bool current_entry = ui_browser__is_current_entry(self, row);
+ SLsmg_gotorc(self->top + row, self->left);
+ objdump_line__show(pos, head, self->width,
+ he, len, current_entry);
+ if (++row == self->height)
+ break;
+ }
+
+ return row;
+}
+
static void __callchain__append_graph_browser(struct callchain_node *self,
newtComponent tree, u64 total,
int *indexes, int depth)
@@ -720,6 +730,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)

memset(&browser, 0, sizeof(browser));
browser.entries = &head;
+ browser.refresh_entries = hist_entry__annotate_browser_refresh;
browser.seek = ui_browser__list_head_seek;
browser.priv = self;
list_for_each_entry(pos, &head, node) {
--
1.6.2.5

2010-06-25 14:17:37

by Ingo Molnar

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


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

> Hi Ingo,
>
> Please pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
>
> Regards,
>
> - Arnaldo
>
> Arnaldo Carvalho de Melo (4):
> perf ui: Introduce routine ui_browser__is_current_entry
> perf ui: Introduce ui_browser->seek to support multiple list structures
> perf ui: Separate showing the entries from running the browser
> perf ui: Move objdump_line specific stuff out of ui_browser
>
> Gui Jianfeng (1):
> perf kvm: Get rid of unused guest_kallsyms
>
> Tom Zanussi (1):
> perf scripts perl: Makefile fix
>
> tools/perf/Makefile | 2 +-
> tools/perf/builtin-record.c | 9 --
> tools/perf/util/newt.c | 185 +++++++++++++++++++++++++------------------
> 3 files changed, 109 insertions(+), 87 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo