linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/19] perf tools: fixes and tweaks
@ 2013-10-18 12:28 Adrian Hunter
  2013-10-18 12:28 ` [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print Adrian Hunter
                   ` (18 more replies)
  0 siblings, 19 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Hi

Here are some fixes and tweaks for perf tools.


Adrian Hunter (19):
      perf evsel: Add missing 'mmap2' from debug print
      perf evsel: Add a debug print if perf_event_open fails
      perf record: Improve write_output error message
      perf evsel: Add missing decrement in id sample parsing
      perf session: Add missing sample flush for piped events
      perf session: Add missing members to perf_event__attr_swap()
      perf script: Set up output options for in-stream attributes
      perf inject: Do not repipe attributes to a perf.data file
      perf tools: Fix 32-bit cross build
      perf evlist: Fix 32-bit build error
      perf tools: Fix test_on_exit for 32-bit build
      perf tools: Fix bench/numa.c for 32-bit build
      perf tools: Fix libunwind build and feature detection for 32-bit build
      perf evlist: Add a debug print if event buffer mmap fails
      perf tools: fix perf_evlist__mmap comments
      perf tools: factor out duplicated evlist mmap code
      perf script: print addr by default for BTS
      perf record: add an option to force per-cpu mmaps
      perf tools: allow non-matching sample types

 tools/perf/Documentation/perf-record.txt        |   6 ++
 tools/perf/Makefile.perf                        |   2 +-
 tools/perf/bench/numa.c                         |   4 +-
 tools/perf/builtin-inject.c                     |   5 +
 tools/perf/builtin-record.c                     |   4 +-
 tools/perf/builtin-script.c                     | 106 ++++++++++++++------
 tools/perf/config/Makefile                      |   8 +-
 tools/perf/config/feature-checks/Makefile       |   6 +-
 tools/perf/config/feature-checks/test-on-exit.c |   1 +
 tools/perf/util/event.h                         |  16 +++
 tools/perf/util/evlist.c                        | 126 ++++++++++++++----------
 tools/perf/util/evlist.h                        |   1 +
 tools/perf/util/evsel.c                         |   8 +-
 tools/perf/util/record.c                        |   5 +-
 tools/perf/util/session.c                       |  11 ++-
 tools/perf/util/target.h                        |   1 +
 16 files changed, 211 insertions(+), 99 deletions(-)


Regards
Adrian


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

* [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
@ 2013-10-18 12:28 ` Adrian Hunter
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:28 ` [PATCH 02/19] perf evsel: Add a debug print if perf_event_open fails Adrian Hunter
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

struct perf_event_attr now has 'mmap2'.  Add it to
perf_event_attr__fprintf().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evsel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bfebc1e..291b18a 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -986,6 +986,7 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
 	ret += PRINT_ATTR2(exclude_host, exclude_guest);
 	ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
 			    "excl.callchain_user", exclude_callchain_user);
+	ret += PRINT_ATTR_U32(mmap2);
 
 	ret += PRINT_ATTR_U32(wakeup_events);
 	ret += PRINT_ATTR_U32(wakeup_watermark);
-- 
1.7.11.7


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

* [PATCH 02/19] perf evsel: Add a debug print if perf_event_open fails
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
  2013-10-18 12:28 ` [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print Adrian Hunter
@ 2013-10-18 12:28 ` Adrian Hunter
  2013-10-18 12:29 ` [PATCH 03/19] perf record: Improve write_output error message Adrian Hunter
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

There is a debug print (at verbose level 2) for each
call to perf_event_open.  Add another debug print if
the call fails, and print the error number.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evsel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 291b18a..1bb4f19 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1052,6 +1052,8 @@ retry_open:
 								     group_fd, flags);
 			if (FD(evsel, cpu, thread) < 0) {
 				err = -errno;
+				pr_debug2("perf_event_open failed, error %d\n",
+					  err);
 				goto try_fallback;
 			}
 			set_rlimit = NO_CHANGE;
-- 
1.7.11.7


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

* [PATCH 03/19] perf record: Improve write_output error message
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
  2013-10-18 12:28 ` [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print Adrian Hunter
  2013-10-18 12:28 ` [PATCH 02/19] perf evsel: Add a debug print if perf_event_open fails Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:43   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing Adrian Hunter
                   ` (15 subsequent siblings)
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Improve the error message from write_output() to say
what failed to write and give the error number.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 92ca541..d269dfa 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -88,7 +88,7 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)
 		int ret = write(rec->output, buf, size);
 
 		if (ret < 0) {
-			pr_err("failed to write\n");
+			pr_err("failed to write perf data, error: %m\n");
 			return -1;
 		}
 
-- 
1.7.11.7


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

* [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (2 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 03/19] perf record: Improve write_output error message Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:44   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 05/19] perf session: Add missing sample flush for piped events Adrian Hunter
                   ` (14 subsequent siblings)
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

The final array decrement in id sample parsing is missing,
which may trip up the next person adding a sample format,
so add it in.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evsel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1bb4f19..e09c7e6 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1220,6 +1220,7 @@ static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel,
 
 		sample->pid = u.val32[0];
 		sample->tid = u.val32[1];
+		array--;
 	}
 
 	return 0;
-- 
1.7.11.7


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

* [PATCH 05/19] perf session: Add missing sample flush for piped events
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (3 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:45   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap() Adrian Hunter
                   ` (13 subsequent siblings)
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Piped events can be sorted so a final flush is needed.
Add that and remove a redundant 'err = 0'.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/session.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d1e4495..d51e62d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1263,7 +1263,9 @@ more:
 	if (!session_done())
 		goto more;
 done:
-	err = 0;
+	/* do the final flush for ordered samples */
+	self->ordered_samples.next_flush = ULLONG_MAX;
+	err = flush_sample_queue(self, tool);
 out_err:
 	free(buf);
 	perf_session__warn_about_errors(self, tool);
@@ -1392,13 +1394,13 @@ more:
 				    "Processing events...");
 	}
 
-	err = 0;
 	if (session_done())
-		goto out_err;
+		goto out;
 
 	if (file_pos < file_size)
 		goto more;
 
+out:
 	/* do the final flush for ordered samples */
 	session->ordered_samples.next_flush = ULLONG_MAX;
 	err = flush_sample_queue(session, tool);
-- 
1.7.11.7


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

* [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap()
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (4 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 05/19] perf session: Add missing sample flush for piped events Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:47   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 07/19] perf script: Set up output options for in-stream attributes Adrian Hunter
                   ` (12 subsequent siblings)
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

perf_event__attr_swap() needs to swap all members of
struct perf_event_attr.  Add mssing ones.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/session.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d51e62d..d4559ca 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -453,6 +453,9 @@ void perf_event__attr_swap(struct perf_event_attr *attr)
 	attr->bp_type		= bswap_32(attr->bp_type);
 	attr->bp_addr		= bswap_64(attr->bp_addr);
 	attr->bp_len		= bswap_64(attr->bp_len);
+	attr->branch_sample_type = bswap_64(attr->branch_sample_type);
+	attr->sample_regs_user	 = bswap_64(attr->sample_regs_user);
+	attr->sample_stack_user  = bswap_32(attr->sample_stack_user);
 
 	swap_bitfield((u8 *) (&attr->read_format + 1), sizeof(u64));
 }
-- 
1.7.11.7


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

* [PATCH 07/19] perf script: Set up output options for in-stream attributes
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (5 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap() Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-18 13:30   ` David Ahern
  2013-10-18 12:29 ` [PATCH 08/19] perf inject: Do not repipe attributes to a perf.data file Adrian Hunter
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Attributes (struct perf_event_attr) are recorded
separately in the perf.data file.  perf script uses
them to set up output options.  However attributes
can also be in the event stream, for example when
the input is a pipe (i.e. live mode).  This patch
makes perf script process in-stream attributes in
the same way as on-file attributes.

Here is an example:

Before this patch:

$ perf record uname | perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.015 MB (null) (~655 samples) ]
:4220  4220 [-01] 2933367.838906: cycles:

:4220  4220 [-01] 2933367.838910: cycles:

:4220  4220 [-01] 2933367.838912: cycles:

:4220  4220 [-01] 2933367.838914: cycles:

:4220  4220 [-01] 2933367.838916: cycles:

:4220  4220 [-01] 2933367.838918: cycles:

uname  4220 [-01] 2933367.838938: cycles:

uname  4220 [-01] 2933367.839207: cycles:

After this patch:

$ perf record uname | perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.015 MB (null) (~655 samples) ]
           :4582  4582 2933425.707724: cycles:  ffffffff81043ffa native_write_msr_safe ([kernel.kallsyms])
           :4582  4582 2933425.707728: cycles:  ffffffff81043ffa native_write_msr_safe ([kernel.kallsyms])
           :4582  4582 2933425.707730: cycles:  ffffffff81043ffa native_write_msr_safe ([kernel.kallsyms])
           :4582  4582 2933425.707732: cycles:  ffffffff81043ffa native_write_msr_safe ([kernel.kallsyms])
           :4582  4582 2933425.707734: cycles:  ffffffff81043ffa native_write_msr_safe ([kernel.kallsyms])
           :4582  4582 2933425.707736: cycles:  ffffffff81309a24 memcpy ([kernel.kallsyms])
           uname  4582 2933425.707760: cycles:  ffffffff8109c1c7 enqueue_task_fair ([kernel.kallsyms])
           uname  4582 2933425.707978: cycles:  ffffffff81308457 clear_page_c ([kernel.kallsyms])

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-script.c | 102 ++++++++++++++++++++++++++++++--------------
 1 file changed, 71 insertions(+), 31 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9c333ff..3f9a9bf 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -228,6 +228,24 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
 	return 0;
 }
 
+static void set_print_ip_opts(struct perf_event_attr *attr)
+{
+	unsigned int type = attr->type;
+
+	output[type].print_ip_opts = 0;
+	if (PRINT_FIELD(IP))
+		output[type].print_ip_opts |= PRINT_IP_OPT_IP;
+
+	if (PRINT_FIELD(SYM))
+		output[type].print_ip_opts |= PRINT_IP_OPT_SYM;
+
+	if (PRINT_FIELD(DSO))
+		output[type].print_ip_opts |= PRINT_IP_OPT_DSO;
+
+	if (PRINT_FIELD(SYMOFFSET))
+		output[type].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET;
+}
+
 /*
  * verify all user requested events exist and the samples
  * have the expected data
@@ -236,7 +254,6 @@ static int perf_session__check_output_opt(struct perf_session *session)
 {
 	int j;
 	struct perf_evsel *evsel;
-	struct perf_event_attr *attr;
 
 	for (j = 0; j < PERF_TYPE_MAX; ++j) {
 		evsel = perf_session__find_first_evtype(session, j);
@@ -259,20 +276,7 @@ static int perf_session__check_output_opt(struct perf_session *session)
 		if (evsel == NULL)
 			continue;
 
-		attr = &evsel->attr;
-
-		output[j].print_ip_opts = 0;
-		if (PRINT_FIELD(IP))
-			output[j].print_ip_opts |= PRINT_IP_OPT_IP;
-
-		if (PRINT_FIELD(SYM))
-			output[j].print_ip_opts |= PRINT_IP_OPT_SYM;
-
-		if (PRINT_FIELD(DSO))
-			output[j].print_ip_opts |= PRINT_IP_OPT_DSO;
-
-		if (PRINT_FIELD(SYMOFFSET))
-			output[j].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET;
+		set_print_ip_opts(&evsel->attr);
 	}
 
 	return 0;
@@ -539,32 +543,51 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
 	return 0;
 }
 
-static struct perf_tool perf_script = {
-	.sample		 = process_sample_event,
-	.mmap		 = perf_event__process_mmap,
-	.mmap2		 = perf_event__process_mmap2,
-	.comm		 = perf_event__process_comm,
-	.exit		 = perf_event__process_exit,
-	.fork		 = perf_event__process_fork,
-	.attr		 = perf_event__process_attr,
-	.tracing_data	 = perf_event__process_tracing_data,
-	.build_id	 = perf_event__process_build_id,
-	.ordered_samples = true,
-	.ordering_requires_timestamps = true,
+struct perf_script {
+	struct perf_tool	tool;
+	struct perf_session	*session;
 };
 
+static int process_attr(struct perf_tool *tool, union perf_event *event,
+			struct perf_evlist **pevlist)
+{
+	struct perf_script *scr = container_of(tool, struct perf_script, tool);
+	struct perf_evlist *evlist;
+	struct perf_evsel *evsel, *pos;
+	int err;
+
+	err = perf_event__process_attr(tool, event, pevlist);
+	if (err)
+		return err;
+
+	evlist = *pevlist;
+	evsel = perf_evlist__last(*pevlist);
+
+	if (evsel->attr.type >= PERF_TYPE_MAX)
+		return 0;
+
+	list_for_each_entry(pos, &evlist->entries, node) {
+		if (pos->attr.type == evsel->attr.type && pos != evsel)
+			return 0;
+	}
+
+	set_print_ip_opts(&evsel->attr);
+
+	return perf_evsel__check_attr(evsel, scr->session);
+}
+
 static void sig_handler(int sig __maybe_unused)
 {
 	session_done = 1;
 }
 
-static int __cmd_script(struct perf_session *session)
+static int __cmd_script(struct perf_script *scr)
 {
 	int ret;
 
 	signal(SIGINT, sig_handler);
 
-	ret = perf_session__process_events(session, &perf_script);
+	ret = perf_session__process_events(scr->session, &scr->tool);
 
 	if (debug_mode)
 		pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
@@ -1266,6 +1289,21 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 	char *script_path = NULL;
 	const char **__argv;
 	int i, j, err;
+	struct perf_script perf_script = {
+		.tool = {
+			.sample		 = process_sample_event,
+			.mmap		 = perf_event__process_mmap,
+			.mmap2		 = perf_event__process_mmap2,
+			.comm		 = perf_event__process_comm,
+			.exit		 = perf_event__process_exit,
+			.fork		 = perf_event__process_fork,
+			.attr		 = process_attr,
+			.tracing_data	 = perf_event__process_tracing_data,
+			.build_id	 = perf_event__process_build_id,
+			.ordered_samples = true,
+			.ordering_requires_timestamps = true,
+		},
+	};
 	const struct option options[] = {
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
@@ -1487,10 +1525,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 		setup_pager();
 
 	session = perf_session__new(input_name, O_RDONLY, 0, false,
-				    &perf_script);
+				    &perf_script.tool);
 	if (session == NULL)
 		return -ENOMEM;
 
+	perf_script.session = session;
+
 	if (cpu_list) {
 		if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
 			return -1;
@@ -1554,7 +1594,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (err < 0)
 		goto out;
 
-	err = __cmd_script(session);
+	err = __cmd_script(&perf_script);
 
 	perf_session__delete(session);
 	cleanup_scripting();
-- 
1.7.11.7


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

* [PATCH 08/19] perf inject: Do not repipe attributes to a perf.data file
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (6 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 07/19] perf script: Set up output options for in-stream attributes Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-18 12:29 ` [PATCH 09/19] perf tools: Fix 32-bit cross build Adrian Hunter
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

perf.data files contain the attributes separately, do not
put them in the event stream as well.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-inject.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index f51a963..2a88a72 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -71,12 +71,17 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
 				   union perf_event *event,
 				   struct perf_evlist **pevlist)
 {
+	struct perf_inject *inject = container_of(tool, struct perf_inject,
+						  tool);
 	int ret;
 
 	ret = perf_event__process_attr(tool, event, pevlist);
 	if (ret)
 		return ret;
 
+	if (!inject->pipe_output)
+		return 0;
+
 	return perf_event__repipe_synth(tool, event);
 }
 
-- 
1.7.11.7


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

* [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (7 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 08/19] perf inject: Do not repipe attributes to a perf.data file Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:42   ` Jiri Olsa
  2013-10-21 14:12   ` Arnaldo Carvalho de Melo
  2013-10-18 12:29 ` [PATCH 10/19] perf evlist: Fix 32-bit build error Adrian Hunter
                   ` (9 subsequent siblings)
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
was not passed around.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/Makefile.perf                  | 2 +-
 tools/perf/config/Makefile                | 4 ++--
 tools/perf/config/feature-checks/Makefile | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index c873e03..699cdb7 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -706,7 +706,7 @@ $(LIB_FILE): $(LIB_OBJS)
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
 
 $(LIBTRACEEVENT): $(TE_SOURCES)
-	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a
+	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" libtraceevent.a
 
 $(LIBTRACEEVENT)-clean:
 	$(call QUIET_CLEAN, libtraceevent)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c516d6b..c94a06b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -92,7 +92,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
@@ -169,7 +169,7 @@ ifeq ($(feature-all), 1)
   #
   $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
 else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
   $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
 endif
 
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 452b67c..353c00c 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -31,7 +31,7 @@ CC := $(CC) -MD
 
 all: $(FILES)
 
-BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
+BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 
 ###############################
 
-- 
1.7.11.7


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

* [PATCH 10/19] perf evlist: Fix 32-bit build error
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (8 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 09/19] perf tools: Fix 32-bit cross build Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 11/19] perf tools: Fix test_on_exit for 32-bit build Adrian Hunter
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

util/evlist.c: In function 'perf_evlist__mmap':
util/evlist.c:772:2: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' [-Werror=format]
cc1: all warnings being treated as errors

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 0b5425b..07ba0a4 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -769,7 +769,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 
 	evlist->overwrite = overwrite;
 	evlist->mmap_len = perf_evlist__mmap_size(pages);
-	pr_debug("mmap size %luB\n", evlist->mmap_len);
+	pr_debug("mmap size %zuB\n", evlist->mmap_len);
 	mask = evlist->mmap_len - page_size - 1;
 
 	list_for_each_entry(evsel, &evlist->entries, node) {
-- 
1.7.11.7


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

* [PATCH 11/19] perf tools: Fix test_on_exit for 32-bit build
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (9 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 10/19] perf evlist: Fix 32-bit build error Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 12/19] perf tools: Fix bench/numa.c " Adrian Hunter
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

builtin-record.c:42:12: error: static declaration of 'on_exit' follows non-static declaration
In file included from util/util.h:51:0,
                 from builtin.h:4,
                 from builtin-record.c:8:
/usr/include/stdlib.h:536:12: note: previous declaration of 'on_exit' was here

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/config/feature-checks/test-on-exit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
index 8f64ed3..8e88b16 100644
--- a/tools/perf/config/feature-checks/test-on-exit.c
+++ b/tools/perf/config/feature-checks/test-on-exit.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 
 static void exit_fn(int status, void *__data)
 {
-- 
1.7.11.7


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

* [PATCH 12/19] perf tools: Fix bench/numa.c for 32-bit build
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (10 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 11/19] perf tools: Fix test_on_exit for 32-bit build Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-23  7:54   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 13/19] perf tools: Fix libunwind build and feature detection " Adrian Hunter
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

bench/numa.c: In function 'worker_thread':
bench/numa.c:1123:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
bench/numa.c:1171:6: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'u64' [-Werror=format]
cc1: all warnings being treated as errors

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/bench/numa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 64fa01c..d4c83c6 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1120,7 +1120,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if ((u32)diff.tv_sec >= g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1167,7 +1167,7 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016"PRIx64"]\n",
 					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
 			}
 			fflush(stdout);
-- 
1.7.11.7


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

* [PATCH 13/19] perf tools: Fix libunwind build and feature detection for 32-bit build
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (11 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 12/19] perf tools: Fix bench/numa.c " Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:43   ` Jiri Olsa
  2013-10-18 12:29 ` [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails Adrian Hunter
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Use -lunwind-x86 instead of -lunwind-x86_64 for
32-bit build.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/config/Makefile                | 6 ++++--
 tools/perf/config/feature-checks/Makefile | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c94a06b..abb32f3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -25,9 +25,11 @@ ifeq ($(ARCH),x86_64)
     RAW_ARCH := x86_64
     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
+    LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
+  else
+    LIBUNWIND_LIBS = -lunwind -lunwind-x86
   endif
   NO_PERF_REGS := 0
-  LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
 endif
 
 ifeq ($(NO_PERF_REGS),0)
@@ -92,7 +94,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 353c00c..d37d58d 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -36,7 +36,7 @@ BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 ###############################
 
 test-all:
-	$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
+	$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
 
 test-hello:
 	$(BUILD)
@@ -72,7 +72,7 @@ test-libnuma:
 	$(BUILD) -lnuma
 
 test-libunwind:
-	$(BUILD) -lunwind -lunwind-x86_64 -lelf
+	$(BUILD) $(LIBUNWIND_LIBS) -lelf
 
 test-libaudit:
 	$(BUILD) -laudit
-- 
1.7.11.7


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

* [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (12 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 13/19] perf tools: Fix libunwind build and feature detection " Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-20 20:43   ` Jiri Olsa
  2013-10-18 12:29 ` [PATCH 15/19] perf tools: fix perf_evlist__mmap comments Adrian Hunter
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Add a debug print if mmap of the perf event
ring buffer fails.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 07ba0a4..52e434a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -600,6 +600,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
 	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
 				      MAP_SHARED, fd, 0);
 	if (evlist->mmap[idx].base == MAP_FAILED) {
+		pr_debug2("failed to mmap perf event ring buffer\n");
 		evlist->mmap[idx].base = NULL;
 		return -1;
 	}
-- 
1.7.11.7


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

* [PATCH 15/19] perf tools: fix perf_evlist__mmap comments
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (13 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-23  7:54   ` [tip:perf/core] perf evlist: Fix " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 16/19] perf tools: factor out duplicated evlist mmap code Adrian Hunter
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Put the comments into the correct kernel-doc format and
correct reference to perf_evlist__read_on_cpu() which
should be perf_evlist__mmap_read().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 52e434a..a4529af 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -739,20 +739,17 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
 	return 0;
 }
 
-/** perf_evlist__mmap - Create per cpu maps to receive events
- *
- * @evlist - list of events
- * @pages - map length in pages
- * @overwrite - overwrite older events?
- *
- * If overwrite is false the user needs to signal event consuption using:
- *
- *	struct perf_mmap *m = &evlist->mmap[cpu];
- *	unsigned int head = perf_mmap__read_head(m);
+/**
+ * perf_evlist__mmap - Create mmaps to receive events.
+ * @evlist: list of events
+ * @pages: map length in pages
+ * @overwrite: overwrite older events?
  *
- *	perf_mmap__write_tail(m, head)
+ * If @overwrite is %false the user needs to signal event consumption using
+ * perf_mmap__write_tail().  Using perf_evlist__mmap_read() does this
+ * automatically.
  *
- * Using perf_evlist__read_on_cpu does this automatically.
+ * Return: %0 on success, negative error code otherwise.
  */
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 		      bool overwrite)
-- 
1.7.11.7


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

* [PATCH 16/19] perf tools: factor out duplicated evlist mmap code
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (14 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 15/19] perf tools: fix perf_evlist__mmap comments Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-23  7:54   ` [tip:perf/core] perf evlist: Factor out duplicated " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 17/19] perf script: print addr by default for BTS Adrian Hunter
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

The same code is used in perf_evlist__mmap_per_cpu()
and perf_evlist__mmap_per_thread().  Factor it out
into a separate function perf_evlist__mmap_per_evsel().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 73 ++++++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index a4529af..18784dc 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -609,9 +609,36 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
 	return 0;
 }
 
-static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int mask)
+static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
+				       int prot, int mask, int cpu, int thread,
+				       int *output)
 {
 	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node) {
+		int fd = FD(evsel, cpu, thread);
+
+		if (*output == -1) {
+			*output = fd;
+			if (__perf_evlist__mmap(evlist, idx, prot, mask,
+						*output) < 0)
+				return -1;
+		} else {
+			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
+				return -1;
+		}
+
+		if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
+		    perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
+				     int mask)
+{
 	int cpu, thread;
 	int nr_cpus = cpu_map__nr(evlist->cpus);
 	int nr_threads = thread_map__nr(evlist->threads);
@@ -621,23 +648,9 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m
 		int output = -1;
 
 		for (thread = 0; thread < nr_threads; thread++) {
-			list_for_each_entry(evsel, &evlist->entries, node) {
-				int fd = FD(evsel, cpu, thread);
-
-				if (output == -1) {
-					output = fd;
-					if (__perf_evlist__mmap(evlist, cpu,
-								prot, mask, output) < 0)
-						goto out_unmap;
-				} else {
-					if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
-						goto out_unmap;
-				}
-
-				if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
-				    perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
-					goto out_unmap;
-			}
+			if (perf_evlist__mmap_per_evsel(evlist, cpu, prot, mask,
+							cpu, thread, &output))
+				goto out_unmap;
 		}
 	}
 
@@ -649,9 +662,9 @@ out_unmap:
 	return -1;
 }
 
-static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, int mask)
+static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot,
+					int mask)
 {
-	struct perf_evsel *evsel;
 	int thread;
 	int nr_threads = thread_map__nr(evlist->threads);
 
@@ -659,23 +672,9 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, in
 	for (thread = 0; thread < nr_threads; thread++) {
 		int output = -1;
 
-		list_for_each_entry(evsel, &evlist->entries, node) {
-			int fd = FD(evsel, 0, thread);
-
-			if (output == -1) {
-				output = fd;
-				if (__perf_evlist__mmap(evlist, thread,
-							prot, mask, output) < 0)
-					goto out_unmap;
-			} else {
-				if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
-					goto out_unmap;
-			}
-
-			if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
-			    perf_evlist__id_add_fd(evlist, evsel, 0, thread, fd) < 0)
-				goto out_unmap;
-		}
+		if (perf_evlist__mmap_per_evsel(evlist, thread, prot, mask, 0,
+						thread, &output))
+			goto out_unmap;
 	}
 
 	return 0;
-- 
1.7.11.7


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

* [PATCH 17/19] perf script: print addr by default for BTS
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (15 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 16/19] perf tools: factor out duplicated evlist mmap code Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-18 18:20   ` David Ahern
  2013-10-23  7:54   ` [tip:perf/core] perf script: Print " tip-bot for Adrian Hunter
  2013-10-18 12:29 ` [PATCH 18/19] perf record: add an option to force per-cpu mmaps Adrian Hunter
  2013-10-18 12:29 ` [PATCH 19/19] perf tools: allow non-matching sample types Adrian Hunter
  18 siblings, 2 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

addr is not displayed by default for hardware events,
however for branch events it is the target of the branch
so for BTS display it by default if it was recorded.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-script.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3f9a9bf..1a91621 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -413,7 +413,9 @@ static void print_sample_bts(union perf_event *event,
 	printf(" => ");
 
 	/* print branch_to information */
-	if (PRINT_FIELD(ADDR))
+	if (PRINT_FIELD(ADDR) ||
+	    ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
+	     !output[attr->type].user_set))
 		print_sample_addr(event, sample, machine, thread, attr);
 
 	printf("\n");
-- 
1.7.11.7


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

* [PATCH 18/19] perf record: add an option to force per-cpu mmaps
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (16 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 17/19] perf script: print addr by default for BTS Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-18 12:29 ` [PATCH 19/19] perf tools: allow non-matching sample types Adrian Hunter
  18 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

By default, when tasks are specified (i.e. -p, -t
or -u options) per-thread mmaps are created.  Add
an option to override that and force per-cpu mmaps.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/Documentation/perf-record.txt | 6 ++++++
 tools/perf/builtin-record.c              | 2 ++
 tools/perf/util/evlist.c                 | 4 +++-
 tools/perf/util/evsel.c                  | 4 ++--
 tools/perf/util/target.h                 | 1 +
 5 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index f10ab63..2ea6685 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -189,6 +189,12 @@ abort events and some memory events in precise mode on modern Intel CPUs.
 --transaction::
 Record transaction flags for transaction related events.
 
+--force-per-cpu::
+Force the use of per-cpu mmaps.  By default, when tasks are specified (i.e. -p,
+-t or -u options) per-thread mmaps are created.  This option overrides that and
+forces per-cpu mmaps.  A side-effect of that is that inheritance is
+automatically enabled.  Add the -i option also to disable inheritance.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d269dfa..fb09430 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -890,6 +890,8 @@ const struct option record_options[] = {
 		    "sample by weight (on special events only)"),
 	OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
 		    "sample transaction flags (special events only)"),
+	OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu,
+		    "force the use of per-cpu mmaps"),
 	OPT_END()
 };
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 18784dc..ffcccdd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -791,7 +791,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist,
 	if (evlist->threads == NULL)
 		return -1;
 
-	if (perf_target__has_task(target))
+	if (target->force_per_cpu)
+		evlist->cpus = cpu_map__new(target->cpu_list);
+	else if (perf_target__has_task(target))
 		evlist->cpus = cpu_map__dummy_new();
 	else if (!perf_target__has_cpu(target) && !target->uses_mmap)
 		evlist->cpus = cpu_map__dummy_new();
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index e09c7e6..f1839b0 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -645,7 +645,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 		}
 	}
 
-	if (perf_target__has_cpu(&opts->target))
+	if (perf_target__has_cpu(&opts->target) || opts->target.force_per_cpu)
 		perf_evsel__set_sample_bit(evsel, CPU);
 
 	if (opts->period)
@@ -653,7 +653,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 
 	if (!perf_missing_features.sample_id_all &&
 	    (opts->sample_time || !opts->no_inherit ||
-	     perf_target__has_cpu(&opts->target)))
+	     perf_target__has_cpu(&opts->target) || opts->target.force_per_cpu))
 		perf_evsel__set_sample_bit(evsel, TIME);
 
 	if (opts->raw_samples) {
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index a4be857..6d7efbd 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -12,6 +12,7 @@ struct perf_target {
 	uid_t	     uid;
 	bool	     system_wide;
 	bool	     uses_mmap;
+	bool	     force_per_cpu;
 };
 
 enum perf_target_errno {
-- 
1.7.11.7


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

* [PATCH 19/19] perf tools: allow non-matching sample types
  2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
                   ` (17 preceding siblings ...)
  2013-10-18 12:29 ` [PATCH 18/19] perf record: add an option to force per-cpu mmaps Adrian Hunter
@ 2013-10-18 12:29 ` Adrian Hunter
  2013-10-18 14:25   ` David Ahern
  18 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 12:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

For kernels that do not support PERF_SAMPLE_IDENTIFIER,
sample types need not be identical to determine
the sample id from the event.  Only the position
of the sample id needs to be the same.

Compatible sample types are ones in which the bits
defined by PERF_COMPAT_MASK are the same.
'perf_evlist__config()' forces sample types to be
compatible on that basis.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/event.h  | 16 ++++++++++++++++
 tools/perf/util/evlist.c | 25 +++++++++++++++++++++++++
 tools/perf/util/evlist.h |  1 +
 tools/perf/util/record.c |  5 ++++-
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 752709c..ca0689c 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -78,6 +78,22 @@ struct throttle_event {
 /* perf sample has 16 bits size limit */
 #define PERF_SAMPLE_MAX_SIZE (1 << 16)
 
+/*
+ * Events have compatible sample types if the following bits all have the same
+ * value.  This is because the order of sample members is fixed.  For sample
+ * events the order is: PERF_SAMPLE_IP, PERF_SAMPLE_TID, PERF_SAMPLE_TIME,
+ * PERF_SAMPLE_ADDR, PERF_SAMPLE_ID.  For non-sample events the sample members
+ * are accessed in reverse order.  The order is: PERF_SAMPLE_ID,
+ * PERF_SAMPLE_STREAM_ID, PERF_SAMPLE_CPU.  PERF_SAMPLE_IDENTIFIER is added for
+ * completeness but it should not be used with PERF_SAMPLE_ID.  Sample types
+ * that include PERF_SAMPLE_IDENTIFIER are always compatible.
+ */
+#define PERF_COMPAT_MASK				\
+	(PERF_SAMPLE_IP   | PERF_SAMPLE_TID       |	\
+	 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR      |	\
+	 PERF_SAMPLE_ID   | PERF_SAMPLE_STREAM_ID |	\
+	 PERF_SAMPLE_CPU  | PERF_SAMPLE_IDENTIFIER)
+
 struct sample_event {
 	struct perf_event_header        header;
 	u64 array[];
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ffcccdd..04c3fc8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -87,6 +87,31 @@ static void perf_evlist__update_id_pos(struct perf_evlist *evlist)
 	perf_evlist__set_id_pos(evlist);
 }
 
+/**
+ * perf_evlist__make_sample_types_compatible - make sample types compatible.
+ * @evlist: selected event list
+ *
+ * Events with compatible sample types all have the same id_pos and is_pos.
+ * This can be achieved by matching the bits of PERF_COMPAT_MASK.
+ */
+void perf_evlist__make_sample_types_compatible(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+	u64 compat = 0;
+
+	list_for_each_entry(evsel, &evlist->entries, node)
+		compat |= evsel->attr.sample_type & PERF_COMPAT_MASK;
+
+	list_for_each_entry(evsel, &evlist->entries, node) {
+		evsel->attr.sample_type |= compat;
+		evsel->sample_size =
+			__perf_evsel__sample_size(evsel->attr.sample_type);
+		perf_evsel__calc_id_pos(evsel);
+	}
+
+	perf_evlist__set_id_pos(evlist);
+}
+
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
 	struct perf_evsel *pos, *n;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 7f8f1ae..8c5cdb9 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -94,6 +94,7 @@ int perf_evlist__open(struct perf_evlist *evlist);
 void perf_evlist__close(struct perf_evlist *evlist);
 
 void perf_evlist__set_id_pos(struct perf_evlist *evlist);
+void perf_evlist__make_sample_types_compatible(struct perf_evlist *evlist);
 bool perf_can_sample_identifier(void);
 void perf_evlist__config(struct perf_evlist *evlist,
 			 struct perf_record_opts *opts);
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index 18d73aa..6e01bf2 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -104,5 +104,8 @@ void perf_evlist__config(struct perf_evlist *evlist,
 			perf_evsel__set_sample_id(evsel, use_sample_identifier);
 	}
 
-	perf_evlist__set_id_pos(evlist);
+	if (use_sample_identifier)
+		perf_evlist__set_id_pos(evlist);
+	else
+		perf_evlist__make_sample_types_compatible(evlist);
 }
-- 
1.7.11.7


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

* Re: [PATCH 07/19] perf script: Set up output options for in-stream attributes
  2013-10-18 12:29 ` [PATCH 07/19] perf script: Set up output options for in-stream attributes Adrian Hunter
@ 2013-10-18 13:30   ` David Ahern
  2013-10-18 14:32     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 54+ messages in thread
From: David Ahern @ 2013-10-18 13:30 UTC (permalink / raw)
  To: Adrian Hunter, Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, Frederic Weisbecker,
	Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
	Stephane Eranian

On 10/18/13 6:29 AM, Adrian Hunter wrote:
> Attributes (struct perf_event_attr) are recorded
> separately in the perf.data file.  perf script uses
> them to set up output options.  However attributes
> can also be in the event stream, for example when
> the input is a pipe (i.e. live mode).  This patch
> makes perf script process in-stream attributes in
> the same way as on-file attributes.

You have multiple changes in this patch -- expanding attribute 
processing to set output options per the description above and you are 
also making perf_script a stack variable. The latter should be a 
separate patch.

David

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

* Re: [PATCH 19/19] perf tools: allow non-matching sample types
  2013-10-18 12:29 ` [PATCH 19/19] perf tools: allow non-matching sample types Adrian Hunter
@ 2013-10-18 14:25   ` David Ahern
  2013-10-18 14:50     ` Adrian Hunter
  0 siblings, 1 reply; 54+ messages in thread
From: David Ahern @ 2013-10-18 14:25 UTC (permalink / raw)
  To: Adrian Hunter, Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, Frederic Weisbecker,
	Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
	Stephane Eranian

On 10/18/13 6:29 AM, Adrian Hunter wrote:
> For kernels that do not support PERF_SAMPLE_IDENTIFIER,
> sample types need not be identical to determine
> the sample id from the event.  Only the position
> of the sample id needs to be the same.
>
> Compatible sample types are ones in which the bits
> defined by PERF_COMPAT_MASK are the same.
> 'perf_evlist__config()' forces sample types to be
> compatible on that basis.

Arnaldo and I have discussed adding callchain handling to perf-trace. To 
do that we only need stack data (including IP) for one event -- eg, 
raw_syscalls:sys_enter. That means raw_syscalls:sys_enter and 
raw_syscalls:sys_exit will have different attributes set - including 
ones in the MASK.

David


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

* Re: [PATCH 07/19] perf script: Set up output options for in-stream attributes
  2013-10-18 13:30   ` David Ahern
@ 2013-10-18 14:32     ` Arnaldo Carvalho de Melo
  2013-10-22  7:35       ` Adrian Hunter
  0 siblings, 1 reply; 54+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-18 14:32 UTC (permalink / raw)
  To: David Ahern
  Cc: Adrian Hunter, Peter Zijlstra, Ingo Molnar, linux-kernel,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Em Fri, Oct 18, 2013 at 07:30:13AM -0600, David Ahern escreveu:
> On 10/18/13 6:29 AM, Adrian Hunter wrote:

> >Attributes (struct perf_event_attr) are recorded separately in the perf.data
> >file.  perf script uses them to set up output options.  However attributes
> >can also be in the event stream, for example when the input is a pipe (i.e.
> >live mode).  This patch makes perf script process in-stream attributes in
> >the same way as on-file attributes.
 
> You have multiple changes in this patch -- expanding attribute
> processing to set output options per the description above and you
> are also making perf_script a stack variable. The latter should be a
> separate patch.

Agreed, and this conversion of struct perf_script to be a stack variable is
nice (killing globals, a favourite pastime, yeah!), I like it, but in the past
one such conversion showed something nasty that made several people stare at
the build seeing builtin-sched.o take ages to build...

Please consider testing before/after that specific stack move:

commit f36f83f947ede547833e462696893f866df77324
Author: Namhyung Kim <namhyung.kim@lge.com>
Date:   Tue Jun 4 14:46:19 2013 +0900

    perf sched: Move struct perf_sched definition out of cmd_sched()
    
    For some reason it consumed quite amount of compile time when declared
    as local variable, and it disappeared when moved out of the function.
    Moving other variables/tables didn't help.
    
    On my system this single-file-change build time reduced from 11s to 3s.

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

* Re: [PATCH 19/19] perf tools: allow non-matching sample types
  2013-10-18 14:25   ` David Ahern
@ 2013-10-18 14:50     ` Adrian Hunter
  2013-10-18 15:03       ` David Ahern
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-18 14:50 UTC (permalink / raw)
  To: David Ahern
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On 18/10/13 17:25, David Ahern wrote:
> On 10/18/13 6:29 AM, Adrian Hunter wrote:
>> For kernels that do not support PERF_SAMPLE_IDENTIFIER,
>> sample types need not be identical to determine
>> the sample id from the event.  Only the position
>> of the sample id needs to be the same.
>>
>> Compatible sample types are ones in which the bits
>> defined by PERF_COMPAT_MASK are the same.
>> 'perf_evlist__config()' forces sample types to be
>> compatible on that basis.
> 
> Arnaldo and I have discussed adding callchain handling to perf-trace. To do
> that we only need stack data (including IP) for one event -- eg,
> raw_syscalls:sys_enter. That means raw_syscalls:sys_enter and
> raw_syscalls:sys_exit will have different attributes set - including ones in
> the MASK.

So how do you know which sample is which?


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

* Re: [PATCH 19/19] perf tools: allow non-matching sample types
  2013-10-18 14:50     ` Adrian Hunter
@ 2013-10-18 15:03       ` David Ahern
  0 siblings, 0 replies; 54+ messages in thread
From: David Ahern @ 2013-10-18 15:03 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On 10/18/13 8:50 AM, Adrian Hunter wrote:
> On 18/10/13 17:25, David Ahern wrote:
>> Arnaldo and I have discussed adding callchain handling to perf-trace. To do
>> that we only need stack data (including IP) for one event -- eg,
>> raw_syscalls:sys_enter. That means raw_syscalls:sys_enter and
>> raw_syscalls:sys_exit will have different attributes set - including ones in
>> the MASK.
>
> So how do you know which sample is which?

We need a solution to the problem, and my point is I don't want to 
increase data in all samples.

David


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

* Re: [PATCH 17/19] perf script: print addr by default for BTS
  2013-10-18 12:29 ` [PATCH 17/19] perf script: print addr by default for BTS Adrian Hunter
@ 2013-10-18 18:20   ` David Ahern
  2013-10-23  7:54   ` [tip:perf/core] perf script: Print " tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: David Ahern @ 2013-10-18 18:20 UTC (permalink / raw)
  To: Adrian Hunter, Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, Frederic Weisbecker,
	Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
	Stephane Eranian

On 10/18/13 6:29 AM, Adrian Hunter wrote:
> addr is not displayed by default for hardware events,
> however for branch events it is the target of the branch
> so for BTS display it by default if it was recorded.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>   tools/perf/builtin-script.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 3f9a9bf..1a91621 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -413,7 +413,9 @@ static void print_sample_bts(union perf_event *event,
>   	printf(" => ");
>
>   	/* print branch_to information */
> -	if (PRINT_FIELD(ADDR))
> +	if (PRINT_FIELD(ADDR) ||
> +	    ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
> +	     !output[attr->type].user_set))
>   		print_sample_addr(event, sample, machine, thread, attr);
>
>   	printf("\n");
>

Looks ok to me. Acked-by: David Ahern <dsahern@gmail.com>

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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-18 12:29 ` [PATCH 09/19] perf tools: Fix 32-bit cross build Adrian Hunter
@ 2013-10-20 20:42   ` Jiri Olsa
  2013-10-21  5:53     ` Adrian Hunter
  2013-10-21 14:12   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:42 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter wrote:
> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
> was not passed around.

this breaks feature detection for me on x86_64,
I've got following errors misdetection with this patch:

...                       libperl: [ OFF ]
...                       on-exit: [ OFF ]

and the build fails as well:

  CC       builtin-stat.o
builtin-record.c:42:12: error: static declaration of ‘on_exit’ follows non-static declaration
In file included from util/util.h:51:0,
                 from builtin.h:4,
                 from builtin-record.c:8:
/usr/include/stdlib.h:536:12: note: previous declaration of ‘on_exit’ was here
make[1]: *** [builtin-record.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2


jirka

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

* Re: [PATCH 03/19] perf record: Improve write_output error message
  2013-10-18 12:29 ` [PATCH 03/19] perf record: Improve write_output error message Adrian Hunter
@ 2013-10-20 20:43   ` Jiri Olsa
  2013-10-21  6:07     ` Adrian Hunter
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  1 sibling, 1 reply; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:43 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:00PM +0300, Adrian Hunter wrote:
> Improve the error message from write_output() to say
> what failed to write and give the error number.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/builtin-record.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 92ca541..d269dfa 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -88,7 +88,7 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)
>  		int ret = write(rec->output, buf, size);
>  
>  		if (ret < 0) {
> -			pr_err("failed to write\n");
> +			pr_err("failed to write perf data, error: %m\n");

is this some kind of format magic? ;-) you wanted
to print out 'ret' value, right?

jirka

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

* Re: [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails
  2013-10-18 12:29 ` [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails Adrian Hunter
@ 2013-10-20 20:43   ` Jiri Olsa
  0 siblings, 0 replies; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:43 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:11PM +0300, Adrian Hunter wrote:
> Add a debug print if mmap of the perf event
> ring buffer fails.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/evlist.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 07ba0a4..52e434a 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -600,6 +600,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
>  	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
>  				      MAP_SHARED, fd, 0);
>  	if (evlist->mmap[idx].base == MAP_FAILED) {
> +		pr_debug2("failed to mmap perf event ring buffer\n");

while at it, we could display errno

jirka

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

* Re: [PATCH 13/19] perf tools: Fix libunwind build and feature detection for 32-bit build
  2013-10-18 12:29 ` [PATCH 13/19] perf tools: Fix libunwind build and feature detection " Adrian Hunter
@ 2013-10-20 20:43   ` Jiri Olsa
  2013-10-21 14:14     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:43 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:10PM +0300, Adrian Hunter wrote:
> Use -lunwind-x86 instead of -lunwind-x86_64 for
> 32-bit build.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

jirka

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

* Re: [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing
  2013-10-18 12:29 ` [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing Adrian Hunter
@ 2013-10-20 20:44   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:44 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:01PM +0300, Adrian Hunter wrote:
> The final array decrement in id sample parsing is missing,
> which may trip up the next person adding a sample format,
> so add it in.

Acked-by: Jiri Olsa <jolsa@redhat.com>

jirka

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

* Re: [PATCH 05/19] perf session: Add missing sample flush for piped events
  2013-10-18 12:29 ` [PATCH 05/19] perf session: Add missing sample flush for piped events Adrian Hunter
@ 2013-10-20 20:45   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:45 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:02PM +0300, Adrian Hunter wrote:
> Piped events can be sorted so a final flush is needed.
> Add that and remove a redundant 'err = 0'.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

seems ok,
Reviewed-by: Jiri Olsa <jolsa@redhat.com>

jirka

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

* Re: [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap()
  2013-10-18 12:29 ` [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap() Adrian Hunter
@ 2013-10-20 20:47   ` Jiri Olsa
  2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: Jiri Olsa @ 2013-10-20 20:47 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Fri, Oct 18, 2013 at 03:29:03PM +0300, Adrian Hunter wrote:
> perf_event__attr_swap() needs to swap all members of
> struct perf_event_attr.  Add mssing ones.

Acked-by: Jiri Olsa <jolsa@redhat.com>

jirka

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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-20 20:42   ` Jiri Olsa
@ 2013-10-21  5:53     ` Adrian Hunter
  2013-10-21  8:46       ` Jiri Olsa
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-21  5:53 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On 20/10/13 23:42, Jiri Olsa wrote:
> On Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter wrote:
>> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
>> was not passed around.
> 
> this breaks feature detection for me on x86_64,
> I've got following errors misdetection with this patch:
> 
> ...                       libperl: [ OFF ]
> ...                       on-exit: [ OFF ]
> 
> and the build fails as well:
> 
>   CC       builtin-stat.o
> builtin-record.c:42:12: error: static declaration of ‘on_exit’ follows non-static declaration
> In file included from util/util.h:51:0,
>                  from builtin.h:4,
>                  from builtin-record.c:8:
> /usr/include/stdlib.h:536:12: note: previous declaration of ‘on_exit’ was here
> make[1]: *** [builtin-record.o] Error 1
> make[1]: *** Waiting for unfinished jobs....
> make: *** [all] Error 2

That is fixed in patch 11: perf tools: Fix test_on_exit for 32-bit build


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

* Re: [PATCH 03/19] perf record: Improve write_output error message
  2013-10-20 20:43   ` Jiri Olsa
@ 2013-10-21  6:07     ` Adrian Hunter
  2013-10-21  8:48       ` Jiri Olsa
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Hunter @ 2013-10-21  6:07 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On 20/10/13 23:43, Jiri Olsa wrote:
> On Fri, Oct 18, 2013 at 03:29:00PM +0300, Adrian Hunter wrote:
>> Improve the error message from write_output() to say
>> what failed to write and give the error number.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>>  tools/perf/builtin-record.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>> index 92ca541..d269dfa 100644
>> --- a/tools/perf/builtin-record.c
>> +++ b/tools/perf/builtin-record.c
>> @@ -88,7 +88,7 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)
>>  		int ret = write(rec->output, buf, size);
>>  
>>  		if (ret < 0) {
>> -			pr_err("failed to write\n");
>> +			pr_err("failed to write perf data, error: %m\n");
> 
> is this some kind of format magic? ;-) you wanted

It is a glibc extension.

> to print out 'ret' value, right?

No, errno


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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-21  5:53     ` Adrian Hunter
@ 2013-10-21  8:46       ` Jiri Olsa
  2013-10-21  9:02         ` Adrian Hunter
  0 siblings, 1 reply; 54+ messages in thread
From: Jiri Olsa @ 2013-10-21  8:46 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Mon, Oct 21, 2013 at 08:53:04AM +0300, Adrian Hunter wrote:
> On 20/10/13 23:42, Jiri Olsa wrote:
> > On Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter wrote:
> >> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
> >> was not passed around.
> > 
> > this breaks feature detection for me on x86_64,
> > I've got following errors misdetection with this patch:
> > 
> > ...                       libperl: [ OFF ]

how about this one?

> > ...                       on-exit: [ OFF ]
> > 
> > and the build fails as well:
> > 
> >   CC       builtin-stat.o
> > builtin-record.c:42:12: error: static declaration of ‘on_exit’ follows non-static declaration
> > In file included from util/util.h:51:0,
> >                  from builtin.h:4,
> >                  from builtin-record.c:8:
> > /usr/include/stdlib.h:536:12: note: previous declaration of ‘on_exit’ was here
> > make[1]: *** [builtin-record.o] Error 1
> > make[1]: *** Waiting for unfinished jobs....
> > make: *** [all] Error 2
> 
> That is fixed in patch 11: perf tools: Fix test_on_exit for 32-bit build

hum, could we apply those patches in reverse order?
I think the notion is not to break build deliberatelly
for the bisection sake.

jirka

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

* Re: [PATCH 03/19] perf record: Improve write_output error message
  2013-10-21  6:07     ` Adrian Hunter
@ 2013-10-21  8:48       ` Jiri Olsa
  0 siblings, 0 replies; 54+ messages in thread
From: Jiri Olsa @ 2013-10-21  8:48 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On Mon, Oct 21, 2013 at 09:07:16AM +0300, Adrian Hunter wrote:
> On 20/10/13 23:43, Jiri Olsa wrote:
> > On Fri, Oct 18, 2013 at 03:29:00PM +0300, Adrian Hunter wrote:
> >> Improve the error message from write_output() to say
> >> what failed to write and give the error number.
> >>
> >> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> >> ---
> >>  tools/perf/builtin-record.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> >> index 92ca541..d269dfa 100644
> >> --- a/tools/perf/builtin-record.c
> >> +++ b/tools/perf/builtin-record.c
> >> @@ -88,7 +88,7 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)
> >>  		int ret = write(rec->output, buf, size);
> >>  
> >>  		if (ret < 0) {
> >> -			pr_err("failed to write\n");
> >> +			pr_err("failed to write perf data, error: %m\n");
> > 
> > is this some kind of format magic? ;-) you wanted
> 
> It is a glibc extension.
> 
> > to print out 'ret' value, right?
> 
> No, errno
> 

ok, thanks

jirka

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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-21  8:46       ` Jiri Olsa
@ 2013-10-21  9:02         ` Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-21  9:02 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
	Namhyung Kim, Paul Mackerras, Stephane Eranian

On 21/10/13 11:46, Jiri Olsa wrote:
> On Mon, Oct 21, 2013 at 08:53:04AM +0300, Adrian Hunter wrote:
>> On 20/10/13 23:42, Jiri Olsa wrote:
>>> On Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter wrote:
>>>> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
>>>> was not passed around.
>>>
>>> this breaks feature detection for me on x86_64,
>>> I've got following errors misdetection with this patch:
>>>
>>> ...                       libperl: [ OFF ]
> 
> how about this one?

I will check it out.

> 
>>> ...                       on-exit: [ OFF ]
>>>
>>> and the build fails as well:
>>>
>>>   CC       builtin-stat.o
>>> builtin-record.c:42:12: error: static declaration of ‘on_exit’ follows non-static declaration
>>> In file included from util/util.h:51:0,
>>>                  from builtin.h:4,
>>>                  from builtin-record.c:8:
>>> /usr/include/stdlib.h:536:12: note: previous declaration of ‘on_exit’ was here
>>> make[1]: *** [builtin-record.o] Error 1
>>> make[1]: *** Waiting for unfinished jobs....
>>> make: *** [all] Error 2
>>
>> That is fixed in patch 11: perf tools: Fix test_on_exit for 32-bit build
> 
> hum, could we apply those patches in reverse order?
> I think the notion is not to break build deliberatelly
> for the bisection sake.

Oh, I had thought it was a 32-bit only problem.
Yes, I will re-order the patches.


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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-18 12:29 ` [PATCH 09/19] perf tools: Fix 32-bit cross build Adrian Hunter
  2013-10-20 20:42   ` Jiri Olsa
@ 2013-10-21 14:12   ` Arnaldo Carvalho de Melo
  2013-10-21 18:29     ` Adrian Hunter
  1 sibling, 1 reply; 54+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-21 14:12 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Em Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter escreveu:
> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
> was not passed around.
 
<SNIP>

> index c873e03..699cdb7 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -706,7 +706,7 @@ $(LIB_FILE): $(LIB_OBJS)
>  TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
>  
>  $(LIBTRACEEVENT): $(TE_SOURCES)
> -	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a
> +	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" libtraceevent.a

So are we unconditionally set -g and -Wall?

And by making CFLAGS be $(EXTRA_CFLAGS) implies EXTRA_CFLAGS already
contains "$(CFLAGS)?

- Arnaldo

>  
>  $(LIBTRACEEVENT)-clean:
>  	$(call QUIET_CLEAN, libtraceevent)
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index c516d6b..c94a06b 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -92,7 +92,7 @@ endif
>  
>  feature_check = $(eval $(feature_check_code))
>  define feature_check_code
> -  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
> +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
>  endef
>  
>  feature_set = $(eval $(feature_set_code))
> @@ -169,7 +169,7 @@ ifeq ($(feature-all), 1)
>    #
>    $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
>  else
> -  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
> +  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
>    $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
>  endif
>  
> diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
> index 452b67c..353c00c 100644
> --- a/tools/perf/config/feature-checks/Makefile
> +++ b/tools/perf/config/feature-checks/Makefile
> @@ -31,7 +31,7 @@ CC := $(CC) -MD
>  
>  all: $(FILES)
>  
> -BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
> +BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
>  
>  ###############################
>  
> -- 
> 1.7.11.7

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

* Re: [PATCH 13/19] perf tools: Fix libunwind build and feature detection for 32-bit build
  2013-10-20 20:43   ` Jiri Olsa
@ 2013-10-21 14:14     ` Arnaldo Carvalho de Melo
  2013-10-22  7:40       ` Adrian Hunter
  0 siblings, 1 reply; 54+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-21 14:14 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Adrian Hunter, Peter Zijlstra, Ingo Molnar, linux-kernel,
	David Ahern, Frederic Weisbecker, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

Em Sun, Oct 20, 2013 at 10:43:46PM +0200, Jiri Olsa escreveu:
> On Fri, Oct 18, 2013 at 03:29:10PM +0300, Adrian Hunter wrote:
> > Use -lunwind-x86 instead of -lunwind-x86_64 for 32-bit build.

> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

> Acked-by: Jiri Olsa <jolsa@redhat.com>

Doesn't apply because it depends on a patch in this series that I made a
question about, the "CFLAGS=-g ... one, but then can we avoid touching
this feature_check_code line with feature specific stuff, i.e. can't we
just touch LDFLAGS or CFLAGS?

- Arnaldo

--- tools/perf/config/Makefile
+++ tools/perf/config/Makefile
@@ -94,7 +96,7 @@
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))

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

* Re: [PATCH 09/19] perf tools: Fix 32-bit cross build
  2013-10-21 14:12   ` Arnaldo Carvalho de Melo
@ 2013-10-21 18:29     ` Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-21 18:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian



On 21/10/2013 5:12 p.m., Arnaldo Carvalho de Melo wrote:
> Em Fri, Oct 18, 2013 at 03:29:06PM +0300, Adrian Hunter escreveu:
>> Setting EXTRA_CFLAGS=-m32 did not work because CFLAGS
>> was not passed around.

Unfortunately passing CFLAGS seems to break some of the
tests, so this needs more work.

>
> <SNIP>
>
>> index c873e03..699cdb7 100644
>> --- a/tools/perf/Makefile.perf
>> +++ b/tools/perf/Makefile.perf
>> @@ -706,7 +706,7 @@ $(LIB_FILE): $(LIB_OBJS)
>>   TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
>>
>>   $(LIBTRACEEVENT): $(TE_SOURCES)
>> -	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a
>> +	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" libtraceevent.a
>
> So are we unconditionally set -g and -Wall?

They are the defaults from tools/lib/traceevent/Makefile
if CFLAGS is not set.  It seemed reasonably to keep them
the same.

>
> And by making CFLAGS be $(EXTRA_CFLAGS) implies EXTRA_CFLAGS already
> contains "$(CFLAGS)?

No I was intending to pass only -m32

>
> - Arnaldo
>
>>
>>   $(LIBTRACEEVENT)-clean:
>>   	$(call QUIET_CLEAN, libtraceevent)
>> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
>> index c516d6b..c94a06b 100644
>> --- a/tools/perf/config/Makefile
>> +++ b/tools/perf/config/Makefile
>> @@ -92,7 +92,7 @@ endif
>>
>>   feature_check = $(eval $(feature_check_code))
>>   define feature_check_code
>> -  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
>> +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
>>   endef
>>
>>   feature_set = $(eval $(feature_set_code))
>> @@ -169,7 +169,7 @@ ifeq ($(feature-all), 1)
>>     #
>>     $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
>>   else
>> -  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
>> +  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
>>     $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
>>   endif
>>
>> diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
>> index 452b67c..353c00c 100644
>> --- a/tools/perf/config/feature-checks/Makefile
>> +++ b/tools/perf/config/feature-checks/Makefile
>> @@ -31,7 +31,7 @@ CC := $(CC) -MD
>>
>>   all: $(FILES)
>>
>> -BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
>> +BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
>>
>>   ###############################
>>
>> --
>> 1.7.11.7

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

* Re: [PATCH 07/19] perf script: Set up output options for in-stream attributes
  2013-10-18 14:32     ` Arnaldo Carvalho de Melo
@ 2013-10-22  7:35       ` Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-22  7:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: David Ahern, Peter Zijlstra, Ingo Molnar, linux-kernel,
	Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

On 18/10/13 17:32, Arnaldo Carvalho de Melo wrote:
> Em Fri, Oct 18, 2013 at 07:30:13AM -0600, David Ahern escreveu:
>> On 10/18/13 6:29 AM, Adrian Hunter wrote:
> 
>>> Attributes (struct perf_event_attr) are recorded separately in the perf.data
>>> file.  perf script uses them to set up output options.  However attributes
>>> can also be in the event stream, for example when the input is a pipe (i.e.
>>> live mode).  This patch makes perf script process in-stream attributes in
>>> the same way as on-file attributes.
>  
>> You have multiple changes in this patch -- expanding attribute
>> processing to set output options per the description above and you
>> are also making perf_script a stack variable. The latter should be a
>> separate patch.
> 
> Agreed, and this conversion of struct perf_script to be a stack variable is
> nice (killing globals, a favourite pastime, yeah!), I like it, but in the past
> one such conversion showed something nasty that made several people stare at
> the build seeing builtin-sched.o take ages to build...

Fixed in V2

> 
> Please consider testing before/after that specific stack move:
> 
> commit f36f83f947ede547833e462696893f866df77324
> Author: Namhyung Kim <namhyung.kim@lge.com>
> Date:   Tue Jun 4 14:46:19 2013 +0900
> 
>     perf sched: Move struct perf_sched definition out of cmd_sched()
>     
>     For some reason it consumed quite amount of compile time when declared
>     as local variable, and it disappeared when moved out of the function.
>     Moving other variables/tables didn't help.
>     
>     On my system this single-file-change build time reduced from 11s to 3s.
> 
> 


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

* Re: [PATCH 13/19] perf tools: Fix libunwind build and feature detection for 32-bit build
  2013-10-21 14:14     ` Arnaldo Carvalho de Melo
@ 2013-10-22  7:40       ` Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: Adrian Hunter @ 2013-10-22  7:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Peter Zijlstra, Ingo Molnar, linux-kernel,
	David Ahern, Frederic Weisbecker, Mike Galbraith, Namhyung Kim,
	Paul Mackerras, Stephane Eranian

On 21/10/13 17:14, Arnaldo Carvalho de Melo wrote:
> Em Sun, Oct 20, 2013 at 10:43:46PM +0200, Jiri Olsa escreveu:
>> On Fri, Oct 18, 2013 at 03:29:10PM +0300, Adrian Hunter wrote:
>>> Use -lunwind-x86 instead of -lunwind-x86_64 for 32-bit build.
> 
>>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> 
>> Acked-by: Jiri Olsa <jolsa@redhat.com>
> 
> Doesn't apply because it depends on a patch in this series that I made a
> question about, the "CFLAGS=-g ... one, but then can we avoid touching
> this feature_check_code line with feature specific stuff, i.e. can't we
> just touch LDFLAGS or CFLAGS?

Because LDFLAGS and CFLAGS are used for all tests, all tests would
fail if any feature libraries were not present.

Also because 'make' invokes 'make' via a shell, it is not possible
to export variables.

That just leaves the command line as far as I can see.

> 
> - Arnaldo
> 
> --- tools/perf/config/Makefile
> +++ tools/perf/config/Makefile
> @@ -94,7 +96,7 @@
>  
>  feature_check = $(eval $(feature_check_code))
>  define feature_check_code
> -  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
> +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS) LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
>  endef
>  
>  feature_set = $(eval $(feature_set_code))
> 
> 


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

* [tip:perf/core] perf evsel: Add missing 'mmap2' from debug print
  2013-10-18 12:28 ` [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print Adrian Hunter
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  40d54ec2f77edc52340dcae236aaabe8c3cc3a07
Gitweb:     http://git.kernel.org/tip/40d54ec2f77edc52340dcae236aaabe8c3cc3a07
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:28:58 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 18 Oct 2013 10:43:14 -0300

perf evsel: Add missing 'mmap2' from debug print

The struct perf_event_attr now has a 'mmap2' member.  Add it to
perf_event_attr__fprintf().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bfebc1e..291b18a 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -986,6 +986,7 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
 	ret += PRINT_ATTR2(exclude_host, exclude_guest);
 	ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
 			    "excl.callchain_user", exclude_callchain_user);
+	ret += PRINT_ATTR_U32(mmap2);
 
 	ret += PRINT_ATTR_U32(wakeup_events);
 	ret += PRINT_ATTR_U32(wakeup_watermark);

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

* [tip:perf/core] perf evsel: Add missing decrement in id sample parsing
  2013-10-18 12:29 ` [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing Adrian Hunter
  2013-10-20 20:44   ` Jiri Olsa
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  dd44bc6be05e4a948124053c8105cfa581177554
Gitweb:     http://git.kernel.org/tip/dd44bc6be05e4a948124053c8105cfa581177554
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:01 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:18:49 -0300

perf evsel: Add missing decrement in id sample parsing

The final array decrement in id sample parsing is missing, which may
trip up the next person adding a sample format, so add it in.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-5-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 291b18a..ec0cc1e 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1218,6 +1218,7 @@ static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel,
 
 		sample->pid = u.val32[0];
 		sample->tid = u.val32[1];
+		array--;
 	}
 
 	return 0;

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

* [tip:perf/core] perf record: Improve write_output error message
  2013-10-18 12:29 ` [PATCH 03/19] perf record: Improve write_output error message Adrian Hunter
  2013-10-20 20:43   ` Jiri Olsa
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  4f624685f92719565981eb6f8d9195bb578522a3
Gitweb:     http://git.kernel.org/tip/4f624685f92719565981eb6f8d9195bb578522a3
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:00 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:06 -0300

perf record: Improve write_output error message

Improve the error message from write_output() to say what failed to
write and give the error number.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-4-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 92ca541..d269dfa 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -88,7 +88,7 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)
 		int ret = write(rec->output, buf, size);
 
 		if (ret < 0) {
-			pr_err("failed to write\n");
+			pr_err("failed to write perf data, error: %m\n");
 			return -1;
 		}
 

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

* [tip:perf/core] perf session: Add missing sample flush for piped events
  2013-10-18 12:29 ` [PATCH 05/19] perf session: Add missing sample flush for piped events Adrian Hunter
  2013-10-20 20:45   ` Jiri Olsa
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  8c16b649606ff9f6d742ad6f71c76fc0ee996c8e
Gitweb:     http://git.kernel.org/tip/8c16b649606ff9f6d742ad6f71c76fc0ee996c8e
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:02 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:07 -0300

perf session: Add missing sample flush for piped events

Piped events can be sorted so a final flush is needed.

Add that and remove a redundant 'err = 0'.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-6-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d1e4495..d51e62d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1263,7 +1263,9 @@ more:
 	if (!session_done())
 		goto more;
 done:
-	err = 0;
+	/* do the final flush for ordered samples */
+	self->ordered_samples.next_flush = ULLONG_MAX;
+	err = flush_sample_queue(self, tool);
 out_err:
 	free(buf);
 	perf_session__warn_about_errors(self, tool);
@@ -1392,13 +1394,13 @@ more:
 				    "Processing events...");
 	}
 
-	err = 0;
 	if (session_done())
-		goto out_err;
+		goto out;
 
 	if (file_pos < file_size)
 		goto more;
 
+out:
 	/* do the final flush for ordered samples */
 	session->ordered_samples.next_flush = ULLONG_MAX;
 	err = flush_sample_queue(session, tool);

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

* [tip:perf/core] perf session: Add missing members to perf_event__attr_swap()
  2013-10-18 12:29 ` [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap() Adrian Hunter
  2013-10-20 20:47   ` Jiri Olsa
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  7db5952846dfa015d74e64b5e8656acac979490b
Gitweb:     http://git.kernel.org/tip/7db5952846dfa015d74e64b5e8656acac979490b
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:03 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:24 -0300

perf session: Add missing members to perf_event__attr_swap()

The perf_event__attr_swap() method needs to swap all members of struct
perf_event_attr.  Add missing ones.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-7-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d51e62d..d4559ca 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -453,6 +453,9 @@ void perf_event__attr_swap(struct perf_event_attr *attr)
 	attr->bp_type		= bswap_32(attr->bp_type);
 	attr->bp_addr		= bswap_64(attr->bp_addr);
 	attr->bp_len		= bswap_64(attr->bp_len);
+	attr->branch_sample_type = bswap_64(attr->branch_sample_type);
+	attr->sample_regs_user	 = bswap_64(attr->sample_regs_user);
+	attr->sample_stack_user  = bswap_32(attr->sample_stack_user);
 
 	swap_bitfield((u8 *) (&attr->read_format + 1), sizeof(u64));
 }

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

* [tip:perf/core] perf evlist: Fix 32-bit build error
  2013-10-18 12:29 ` [PATCH 10/19] perf evlist: Fix 32-bit build error Adrian Hunter
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  2af68ef50c6afc1632edc984e9c834545d90f597
Gitweb:     http://git.kernel.org/tip/2af68ef50c6afc1632edc984e9c834545d90f597
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:07 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:41 -0300

perf evlist: Fix 32-bit build error

util/evlist.c: In function 'perf_evlist__mmap':
util/evlist.c:772:2: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' [-Werror=format]
cc1: all warnings being treated as errors

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-11-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 0b5425b..07ba0a4 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -769,7 +769,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 
 	evlist->overwrite = overwrite;
 	evlist->mmap_len = perf_evlist__mmap_size(pages);
-	pr_debug("mmap size %luB\n", evlist->mmap_len);
+	pr_debug("mmap size %zuB\n", evlist->mmap_len);
 	mask = evlist->mmap_len - page_size - 1;
 
 	list_for_each_entry(evsel, &evlist->entries, node) {

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

* [tip:perf/core] perf tools: Fix test_on_exit for 32-bit build
  2013-10-18 12:29 ` [PATCH 11/19] perf tools: Fix test_on_exit for 32-bit build Adrian Hunter
@ 2013-10-23  7:53   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  9402802a416c96b48b2bd9331c070ba2d7550b36
Gitweb:     http://git.kernel.org/tip/9402802a416c96b48b2bd9331c070ba2d7550b36
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:08 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:42 -0300

perf tools: Fix test_on_exit for 32-bit build

builtin-record.c:42:12: error: static declaration of 'on_exit' follows non-static declaration
In file included from util/util.h:51:0,
                 from builtin.h:4,
                 from builtin-record.c:8:
/usr/include/stdlib.h:536:12: note: previous declaration of 'on_exit' was here

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-12-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/config/feature-checks/test-on-exit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
index 8f64ed3..8e88b16 100644
--- a/tools/perf/config/feature-checks/test-on-exit.c
+++ b/tools/perf/config/feature-checks/test-on-exit.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 
 static void exit_fn(int status, void *__data)
 {

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

* [tip:perf/core] perf tools: Fix bench/numa.c for 32-bit build
  2013-10-18 12:29 ` [PATCH 12/19] perf tools: Fix bench/numa.c " Adrian Hunter
@ 2013-10-23  7:54   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  2100f778d44b9c25bd13d38c24a999e2caf1ae3d
Gitweb:     http://git.kernel.org/tip/2100f778d44b9c25bd13d38c24a999e2caf1ae3d
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:09 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:42 -0300

perf tools: Fix bench/numa.c for 32-bit build

bench/numa.c: In function 'worker_thread':
bench/numa.c:1123:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
bench/numa.c:1171:6: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'u64' [-Werror=format]
cc1: all warnings being treated as errors

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-13-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bench/numa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 64fa01c..d4c83c6 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1120,7 +1120,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if ((u32)diff.tv_sec >= g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1167,7 +1167,7 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016"PRIx64"]\n",
 					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
 			}
 			fflush(stdout);

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

* [tip:perf/core] perf evlist: Fix perf_evlist__mmap comments
  2013-10-18 12:29 ` [PATCH 15/19] perf tools: fix perf_evlist__mmap comments Adrian Hunter
@ 2013-10-23  7:54   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  c83fa7f2549cb60bc4d429de31096546f659ce6d
Gitweb:     http://git.kernel.org/tip/c83fa7f2549cb60bc4d429de31096546f659ce6d
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:12 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:43 -0300

perf evlist: Fix perf_evlist__mmap comments

Put the comments into the correct kernel-doc format and correct
reference to perf_evlist__read_on_cpu() which should be
perf_evlist__mmap_read().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-16-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 07ba0a4..acef94a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -738,20 +738,17 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
 	return 0;
 }
 
-/** perf_evlist__mmap - Create per cpu maps to receive events
- *
- * @evlist - list of events
- * @pages - map length in pages
- * @overwrite - overwrite older events?
- *
- * If overwrite is false the user needs to signal event consuption using:
- *
- *	struct perf_mmap *m = &evlist->mmap[cpu];
- *	unsigned int head = perf_mmap__read_head(m);
+/**
+ * perf_evlist__mmap - Create mmaps to receive events.
+ * @evlist: list of events
+ * @pages: map length in pages
+ * @overwrite: overwrite older events?
  *
- *	perf_mmap__write_tail(m, head)
+ * If @overwrite is %false the user needs to signal event consumption using
+ * perf_mmap__write_tail().  Using perf_evlist__mmap_read() does this
+ * automatically.
  *
- * Using perf_evlist__read_on_cpu does this automatically.
+ * Return: %0 on success, negative error code otherwise.
  */
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 		      bool overwrite)

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

* [tip:perf/core] perf evlist: Factor out duplicated mmap code
  2013-10-18 12:29 ` [PATCH 16/19] perf tools: factor out duplicated evlist mmap code Adrian Hunter
@ 2013-10-23  7:54   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  04e213148c434544e3aa88d227b5375fd375738b
Gitweb:     http://git.kernel.org/tip/04e213148c434544e3aa88d227b5375fd375738b
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:13 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 11:19:43 -0300

perf evlist: Factor out duplicated mmap code

The same code is used in perf_evlist__mmap_per_cpu() and
perf_evlist__mmap_per_thread().

Factor it out into a separate function perf_evlist__mmap_per_evsel().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-17-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 73 ++++++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index acef94a..85c4c80 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -608,9 +608,36 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
 	return 0;
 }
 
-static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int mask)
+static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
+				       int prot, int mask, int cpu, int thread,
+				       int *output)
 {
 	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node) {
+		int fd = FD(evsel, cpu, thread);
+
+		if (*output == -1) {
+			*output = fd;
+			if (__perf_evlist__mmap(evlist, idx, prot, mask,
+						*output) < 0)
+				return -1;
+		} else {
+			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
+				return -1;
+		}
+
+		if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
+		    perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
+				     int mask)
+{
 	int cpu, thread;
 	int nr_cpus = cpu_map__nr(evlist->cpus);
 	int nr_threads = thread_map__nr(evlist->threads);
@@ -620,23 +647,9 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m
 		int output = -1;
 
 		for (thread = 0; thread < nr_threads; thread++) {
-			list_for_each_entry(evsel, &evlist->entries, node) {
-				int fd = FD(evsel, cpu, thread);
-
-				if (output == -1) {
-					output = fd;
-					if (__perf_evlist__mmap(evlist, cpu,
-								prot, mask, output) < 0)
-						goto out_unmap;
-				} else {
-					if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
-						goto out_unmap;
-				}
-
-				if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
-				    perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
-					goto out_unmap;
-			}
+			if (perf_evlist__mmap_per_evsel(evlist, cpu, prot, mask,
+							cpu, thread, &output))
+				goto out_unmap;
 		}
 	}
 
@@ -648,9 +661,9 @@ out_unmap:
 	return -1;
 }
 
-static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, int mask)
+static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot,
+					int mask)
 {
-	struct perf_evsel *evsel;
 	int thread;
 	int nr_threads = thread_map__nr(evlist->threads);
 
@@ -658,23 +671,9 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, in
 	for (thread = 0; thread < nr_threads; thread++) {
 		int output = -1;
 
-		list_for_each_entry(evsel, &evlist->entries, node) {
-			int fd = FD(evsel, 0, thread);
-
-			if (output == -1) {
-				output = fd;
-				if (__perf_evlist__mmap(evlist, thread,
-							prot, mask, output) < 0)
-					goto out_unmap;
-			} else {
-				if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
-					goto out_unmap;
-			}
-
-			if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
-			    perf_evlist__id_add_fd(evlist, evsel, 0, thread, fd) < 0)
-				goto out_unmap;
-		}
+		if (perf_evlist__mmap_per_evsel(evlist, thread, prot, mask, 0,
+						thread, &output))
+			goto out_unmap;
 	}
 
 	return 0;

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

* [tip:perf/core] perf script: Print addr by default for BTS
  2013-10-18 12:29 ` [PATCH 17/19] perf script: print addr by default for BTS Adrian Hunter
  2013-10-18 18:20   ` David Ahern
@ 2013-10-23  7:54   ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Adrian Hunter @ 2013-10-23  7:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, paulus, mingo, hpa, mingo,
	a.p.zijlstra, efault, namhyung, jolsa, fweisbec, adrian.hunter,
	dsahern, tglx

Commit-ID:  243be3dd7c14454899e51334a6d66d29a41ae6ab
Gitweb:     http://git.kernel.org/tip/243be3dd7c14454899e51334a6d66d29a41ae6ab
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 18 Oct 2013 15:29:14 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Oct 2013 17:33:22 -0300

perf script: Print addr by default for BTS

The addr field is not displayed by default for hardware events, however
for branch events it is the target of the branch so for BTS display it
by default if it was recorded.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382099356-4918-18-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9c333ff..ebb2b5f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -409,7 +409,9 @@ static void print_sample_bts(union perf_event *event,
 	printf(" => ");
 
 	/* print branch_to information */
-	if (PRINT_FIELD(ADDR))
+	if (PRINT_FIELD(ADDR) ||
+	    ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
+	     !output[attr->type].user_set))
 		print_sample_addr(event, sample, machine, thread, attr);
 
 	printf("\n");

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

end of thread, other threads:[~2013-10-23  7:54 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 12:28 [PATCH 00/19] perf tools: fixes and tweaks Adrian Hunter
2013-10-18 12:28 ` [PATCH 01/19] perf evsel: Add missing 'mmap2' from debug print Adrian Hunter
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:28 ` [PATCH 02/19] perf evsel: Add a debug print if perf_event_open fails Adrian Hunter
2013-10-18 12:29 ` [PATCH 03/19] perf record: Improve write_output error message Adrian Hunter
2013-10-20 20:43   ` Jiri Olsa
2013-10-21  6:07     ` Adrian Hunter
2013-10-21  8:48       ` Jiri Olsa
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 04/19] perf evsel: Add missing decrement in id sample parsing Adrian Hunter
2013-10-20 20:44   ` Jiri Olsa
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 05/19] perf session: Add missing sample flush for piped events Adrian Hunter
2013-10-20 20:45   ` Jiri Olsa
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 06/19] perf session: Add missing members to perf_event__attr_swap() Adrian Hunter
2013-10-20 20:47   ` Jiri Olsa
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 07/19] perf script: Set up output options for in-stream attributes Adrian Hunter
2013-10-18 13:30   ` David Ahern
2013-10-18 14:32     ` Arnaldo Carvalho de Melo
2013-10-22  7:35       ` Adrian Hunter
2013-10-18 12:29 ` [PATCH 08/19] perf inject: Do not repipe attributes to a perf.data file Adrian Hunter
2013-10-18 12:29 ` [PATCH 09/19] perf tools: Fix 32-bit cross build Adrian Hunter
2013-10-20 20:42   ` Jiri Olsa
2013-10-21  5:53     ` Adrian Hunter
2013-10-21  8:46       ` Jiri Olsa
2013-10-21  9:02         ` Adrian Hunter
2013-10-21 14:12   ` Arnaldo Carvalho de Melo
2013-10-21 18:29     ` Adrian Hunter
2013-10-18 12:29 ` [PATCH 10/19] perf evlist: Fix 32-bit build error Adrian Hunter
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 11/19] perf tools: Fix test_on_exit for 32-bit build Adrian Hunter
2013-10-23  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 12/19] perf tools: Fix bench/numa.c " Adrian Hunter
2013-10-23  7:54   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 13/19] perf tools: Fix libunwind build and feature detection " Adrian Hunter
2013-10-20 20:43   ` Jiri Olsa
2013-10-21 14:14     ` Arnaldo Carvalho de Melo
2013-10-22  7:40       ` Adrian Hunter
2013-10-18 12:29 ` [PATCH 14/19] perf evlist: Add a debug print if event buffer mmap fails Adrian Hunter
2013-10-20 20:43   ` Jiri Olsa
2013-10-18 12:29 ` [PATCH 15/19] perf tools: fix perf_evlist__mmap comments Adrian Hunter
2013-10-23  7:54   ` [tip:perf/core] perf evlist: Fix " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 16/19] perf tools: factor out duplicated evlist mmap code Adrian Hunter
2013-10-23  7:54   ` [tip:perf/core] perf evlist: Factor out duplicated " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 17/19] perf script: print addr by default for BTS Adrian Hunter
2013-10-18 18:20   ` David Ahern
2013-10-23  7:54   ` [tip:perf/core] perf script: Print " tip-bot for Adrian Hunter
2013-10-18 12:29 ` [PATCH 18/19] perf record: add an option to force per-cpu mmaps Adrian Hunter
2013-10-18 12:29 ` [PATCH 19/19] perf tools: allow non-matching sample types Adrian Hunter
2013-10-18 14:25   ` David Ahern
2013-10-18 14:50     ` Adrian Hunter
2013-10-18 15:03       ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).