2012-05-30 00:11:44

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 0/4] perf/urgent fixes

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

Hi Ingo,

Please consider pulling.

There are 5 other fixes in this repo, that went on my previous
perf/urgent pull request.

Thanks,

- Arnaldo


The following changes since commit a00dc319e98161949aa87f71a17db32e925c3257:

perf record: Fix branch_stack type in perf_record_opts (2012-05-25 18:32:44 -0300)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo

for you to fetch changes up to a44b45f236dd1c1a8caccf9a078adf2941a20267:

perf annotate browser: The idx_asm field should be used in asm only view (2012-05-29 20:52:38 -0300)

----------------------------------------------------------------
Fixes for perf/urgent

. Fix fallback to --stdio when TUI not supported, from Namhyung Kim.

. Use right cast for pointers/long in libtraceevent, from Namhyung Kim.

. Be consistent on using the right error reporting interface for fatal errors,
from Namhyung Kim.

. Fix fallback to --stdio when TUI not supported, from Namhyung Kim.

. Use the right index in asm only view in the annotate browser.

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf annotate browser: The idx_asm field should be used in asm only view

Namhyung Kim (3):
tools lib traceevent: Silence compiler warning on 32bit build
perf ui: Make --stdio default when TUI is not supported
perf tools: Convert critical messages to ui__error()

tools/lib/traceevent/parse-filter.c | 2 +-
tools/perf/builtin-annotate.c | 2 +-
tools/perf/builtin-record.c | 14 +++++++-------
tools/perf/builtin-report.c | 14 ++++++--------
tools/perf/builtin-top.c | 22 +++++++++++-----------
tools/perf/ui/browsers/annotate.c | 6 +++++-
tools/perf/ui/setup.c | 1 +
7 files changed, 32 insertions(+), 29 deletions(-)


2012-05-30 00:11:42

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/4] perf tools: Convert critical messages to ui__error()

From: Namhyung Kim <[email protected]>

There were places where use ui__warning (or even fprintf) to show
critical messages. This patch converts them to ui__error so that the
front-end code can implement appropriate behavior.

Signed-off-by: Namhyung Kim <[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/builtin-annotate.c | 2 +-
tools/perf/builtin-record.c | 14 +++++++-------
tools/perf/builtin-report.c | 14 ++++++--------
tools/perf/builtin-top.c | 22 +++++++++++-----------
4 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 806e0a2..67522cf 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
}

if (total_nr_samples == 0) {
- ui__warning("The %s file has no samples!\n", session->filename);
+ ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}
out_delete:
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e5cb084..f95840d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -264,7 +264,7 @@ try_again:
}

if (err == ENOENT) {
- ui__warning("The %s event is not supported.\n",
+ ui__error("The %s event is not supported.\n",
event_name(pos));
exit(EXIT_FAILURE);
}
@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
usage_with_options(record_usage, record_options);

if (rec->force && rec->append_file) {
- fprintf(stderr, "Can't overwrite and append at the same time."
- " You need to choose between -f and -A");
+ ui__error("Can't overwrite and append at the same time."
+ " You need to choose between -f and -A");
usage_with_options(record_usage, record_options);
} else if (rec->append_file) {
rec->write_mode = WRITE_APPEND;
@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
}

if (nr_cgroups && !rec->opts.target.system_wide) {
- fprintf(stderr, "cgroup monitoring only available in"
- " system-wide mode\n");
+ ui__error("cgroup monitoring only available in"
+ " system-wide mode\n");
usage_with_options(record_usage, record_options);
}

@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno;

perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
- ui__warning("%s", errbuf);
+ ui__error("%s", errbuf);

err = -saved_errno;
goto out_free_fd;
@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
else if (rec->opts.freq) {
rec->opts.default_interval = rec->opts.freq;
} else {
- fprintf(stderr, "frequency and count are zero, aborting\n");
+ ui__error("frequency and count are zero, aborting\n");
err = -EINVAL;
goto out_free_fd;
}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d58e414..8c767c6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)

if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
- ui__warning("Selected --sort parent, but no "
+ ui__error("Selected --sort parent, but no "
"callchain data. Did you call "
"'perf record' without -g?\n");
return -EINVAL;
}
if (symbol_conf.use_callchain) {
- ui__warning("Selected -g but no callchain data. Did "
+ ui__error("Selected -g but no callchain data. Did "
"you call 'perf record' without -g?\n");
return -1;
}
@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
!symbol_conf.use_callchain) {
symbol_conf.use_callchain = true;
if (callchain_register_param(&callchain_param) < 0) {
- ui__warning("Can't register callchain "
- "params.\n");
+ ui__error("Can't register callchain params.\n");
return -EINVAL;
}
}

if (sort__branch_mode == 1) {
if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
- fprintf(stderr, "selected -b but no branch data."
- " Did you call perf record without"
- " -b?\n");
+ ui__error("Selected -b but no branch data. "
+ "Did you call perf record without -b?\n");
return -1;
}
}
@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep)
}

if (nr_samples == 0) {
- ui__warning("The %s file has no samples!\n", session->filename);
+ ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index d4a5f9b..871b540 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -959,16 +959,16 @@ try_again:
}

if (err == ENOENT) {
- ui__warning("The %s event is not supported.\n",
+ ui__error("The %s event is not supported.\n",
event_name(counter));
goto out_err;
} else if (err == EMFILE) {
- ui__warning("Too many events are opened.\n"
+ ui__error("Too many events are opened.\n"
"Try again after reducing the number of events\n");
goto out_err;
}

- ui__warning("The sys_perf_event_open() syscall "
+ ui__error("The sys_perf_event_open() syscall "
"returned with %d (%s). /bin/dmesg "
"may provide additional information.\n"
"No CONFIG_PERF_EVENTS=y kernel support "
@@ -978,7 +978,7 @@ try_again:
}

if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) {
- ui__warning("Failed to mmap with %d (%s)\n",
+ ui__error("Failed to mmap with %d (%s)\n",
errno, strerror(errno));
goto out_err;
}
@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top)
{
if (!top->sort_has_symbols) {
if (symbol_conf.use_callchain) {
- ui__warning("Selected -g but \"sym\" not present in --sort/-s.");
+ ui__error("Selected -g but \"sym\" not present in --sort/-s.");
return -EINVAL;
}
} else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) {
if (callchain_register_param(&callchain_param) < 0) {
- ui__warning("Can't register callchain params.\n");
+ ui__error("Can't register callchain params.\n");
return -EINVAL;
}
}
@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)

if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
display_thread), top)) {
- printf("Could not create display thread.\n");
+ ui__error("Could not create display thread.\n");
exit(-1);
}

@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top)

param.sched_priority = top->realtime_prio;
if (sched_setscheduler(0, SCHED_FIFO, &param)) {
- printf("Could not set realtime priority.\n");
+ ui__error("Could not set realtime priority.\n");
exit(-1);
}
}
@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno;

perf_target__strerror(&top.target, status, errbuf, BUFSIZ);
- ui__warning("%s", errbuf);
+ ui__error("%s", errbuf);

status = -saved_errno;
goto out_delete_evlist;
@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)

if (!top.evlist->nr_entries &&
perf_evlist__add_default(top.evlist) < 0) {
- pr_err("Not enough memory for event selector list\n");
+ ui__error("Not enough memory for event selector list\n");
return -ENOMEM;
}

@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
else if (top.freq) {
top.default_interval = top.freq;
} else {
- fprintf(stderr, "frequency and count are zero, aborting\n");
+ ui__error("frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
}

--
1.7.9.2.358.g22243

2012-05-30 00:12:03

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/4] tools lib traceevent: Silence compiler warning on 32bit build

From: Namhyung Kim <[email protected]>

The gcc complains about casting a pointer to unsigned long long directly:

SUBDIR ../lib/traceevent/
CC FPIC event-parse.o
CC FPIC trace-seq.o
CC FPIC parse-filter.o
/home/namhyung/project/linux/tools/lib/traceevent/parse-filter.c: In function ‘get_value’:
/home/namhyung/project/linux/tools/lib/traceevent/parse-filter.c:1588: warning: cast from pointer to integer of different size
CC FPIC parse-utils.o
BUILD STATIC LIB libtraceevent.a

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index e08d21f..dfcfe2c 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1584,7 +1584,7 @@ get_value(struct event_format *event,
const char *name;

name = get_comm(event, record);
- return (unsigned long long)name;
+ return (unsigned long)name;
}

pevent_read_number_field(field, record->data, &val);
--
1.7.9.2.358.g22243

2012-05-30 00:11:40

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 4/4] perf annotate browser: The idx_asm field should be used in asm only view

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

When hide_src_view is true we can't use browser_disasm_line->idx, that
takes into account also non asm lines, we must use browser_disasm_line->idx_asm
instead, otherwise we may end up with an index after the number of
entries, oops, fix it.

Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/annotate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6e0ef79..aaf36ce 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -300,10 +300,14 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
{
struct browser_disasm_line *bpos;
struct disasm_line *pos;
+ u32 idx;

bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
pos = ((struct disasm_line *)bpos) - 1;
- annotate_browser__set_top(browser, pos, bpos->idx);
+ idx = bpos->idx;
+ if (browser->hide_src_code)
+ idx = bpos->idx_asm;
+ annotate_browser__set_top(browser, pos, idx);
browser->curr_hot = nd;
}

--
1.7.9.2.358.g22243

2012-05-30 00:12:23

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/4] perf ui: Make --stdio default when TUI is not supported

From: Namhyung Kim <[email protected]>

The commit dc41b9b8f02db ("perf ui: Change fallback policy of
setup_browser") changed default behavior of the function but missed
setting the use_browser variable to 0 accidently. So perf report ends up
doing nothing in such cases. Fix it.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[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/setup.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 9f5f888..791fb15 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -22,6 +22,7 @@ void setup_browser(bool fallback_to_pager)
break;
/* fall through */
default:
+ use_browser = 0;
if (fallback_to_pager)
setup_pager();
break;
--
1.7.9.2.358.g22243

2012-05-30 07:00:29

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 0/4] perf/urgent fixes


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

> From: Arnaldo Carvalho de Melo <[email protected]>
>
> Hi Ingo,
>
> Please consider pulling.
>
> There are 5 other fixes in this repo, that went on my previous
> perf/urgent pull request.
>
> Thanks,
>
> - Arnaldo
>
>
> The following changes since commit a00dc319e98161949aa87f71a17db32e925c3257:
>
> perf record: Fix branch_stack type in perf_record_opts (2012-05-25 18:32:44 -0300)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo
>
> for you to fetch changes up to a44b45f236dd1c1a8caccf9a078adf2941a20267:
>
> perf annotate browser: The idx_asm field should be used in asm only view (2012-05-29 20:52:38 -0300)
>
> ----------------------------------------------------------------
> Fixes for perf/urgent
>
> . Fix fallback to --stdio when TUI not supported, from Namhyung Kim.
>
> . Use right cast for pointers/long in libtraceevent, from Namhyung Kim.
>
> . Be consistent on using the right error reporting interface for fatal errors,
> from Namhyung Kim.
>
> . Fix fallback to --stdio when TUI not supported, from Namhyung Kim.
>
> . Use the right index in asm only view in the annotate browser.
>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
>
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (1):
> perf annotate browser: The idx_asm field should be used in asm only view
>
> Namhyung Kim (3):
> tools lib traceevent: Silence compiler warning on 32bit build
> perf ui: Make --stdio default when TUI is not supported
> perf tools: Convert critical messages to ui__error()
>
> tools/lib/traceevent/parse-filter.c | 2 +-
> tools/perf/builtin-annotate.c | 2 +-
> tools/perf/builtin-record.c | 14 +++++++-------
> tools/perf/builtin-report.c | 14 ++++++--------
> tools/perf/builtin-top.c | 22 +++++++++++-----------
> tools/perf/ui/browsers/annotate.c | 6 +++++-
> tools/perf/ui/setup.c | 1 +
> 7 files changed, 32 insertions(+), 29 deletions(-)

Pulled, thanks Arnaldo!

Ingo