All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL 0/6] perf/core fixes and improvements
@ 2011-08-16 14:41 Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 1/6] perf list: Fix exit value Arnaldo Carvalho de Melo
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Peter Zijlstra,
	Stephane Eranian, acme

Hi Ingo,

        Please consider pulling from:

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

Regards,

- Arnaldo

Stephane Eranian (6):
  perf list: Fix exit value
  perf evlist: Fix missing event name init for default event (v2)
  perf tools: Fix error handling of unknown events
  perf annotate: Make output more readable
  perf annotate: Add --symfs option
  perf stat: Add -o and --append options

 tools/perf/Documentation/perf-annotate.txt |   11 ++
 tools/perf/Documentation/perf-stat.txt     |    7 ++
 tools/perf/builtin-annotate.c              |    6 +
 tools/perf/builtin-stat.c                  |  155 ++++++++++++++++-----------
 tools/perf/util/annotate.c                 |    5 +-
 tools/perf/util/color.c                    |    2 +-
 tools/perf/util/evlist.c                   |   11 ++-
 tools/perf/util/parse-events.c             |    8 +-
 tools/perf/util/symbol.c                   |    2 +
 tools/perf/util/symbol.h                   |    4 +-
 10 files changed, 141 insertions(+), 70 deletions(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] perf list: Fix exit value
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 2/6] perf evlist: Fix missing event name init for default event (v2) Arnaldo Carvalho de Melo
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Frederic Weisbecker, Ingo Molnar,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

This patch fixes an issue with the exit value of perf list:

$ perf list; echo $?
129

perf list returns an error exit code even though there is no error.

There was a stray exit(129) in print_events(). This patch removes this
exit().

$ perf list; echo $?
0

$ perf list hw sw
  cpu-cycles OR cycles                               [Hardware event]
  stalled-cycles-frontend OR idle-cycles-frontend    [Hardware event]
  stalled-cycles-backend OR idle-cycles-backend      [Hardware event]
  instructions                                       [Hardware event]
  cache-references                                   [Hardware event]
  cache-misses                                       [Hardware event]
  branch-instructions OR branches                    [Hardware event]
  branch-misses                                      [Hardware event]
  bus-cycles                                         [Hardware event]

  cpu-clock                                          [Software event]
  task-clock                                         [Software event]
  page-faults OR faults                              [Software event]
  minor-faults                                       [Software event]
  major-faults                                       [Software event]
  context-switches OR cs                             [Software event]
  cpu-migrations OR migrations                       [Software event]
  alignment-faults                                   [Software event]
  emulation-faults                                   [Software event]
$ echo $?
0

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20110523123917.GA31060@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4ea7e19..d93f3ce 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1097,6 +1097,4 @@ void print_events(const char *event_glob)
 	printf("\n");
 
 	print_tracepoint_events(NULL, NULL);
-
-	exit(129);
 }
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] perf evlist: Fix missing event name init for default event (v2)
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 1/6] perf list: Fix exit value Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 3/6] perf tools: Fix error handling of unknown events Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

When no event is given to perf record, perf top, a default event is
initialized (cycles). However, perf_evlist__add_default() was not
setting the symbolic name for the event. Perf top worked simply because
it was reconstructing the name from the event code. But it should not
have to do this. This patch initializes the evsel->name field properly.

This second version improves the code flow on the non error path.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20110607161936.GA8163@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
[committer note: Use perf_evsel__delete() instead of plain free()]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e03e7bc..c12bd47 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -85,10 +85,19 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
 	struct perf_evsel *evsel = perf_evsel__new(&attr, 0);
 
 	if (evsel == NULL)
-		return -ENOMEM;
+		goto error;
+
+	/* use strdup() because free(evsel) assumes name is allocated */
+	evsel->name = strdup("cycles");
+	if (!evsel->name)
+		goto error_free;
 
 	perf_evlist__add(evlist, evsel);
 	return 0;
+error_free:
+	perf_evsel__delete(evsel);
+error:
+	return -ENOMEM;
 }
 
 void perf_evlist__disable(struct perf_evlist *evlist)
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] perf tools: Fix error handling of unknown events
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 1/6] perf list: Fix exit value Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 2/6] perf evlist: Fix missing event name init for default event (v2) Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 4/6] perf annotate: Make output more readable Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

There was a problem with the parse_events() code not printing the
correct event name when an event was unknown and starting with an 'r'.
The source of the problem was the way raw notation was parsed.

Without the patch:
	$ perf stat -e retired_foo
	invalid event modifier: 'tired_foo'

With the patch:
	$ perf stat -e retired_foo
	invalid or unsupported event: 'retired_foo'

This also covers the case where the name of the event was not printed at
all when perf was linked with libpfm4.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20110723021043.GA20178@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d93f3ce..928918b 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -697,7 +697,11 @@ parse_raw_event(const char **strp, struct perf_event_attr *attr)
 		return EVT_FAILED;
 	n = hex2u64(str + 1, &config);
 	if (n > 0) {
-		*strp = str + n + 1;
+		const char *end = str + n + 1;
+		if (*end != '\0' && *end != ',' && *end != ':')
+			return EVT_FAILED;
+
+		*strp = end;
 		attr->type = PERF_TYPE_RAW;
 		attr->config = config;
 		return EVT_HANDLED;
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] perf annotate: Make output more readable
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2011-08-16 14:41 ` [PATCH 3/6] perf tools: Fix error handling of unknown events Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 5/6] perf annotate: Add --symfs option Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

This patch adds two new options to perf annotate:
	- --no-asm-raw : Do not display raw instruction encodings
	- --no-source  : Do not interleave source code with assembly code

We believe those options make the output of annotate more readable.

Systematically displaying source can make it hard to follow code and
especially optimized code.

Raw encodings are not useful in most cases.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20110517153207.GA9834@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
[committer note: Use the 'no-' option inverting logic]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt |    8 ++++++++
 tools/perf/builtin-annotate.c              |    4 ++++
 tools/perf/util/annotate.c                 |    5 ++++-
 tools/perf/util/symbol.c                   |    2 ++
 tools/perf/util/symbol.h                   |    4 +++-
 5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 85c5f02..5bc0600 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -72,6 +72,14 @@ OPTIONS
 	CPUs are specified with -: 0-2. Default is to report samples on all
 	CPUs.
 
+--asm-raw::
+	Show raw instruction encoding of assembly instructions. They
+	are displayed by default, disable with --no-asm-raw.
+
+--source::
+	Interleave source code with assembly code. Enabled by default,
+	disable with --no-source.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 555aefd..5015e04 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -267,6 +267,10 @@ static const struct option options[] = {
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
 		    "Don't shorten the displayed pathnames"),
 	OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+	OPT_BOOLEAN('0', "source", &symbol_conf.annotate_src,
+		    "Interleave source code with assembly code (default)"),
+	OPT_BOOLEAN('0', "asm-raw", &symbol_conf.annotate_asm_raw,
+		    "Display raw encoding of assembly instructions (default)"),
 	OPT_END()
 };
 
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e01af2b..01d36ba 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -324,9 +324,12 @@ fallback:
 
 	snprintf(command, sizeof(command),
 		 "objdump --start-address=0x%016" PRIx64
-		 " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand",
+		 " --stop-address=0x%016" PRIx64
+		 " -d %s %s -C %s|grep -v %s|expand",
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->end),
+		 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
+		 symbol_conf.annotate_src ? "-S" : "",
 		 symfs_filename, filename);
 
 	pr_debug("Executing: %s\n", command);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 469c026..245e60d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -46,6 +46,8 @@ struct symbol_conf symbol_conf = {
 	.exclude_other	  = true,
 	.use_modules	  = true,
 	.try_vmlinux_path = true,
+	.annotate_asm_raw = true,
+	.annotate_src	  = true,
 	.symfs            = "",
 };
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 4f377d9..7733f0b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -76,7 +76,9 @@ struct symbol_conf {
 			exclude_other,
 			show_cpu_utilization,
 			initialized,
-			kptr_restrict;
+			kptr_restrict,
+			annotate_asm_raw,
+			annotate_src;
 	const char	*vmlinux_name,
 			*kallsyms_name,
 			*source_prefix,
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] perf annotate: Add --symfs option
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2011-08-16 14:41 ` [PATCH 4/6] perf annotate: Make output more readable Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-16 14:41 ` [PATCH 6/6] perf stat: Add -o and --append options Arnaldo Carvalho de Melo
  2011-08-17 21:36 ` [GIT PULL 0/6] perf/core fixes and improvements Ingo Molnar
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar, Peter Zijlstra,
	David Ahern, Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

If you have --symfs in perf report, then you also need it for perf
annotate.  This allows off-box assembly level analysis of perf.data
samples.

This patch complements:

commit ec5761eab318e50e69fcf8e63e9edaef5949c067
Author: David Ahern <daahern@cisco.com>
Date:   Thu Dec 9 13:27:07 2010 -0700

    perf symbols: Add symfs option for off-box analysis using specified tree

Acked-by: David Ahern <daahern@cisco.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: David Ahern <daahern@cisco.com>
Link: http://lkml.kernel.org/r/20110729232040.GA21838@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt |    3 +++
 tools/perf/builtin-annotate.c              |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 5bc0600..98a31e3 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -80,6 +80,9 @@ OPTIONS
 	Interleave source code with assembly code. Enabled by default,
 	disable with --no-source.
 
+--symfs=<directory>::
+        Look for files with symbols relative to this directory.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 5015e04..c5be288 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -267,6 +267,8 @@ static const struct option options[] = {
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
 		    "Don't shorten the displayed pathnames"),
 	OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+		   "Look for files with symbols relative to this directory"),
 	OPT_BOOLEAN('0', "source", &symbol_conf.annotate_src,
 		    "Interleave source code with assembly code (default)"),
 	OPT_BOOLEAN('0', "asm-raw", &symbol_conf.annotate_asm_raw,
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/6] perf stat: Add -o and --append options
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2011-08-16 14:41 ` [PATCH 5/6] perf annotate: Add --symfs option Arnaldo Carvalho de Melo
@ 2011-08-16 14:41 ` Arnaldo Carvalho de Melo
  2011-08-17 21:36 ` [GIT PULL 0/6] perf/core fixes and improvements Ingo Molnar
  6 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-16 14:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

This patch adds an option (-o) to save the output of perf stat into a
file. You could do this with perf record but not with perf stat.
Instead, you had to fiddle with stderr to save the counts into a
separate file.

The patch also adds the --append option so that results can be
concatenated into a single file across runs. Each run of the tool is
clearly separated by a comment line starting with a hash mark. The -A
option of perf record is already used by perf stat, so we only add a
long option.

$ perf stat -o res.txt date
$ cat res.txt

 Performance counter stats for 'date':

          0.791306 task-clock                #    0.668 CPUs utilized
                 2 context-switches          #    0.003 M/sec
                 0 CPU-migrations            #    0.000 M/sec
               197 page-faults               #    0.249 M/sec
           1878143 cycles                    #    2.373 GHz
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
           1083367 instructions              #    0.58  insns per cycle
            193027 branches                  #  243.935 M/sec
              9014 branch-misses             #    4.67% of all branches

       0.001184746 seconds time elapsed

The option can be combined with -x to make the output file much easier
to parse.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20110815202233.GA18535@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-stat.txt |    7 ++
 tools/perf/builtin-stat.c              |  155 +++++++++++++++++++-------------
 tools/perf/util/color.c                |    2 +-
 3 files changed, 100 insertions(+), 64 deletions(-)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 918cc38..08394c4 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -94,6 +94,13 @@ an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must ha
 corresponding events, i.e., they always refer to events defined earlier on the command
 line.
 
+-o file::
+-output file::
+Print the output into the designated file.
+
+--append::
+Append to the output file designated with the -o option. Ignored if -o is not specified.
+
 EXAMPLES
 --------
 
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1ad04ce..a22393d 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -193,6 +193,8 @@ static int			big_num_opt			=  -1;
 static const char		*cpu_list;
 static const char		*csv_sep			= NULL;
 static bool			csv_output			= false;
+static const char		*output_name			= NULL;
+static FILE			*output				= NULL;
 
 static volatile int done = 0;
 
@@ -351,7 +353,7 @@ static int read_counter_aggr(struct perf_evsel *counter)
 		update_stats(&ps->res_stats[i], count[i]);
 
 	if (verbose) {
-		fprintf(stderr, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
+		fprintf(output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
 			event_name(counter), count[0], count[1], count[2]);
 	}
 
@@ -518,9 +520,9 @@ static void print_noise_pct(double total, double avg)
 		pct = 100.0*total/avg;
 
 	if (csv_output)
-		fprintf(stderr, "%s%.2f%%", csv_sep, pct);
+		fprintf(output, "%s%.2f%%", csv_sep, pct);
 	else
-		fprintf(stderr, "  ( +-%6.2f%% )", pct);
+		fprintf(output, "  ( +-%6.2f%% )", pct);
 }
 
 static void print_noise(struct perf_evsel *evsel, double avg)
@@ -545,16 +547,17 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
 			csv_output ? 0 : -4,
 			evsel_list->cpus->map[cpu], csv_sep);
 
-	fprintf(stderr, fmt, cpustr, msecs, csv_sep, event_name(evsel));
+	fprintf(output, fmt, cpustr, msecs, csv_sep, event_name(evsel));
 
 	if (evsel->cgrp)
-		fprintf(stderr, "%s%s", csv_sep, evsel->cgrp->name);
+		fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
 
 	if (csv_output)
 		return;
 
 	if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
-		fprintf(stderr, " # %8.3f CPUs utilized          ", avg / avg_stats(&walltime_nsecs_stats));
+		fprintf(output, " # %8.3f CPUs utilized          ",
+			avg / avg_stats(&walltime_nsecs_stats));
 }
 
 static void print_stalled_cycles_frontend(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -575,9 +578,9 @@ static void print_stalled_cycles_frontend(int cpu, struct perf_evsel *evsel __us
 	else if (ratio > 10.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " frontend cycles idle   ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " frontend cycles idle   ");
 }
 
 static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -598,9 +601,9 @@ static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __use
 	else if (ratio > 20.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " backend  cycles idle   ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " backend  cycles idle   ");
 }
 
 static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -621,9 +624,9 @@ static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all branches        ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all branches        ");
 }
 
 static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -644,9 +647,9 @@ static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, dou
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all L1-dcache hits  ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all L1-dcache hits  ");
 }
 
 static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -667,9 +670,9 @@ static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, dou
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all L1-icache hits  ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all L1-icache hits  ");
 }
 
 static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -690,9 +693,9 @@ static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, do
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all dTLB cache hits ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all dTLB cache hits ");
 }
 
 static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -713,9 +716,9 @@ static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, do
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all iTLB cache hits ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all iTLB cache hits ");
 }
 
 static void print_ll_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -736,9 +739,9 @@ static void print_ll_cache_misses(int cpu, struct perf_evsel *evsel __used, doub
 	else if (ratio > 5.0)
 		color = PERF_COLOR_YELLOW;
 
-	fprintf(stderr, " #  ");
-	color_fprintf(stderr, color, "%6.2f%%", ratio);
-	fprintf(stderr, " of all LL-cache hits   ");
+	fprintf(output, " #  ");
+	color_fprintf(output, color, "%6.2f%%", ratio);
+	fprintf(output, " of all LL-cache hits   ");
 }
 
 static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
@@ -761,10 +764,10 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
 	else
 		cpu = 0;
 
-	fprintf(stderr, fmt, cpustr, avg, csv_sep, event_name(evsel));
+	fprintf(output, fmt, cpustr, avg, csv_sep, event_name(evsel));
 
 	if (evsel->cgrp)
-		fprintf(stderr, "%s%s", csv_sep, evsel->cgrp->name);
+		fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
 
 	if (csv_output)
 		return;
@@ -775,14 +778,14 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
 		if (total)
 			ratio = avg / total;
 
-		fprintf(stderr, " #   %5.2f  insns per cycle        ", ratio);
+		fprintf(output, " #   %5.2f  insns per cycle        ", ratio);
 
 		total = avg_stats(&runtime_stalled_cycles_front_stats[cpu]);
 		total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[cpu]));
 
 		if (total && avg) {
 			ratio = total / avg;
-			fprintf(stderr, "\n                                             #   %5.2f  stalled cycles per insn", ratio);
+			fprintf(output, "\n                                             #   %5.2f  stalled cycles per insn", ratio);
 		}
 
 	} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
@@ -830,7 +833,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
 		if (total)
 			ratio = avg * 100 / total;
 
-		fprintf(stderr, " # %8.3f %% of all cache refs    ", ratio);
+		fprintf(output, " # %8.3f %% of all cache refs    ", ratio);
 
 	} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
 		print_stalled_cycles_frontend(cpu, evsel, avg);
@@ -842,16 +845,16 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
 		if (total)
 			ratio = 1.0 * avg / total;
 
-		fprintf(stderr, " # %8.3f GHz                    ", ratio);
+		fprintf(output, " # %8.3f GHz                    ", ratio);
 	} else if (runtime_nsecs_stats[cpu].n != 0) {
 		total = avg_stats(&runtime_nsecs_stats[cpu]);
 
 		if (total)
 			ratio = 1000.0 * avg / total;
 
-		fprintf(stderr, " # %8.3f M/sec                  ", ratio);
+		fprintf(output, " # %8.3f M/sec                  ", ratio);
 	} else {
-		fprintf(stderr, "                                   ");
+		fprintf(output, "                                   ");
 	}
 }
 
@@ -866,7 +869,7 @@ static void print_counter_aggr(struct perf_evsel *counter)
 	int scaled = counter->counts->scaled;
 
 	if (scaled == -1) {
-		fprintf(stderr, "%*s%s%*s",
+		fprintf(output, "%*s%s%*s",
 			csv_output ? 0 : 18,
 			counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
 			csv_sep,
@@ -874,9 +877,9 @@ static void print_counter_aggr(struct perf_evsel *counter)
 			event_name(counter));
 
 		if (counter->cgrp)
-			fprintf(stderr, "%s%s", csv_sep, counter->cgrp->name);
+			fprintf(output, "%s%s", csv_sep, counter->cgrp->name);
 
-		fputc('\n', stderr);
+		fputc('\n', output);
 		return;
 	}
 
@@ -888,7 +891,7 @@ static void print_counter_aggr(struct perf_evsel *counter)
 	print_noise(counter, avg);
 
 	if (csv_output) {
-		fputc('\n', stderr);
+		fputc('\n', output);
 		return;
 	}
 
@@ -898,9 +901,9 @@ static void print_counter_aggr(struct perf_evsel *counter)
 		avg_enabled = avg_stats(&ps->res_stats[1]);
 		avg_running = avg_stats(&ps->res_stats[2]);
 
-		fprintf(stderr, " [%5.2f%%]", 100 * avg_running / avg_enabled);
+		fprintf(output, " [%5.2f%%]", 100 * avg_running / avg_enabled);
 	}
-	fprintf(stderr, "\n");
+	fprintf(output, "\n");
 }
 
 /*
@@ -917,7 +920,7 @@ static void print_counter(struct perf_evsel *counter)
 		ena = counter->counts->cpu[cpu].ena;
 		run = counter->counts->cpu[cpu].run;
 		if (run == 0 || ena == 0) {
-			fprintf(stderr, "CPU%*d%s%*s%s%*s",
+			fprintf(output, "CPU%*d%s%*s%s%*s",
 				csv_output ? 0 : -4,
 				evsel_list->cpus->map[cpu], csv_sep,
 				csv_output ? 0 : 18,
@@ -927,9 +930,10 @@ static void print_counter(struct perf_evsel *counter)
 				event_name(counter));
 
 			if (counter->cgrp)
-				fprintf(stderr, "%s%s", csv_sep, counter->cgrp->name);
+				fprintf(output, "%s%s",
+					csv_sep, counter->cgrp->name);
 
-			fputc('\n', stderr);
+			fputc('\n', output);
 			continue;
 		}
 
@@ -942,9 +946,10 @@ static void print_counter(struct perf_evsel *counter)
 			print_noise(counter, 1.0);
 
 			if (run != ena)
-				fprintf(stderr, "  (%.2f%%)", 100.0 * run / ena);
+				fprintf(output, "  (%.2f%%)",
+					100.0 * run / ena);
 		}
-		fputc('\n', stderr);
+		fputc('\n', output);
 	}
 }
 
@@ -956,21 +961,21 @@ static void print_stat(int argc, const char **argv)
 	fflush(stdout);
 
 	if (!csv_output) {
-		fprintf(stderr, "\n");
-		fprintf(stderr, " Performance counter stats for ");
+		fprintf(output, "\n");
+		fprintf(output, " Performance counter stats for ");
 		if(target_pid == -1 && target_tid == -1) {
-			fprintf(stderr, "\'%s", argv[0]);
+			fprintf(output, "\'%s", argv[0]);
 			for (i = 1; i < argc; i++)
-				fprintf(stderr, " %s", argv[i]);
+				fprintf(output, " %s", argv[i]);
 		} else if (target_pid != -1)
-			fprintf(stderr, "process id \'%d", target_pid);
+			fprintf(output, "process id \'%d", target_pid);
 		else
-			fprintf(stderr, "thread id \'%d", target_tid);
+			fprintf(output, "thread id \'%d", target_tid);
 
-		fprintf(stderr, "\'");
+		fprintf(output, "\'");
 		if (run_count > 1)
-			fprintf(stderr, " (%d runs)", run_count);
-		fprintf(stderr, ":\n\n");
+			fprintf(output, " (%d runs)", run_count);
+		fprintf(output, ":\n\n");
 	}
 
 	if (no_aggr) {
@@ -983,15 +988,15 @@ static void print_stat(int argc, const char **argv)
 
 	if (!csv_output) {
 		if (!null_run)
-			fprintf(stderr, "\n");
-		fprintf(stderr, " %17.9f seconds time elapsed",
+			fprintf(output, "\n");
+		fprintf(output, " %17.9f seconds time elapsed",
 				avg_stats(&walltime_nsecs_stats)/1e9);
 		if (run_count > 1) {
-			fprintf(stderr, "                                        ");
+			fprintf(output, "                                        ");
 			print_noise_pct(stddev_stats(&walltime_nsecs_stats),
 					avg_stats(&walltime_nsecs_stats));
 		}
-		fprintf(stderr, "\n\n");
+		fprintf(output, "\n\n");
 	}
 }
 
@@ -1029,6 +1034,8 @@ static int stat__set_big_num(const struct option *opt __used,
 	return 0;
 }
 
+static bool append_file;
+
 static const struct option options[] = {
 	OPT_CALLBACK('e', "event", &evsel_list, "event",
 		     "event selector. use 'perf list' to list available events",
@@ -1067,6 +1074,9 @@ static const struct option options[] = {
 	OPT_CALLBACK('G', "cgroup", &evsel_list, "name",
 		     "monitor event in cgroup name only",
 		     parse_cgroups),
+	OPT_STRING('o', "output", &output_name, "file",
+		    "output file name"),
+	OPT_BOOLEAN(0, "append", &append_file, "append to the output file"),
 	OPT_END()
 };
 
@@ -1138,6 +1148,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
 {
 	struct perf_evsel *pos;
 	int status = -ENOMEM;
+	const char *mode;
 
 	setlocale(LC_ALL, "");
 
@@ -1148,6 +1159,23 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
 	argc = parse_options(argc, argv, options, stat_usage,
 		PARSE_OPT_STOP_AT_NON_OPTION);
 
+	output = stderr;
+	if (output_name && strcmp(output_name, "-"))
+		output = NULL;
+
+	if (!output) {
+		struct timespec tm;
+		mode = append_file ? "a" : "w";
+
+		output = fopen(output_name, mode);
+		if (!output) {
+			perror("failed to create output file");
+			exit(-1);
+		}
+		clock_gettime(CLOCK_REALTIME, &tm);
+		fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
+	}
+
 	if (csv_sep)
 		csv_output = true;
 	else
@@ -1223,7 +1251,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
 	status = 0;
 	for (run_idx = 0; run_idx < run_count; run_idx++) {
 		if (run_count != 1 && verbose)
-			fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx + 1);
+			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
+				run_idx + 1);
 
 		if (sync_run)
 			sync();
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index e191eb9..521c38a 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -200,7 +200,7 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
 	 * Auto-detect:
 	 */
 	if (perf_use_color_default < 0) {
-		if (isatty(1) || pager_in_use())
+		if (isatty(fileno(fp)) || pager_in_use())
 			perf_use_color_default = 1;
 		else
 			perf_use_color_default = 0;
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [GIT PULL 0/6] perf/core fixes and improvements
  2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
                   ` (5 preceding siblings ...)
  2011-08-16 14:41 ` [PATCH 6/6] perf stat: Add -o and --append options Arnaldo Carvalho de Melo
@ 2011-08-17 21:36 ` Ingo Molnar
  2011-08-18 12:43   ` Arnaldo Carvalho de Melo
  6 siblings, 1 reply; 12+ messages in thread
From: Ingo Molnar @ 2011-08-17 21:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, David Ahern, Frederic Weisbecker,
	Peter Zijlstra, Stephane Eranian, acme


* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:

> Hi Ingo,
> 
>         Please consider pulling from:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf/core
> 
> Regards,
> 
> - Arnaldo
> 
> Stephane Eranian (6):
>   perf list: Fix exit value
>   perf evlist: Fix missing event name init for default event (v2)
>   perf tools: Fix error handling of unknown events
>   perf annotate: Make output more readable
>   perf annotate: Add --symfs option
>   perf stat: Add -o and --append options
> 
>  tools/perf/Documentation/perf-annotate.txt |   11 ++
>  tools/perf/Documentation/perf-stat.txt     |    7 ++
>  tools/perf/builtin-annotate.c              |    6 +
>  tools/perf/builtin-stat.c                  |  155 ++++++++++++++++-----------
>  tools/perf/util/annotate.c                 |    5 +-
>  tools/perf/util/color.c                    |    2 +-
>  tools/perf/util/evlist.c                   |   11 ++-
>  tools/perf/util/parse-events.c             |    8 +-
>  tools/perf/util/symbol.c                   |    2 +
>  tools/perf/util/symbol.h                   |    4 +-
>  10 files changed, 141 insertions(+), 70 deletions(-)

hm, shouldnt these:

>   perf list: Fix exit value
>   perf evlist: Fix missing event name init for default event (v2)
>   perf tools: Fix error handling of unknown events

be in perf/urgent (based on -git) and go into v3.1, while the rest is 
for perf/core and goes into v3.2?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [GIT PULL 0/6] perf/core fixes and improvements
  2011-08-17 21:36 ` [GIT PULL 0/6] perf/core fixes and improvements Ingo Molnar
@ 2011-08-18 12:43   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-08-18 12:43 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Ingo Molnar, linux-kernel, David Ahern, Frederic Weisbecker,
	Peter Zijlstra, Stephane Eranian

Em Wed, Aug 17, 2011 at 11:36:17PM +0200, Ingo Molnar escreveu:
> * Arnaldo Carvalho de Melo <acme@infradead.org> wrote:
> > Hi Ingo,
> > 
> >         Please consider pulling from:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf/core
> 
> hm, shouldnt these:
> 
> >   perf list: Fix exit value
> >   perf evlist: Fix missing event name init for default event (v2)
> >   perf tools: Fix error handling of unknown events
> 
> be in perf/urgent (based on -git) and go into v3.1, while the rest is 
> for perf/core and goes into v3.2?

I'll rework the branches, adding these and other fixes (glibc build fix,
etc) in perf/urgent and the rest in perf/core, resubmit.

- Arnaldo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [GIT PULL 0/6] perf/core fixes and improvements
  2011-10-14  7:16 ` Ingo Molnar
@ 2011-10-14 15:07   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-10-14 15:07 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

Em Fri, Oct 14, 2011 at 09:16:10AM +0200, Ingo Molnar escreveu:
> Hm, got a segfault with a plain 'perf top' on a 3.0-0.rc7.git3-ish 
> box:
> 
>  ./perf top
>  Segmentation fault (core dumped)
> 
> It took about 20 attempts to reproduce the segfault, and it always 
> occured right after the first refresh (which, unlike the working 
> cases showed zero samples):
> 
> Program received signal SIGSEGV, Segmentation fault.                                                    
> [Switching to Thread 0x7ffff13a3700 (LWP 21657)]
> ui_browser__hists_seek (whence=<optimized out>, offset=0, 
> self=0x7fffec0008c0)
>     at util/ui/browsers/hists.c:682
> 682		h->row_offset = 0;
> (gdb) 
> 
> (gdb) bt
> #0  ui_browser__hists_seek (whence=<optimized out>, offset=0, self=0x7fffec0008c0)

browser->top was NULL at that point, it was only being initialized in
the refresh routine, fixed in my tree, please re-pull.

One can easily trigger it by specifying a seldom ocurring event, which
will start the browser without samples, then generating such event, I
used net:netif_rx + ping on my workstation.

> Btw., a side note: could we try to reset the console on segfaults and 
> similar crashes? TUI crashes tend to leave the console in a messed up 
> (blue, etc.) state.

I'll work on that, and also on allowing changing the browser colors,
say, to look like the stdio one.

- Arnaldo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [GIT PULL 0/6] perf/core fixes and improvements
  2011-10-13 15:08 Arnaldo Carvalho de Melo
@ 2011-10-14  7:16 ` Ingo Molnar
  2011-10-14 15:07   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 12+ messages in thread
From: Ingo Molnar @ 2011-10-14  7:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian, arnaldo.melo


* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:

> Hi Ingo,
> 
>         Please consider pulling from:
> 
> git://github.com/acmel/linux.git perf/core
> 
> Regards,
> 
> - Arnaldo
> 
> Arnaldo Carvalho de Melo (5):
>   perf hists browser: Recalculate browser pointers after resort/decay
>   perf hists: Don't free decayed entries if in the annotation browser
>   perf ui browser: Handle SIGWINCH
>   perf ui browser: Remove ui_browser__add_exit_keys
>   perf top: Remove entries from entries_collapsed on decay
> 
> Stephane Eranian (1):
>   perf hists: Fix compilation when NO_NEWT_SUPPORT is set
> 
>  tools/perf/builtin-top.c               |   23 ++++-
>  tools/perf/perf.c                      |   24 +++++
>  tools/perf/perf.h                      |    2 +
>  tools/perf/util/hist.c                 |   24 ++++-
>  tools/perf/util/hist.h                 |   11 ++-
>  tools/perf/util/sort.h                 |    1 +
>  tools/perf/util/ui/browser.c           |  176 ++++++++++++++++++++------------
>  tools/perf/util/ui/browser.h           |    9 +-
>  tools/perf/util/ui/browsers/annotate.c |   17 +--
>  tools/perf/util/ui/browsers/hists.c    |   55 +++-------
>  tools/perf/util/ui/browsers/map.c      |    6 +-
>  tools/perf/util/ui/helpline.h          |    2 +
>  12 files changed, 216 insertions(+), 134 deletions(-)

Hm, got a segfault with a plain 'perf top' on a 3.0-0.rc7.git3-ish 
box:

 ./perf top
 Segmentation fault (core dumped)

It took about 20 attempts to reproduce the segfault, and it always 
occured right after the first refresh (which, unlike the working 
cases showed zero samples):

Program received signal SIGSEGV, Segmentation fault.                                                    
[Switching to Thread 0x7ffff13a3700 (LWP 21657)]
ui_browser__hists_seek (whence=<optimized out>, offset=0, 
self=0x7fffec0008c0)
    at util/ui/browsers/hists.c:682
682		h->row_offset = 0;
(gdb) 

(gdb) bt
#0  ui_browser__hists_seek (whence=<optimized out>, offset=0, self=0x7fffec0008c0)
    at util/ui/browsers/hists.c:682
#1  ui_browser__hists_seek (self=0x7fffec0008c0, offset=0, whence=<optimized out>)
    at util/ui/browsers/hists.c:652
#2  0x0000000000472ab5 in hist_browser__run (delay_secs=2, arg=0x7602a0, 
    timer=0x420cc0 <perf_top__sort_new_samples>, ev_name=0x8f5dd0 "cycles", self=0x7fffec0008c0)
    at util/ui/browsers/hists.c:324
#3  perf_evsel__hists_browse (evsel=0x8f5b50, nr_events=1, helpline=<optimized out>, 
    ev_name=0x8f5dd0 "cycles", left_exits=false, timer=0x420cc0 <perf_top__sort_new_samples>, 
    arg=0x7602a0, delay_secs=2) at util/ui/browsers/hists.c:850
#4  0x0000000000473554 in perf_evlist__tui_browse_hists (evlist=0x8c4460, 
    help=0x50ab20 "For a higher level overview, try: perf top --sort comm,dso", 
    timer=0x420cc0 <perf_top__sort_new_samples>, arg=0x7602a0, delay_secs=2)
    at util/ui/browsers/hists.c:1178
#5  0x0000000000420ea3 in display_thread_tui (arg=<optimized out>) at builtin-top.c:567
#6  0x00000035f5807d31 in start_thread () from /lib64/libpthread.so.0
#7  0x00000035f54efdfd in clone () from /lib64/libc.so.6

(gdb) i r
rax            0x9118b8	9509048
rbx            0x7fffec0008c0	140737152813248
rcx            0x0	0
rdx            0x1	1
rsi            0x0	0
rdi            0x8f5bf0	9395184
rbp            0x7ffff13a2b90	0x7ffff13a2b90
rsp            0x7ffff13a2b70	0x7ffff13a2b70
r8             0x0	0
r9             0x0	0
r10            0xe6fe58	15138392
r11            0x0	0
r12            0x0	0
r13            0x2	2
r14            0x50ab20	5286688
r15            0x7602a0	7733920
rip            0x470f80	0x470f80 <ui_browser__hists_seek+128>
eflags         0x10246	[ PF ZF IF RF ]
cs             0x33	51
ss             0x2b	43
ds             0x0	0
es             0x0	0
fs             0x0	0
gs             0x0	0

The tree i pulled was 18eaf0b8e60a.

Btw., a side note: could we try to reset the console on segfaults and 
similar crashes? TUI crashes tend to leave the console in a messed up 
(blue, etc.) state.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [GIT PULL 0/6] perf/core fixes and improvements
@ 2011-10-13 15:08 Arnaldo Carvalho de Melo
  2011-10-14  7:16 ` Ingo Molnar
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-10-13 15:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Mike Galbraith, Paul Mackerras,
	Peter Zijlstra, Stephane Eranian, arnaldo.melo

Hi Ingo,

        Please consider pulling from:

git://github.com/acmel/linux.git perf/core

Regards,

- Arnaldo

Arnaldo Carvalho de Melo (5):
  perf hists browser: Recalculate browser pointers after resort/decay
  perf hists: Don't free decayed entries if in the annotation browser
  perf ui browser: Handle SIGWINCH
  perf ui browser: Remove ui_browser__add_exit_keys
  perf top: Remove entries from entries_collapsed on decay

Stephane Eranian (1):
  perf hists: Fix compilation when NO_NEWT_SUPPORT is set

 tools/perf/builtin-top.c               |   23 ++++-
 tools/perf/perf.c                      |   24 +++++
 tools/perf/perf.h                      |    2 +
 tools/perf/util/hist.c                 |   24 ++++-
 tools/perf/util/hist.h                 |   11 ++-
 tools/perf/util/sort.h                 |    1 +
 tools/perf/util/ui/browser.c           |  176 ++++++++++++++++++++------------
 tools/perf/util/ui/browser.h           |    9 +-
 tools/perf/util/ui/browsers/annotate.c |   17 +--
 tools/perf/util/ui/browsers/hists.c    |   55 +++-------
 tools/perf/util/ui/browsers/map.c      |    6 +-
 tools/perf/util/ui/helpline.h          |    2 +
 12 files changed, 216 insertions(+), 134 deletions(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-10-14 15:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-16 14:41 [GIT PULL 0/6] perf/core fixes and improvements Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 1/6] perf list: Fix exit value Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 2/6] perf evlist: Fix missing event name init for default event (v2) Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 3/6] perf tools: Fix error handling of unknown events Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 4/6] perf annotate: Make output more readable Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 5/6] perf annotate: Add --symfs option Arnaldo Carvalho de Melo
2011-08-16 14:41 ` [PATCH 6/6] perf stat: Add -o and --append options Arnaldo Carvalho de Melo
2011-08-17 21:36 ` [GIT PULL 0/6] perf/core fixes and improvements Ingo Molnar
2011-08-18 12:43   ` Arnaldo Carvalho de Melo
2011-10-13 15:08 Arnaldo Carvalho de Melo
2011-10-14  7:16 ` Ingo Molnar
2011-10-14 15:07   ` Arnaldo Carvalho de Melo

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.