linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] perf tools: Introduce trim function
@ 2016-04-07  7:11 Jiri Olsa
  2016-04-07  7:11 ` [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct Jiri Olsa
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jiri Olsa @ 2016-04-07  7:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Andreas Hollmann, Milian Wolff

To be used in cases for both sides trim.

Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 3 +--
 tools/perf/ui/stdio/hist.c     | 3 +--
 tools/perf/util/util.h         | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2a83414159a6..e70df2e54d66 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
 
 			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
 			dummy_hpp.buf[ret] = '\0';
-			rtrim(dummy_hpp.buf);
 
-			start = ltrim(dummy_hpp.buf);
+			start = trim(dummy_hpp.buf);
 			ret = strlen(start);
 
 			if (start != dummy_hpp.buf)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7aff5acf3265..560eb47d56f9 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
 			first_col = false;
 
 			fmt->header(fmt, hpp, hists_to_evsel(hists));
-			rtrim(hpp->buf);
 
-			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
+			header_width += fprintf(fp, "%s", trim(hpp->buf));
 		}
 	}
 
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 8298d607c738..3bf3de86d429 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+	return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 
-- 
2.4.11

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

* [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct
  2016-04-07  7:11 [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa
@ 2016-04-07  7:11 ` Jiri Olsa
  2016-04-13  7:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2016-04-07  7:11 ` [PATCH 3/3] perf script: Process event update events Jiri Olsa
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-04-07  7:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Andreas Hollmann, Milian Wolff

Milian reported issue with thread::priv, which was double
booked by perf trace and DWARF unwind code. So using those
together is impossible at the moment.

Moving DWARF unwind private data into separate variable
so perf trace can keep using thread::priv.

Reported-by: Milian Wolff <milian.wolff@kdab.com>
Link: http://lkml.kernel.org/n/tip-pwiici9lf2l0iuji1jv1f5kx@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/thread.h           |  6 ++++++
 tools/perf/util/unwind-libunwind.c | 25 +++++++++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index a0ac0317affb..e214207bb13a 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -9,6 +9,9 @@
 #include "symbol.h"
 #include <strlist.h>
 #include <intlist.h>
+#ifdef HAVE_LIBUNWIND_SUPPORT
+#include <libunwind.h>
+#endif
 
 struct thread_stack;
 
@@ -32,6 +35,9 @@ struct thread {
 
 	void			*priv;
 	struct thread_stack	*ts;
+#ifdef HAVE_LIBUNWIND_SUPPORT
+	unw_addr_space_t	addr_space;
+#endif
 };
 
 struct machine;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index ee7e372297e5..63687d3a344e 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -32,6 +32,7 @@
 #include "symbol.h"
 #include "util.h"
 #include "debug.h"
+#include "asm/bug.h"
 
 extern int
 UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
@@ -580,43 +581,33 @@ static unw_accessors_t accessors = {
 
 int unwind__prepare_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return 0;
 
-	addr_space = unw_create_addr_space(&accessors, 0);
-	if (!addr_space) {
+	thread->addr_space = unw_create_addr_space(&accessors, 0);
+	if (!thread->addr_space) {
 		pr_err("unwind: Can't create unwind address space.\n");
 		return -ENOMEM;
 	}
 
-	unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
-	thread__set_priv(thread, addr_space);
-
+	unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL);
 	return 0;
 }
 
 void unwind__flush_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
 
-	addr_space = thread__priv(thread);
-	unw_flush_cache(addr_space, 0, 0);
+	unw_flush_cache(thread->addr_space, 0, 0);
 }
 
 void unwind__finish_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
 
-	addr_space = thread__priv(thread);
-	unw_destroy_addr_space(addr_space);
+	unw_destroy_addr_space(thread->addr_space);
 }
 
 static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
@@ -639,7 +630,9 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 	 * unwind itself.
 	 */
 	if (max_stack - 1 > 0) {
-		addr_space = thread__priv(ui->thread);
+		WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
+		addr_space = ui->thread->addr_space;
+
 		if (addr_space == NULL)
 			return -1;
 
-- 
2.4.11

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

* [PATCH 3/3] perf script: Process event update events
  2016-04-07  7:11 [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa
  2016-04-07  7:11 ` [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct Jiri Olsa
@ 2016-04-07  7:11 ` Jiri Olsa
  2016-04-13  7:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2016-04-07 13:50 ` [PATCH 1/3] perf tools: Introduce trim function Arnaldo Carvalho de Melo
  2016-04-13  7:16 ` [tip:perf/core] " tip-bot for Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-04-07  7:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Andreas Hollmann, Milian Wolff

Andreas reported following command produces no output:

  $ cat test.py
  #!/usr/bin/env python

  def stat__krava(cpu, thread, time, val, ena, run):
      print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \
            ("krava", cpu, thread, time, val, ena, run)
  $ perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py

The reason is that perf script does not process event update
events and will never get the event name update thus the
python callback is never called.

The fix is just to add already existing callback we use
in the perf stat report.

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Link: http://lkml.kernel.org/n/tip-5tyy9xeoiyg1nvy32tkjrlv1@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-script.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3dffe5e..59009aa7e2ca 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1961,6 +1961,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 			.exit		 = perf_event__process_exit,
 			.fork		 = perf_event__process_fork,
 			.attr		 = process_attr,
+			.event_update   = perf_event__process_event_update,
 			.tracing_data	 = perf_event__process_tracing_data,
 			.build_id	 = perf_event__process_build_id,
 			.id_index	 = perf_event__process_id_index,
-- 
2.4.11

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

* Re: [PATCH 1/3] perf tools: Introduce trim function
  2016-04-07  7:11 [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa
  2016-04-07  7:11 ` [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct Jiri Olsa
  2016-04-07  7:11 ` [PATCH 3/3] perf script: Process event update events Jiri Olsa
@ 2016-04-07 13:50 ` Arnaldo Carvalho de Melo
  2016-04-07 14:03   ` Jiri Olsa
  2016-04-13  7:16 ` [tip:perf/core] " tip-bot for Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-04-07 13:50 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Andreas Hollmann, Milian Wolff

Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> To be used in cases for both sides trim.
> 
> Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

Will try Milian's 'perf trace' callchain patch soon, any updates on that one?

- Arnaldo

>  tools/perf/ui/browsers/hists.c | 3 +--
>  tools/perf/ui/stdio/hist.c     | 3 +--
>  tools/perf/util/util.h         | 5 +++++
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 2a83414159a6..e70df2e54d66 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
>  
>  			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
>  			dummy_hpp.buf[ret] = '\0';
> -			rtrim(dummy_hpp.buf);
>  
> -			start = ltrim(dummy_hpp.buf);
> +			start = trim(dummy_hpp.buf);
>  			ret = strlen(start);
>  
>  			if (start != dummy_hpp.buf)
> diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
> index 7aff5acf3265..560eb47d56f9 100644
> --- a/tools/perf/ui/stdio/hist.c
> +++ b/tools/perf/ui/stdio/hist.c
> @@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
>  			first_col = false;
>  
>  			fmt->header(fmt, hpp, hists_to_evsel(hists));
> -			rtrim(hpp->buf);
>  
> -			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
> +			header_width += fprintf(fp, "%s", trim(hpp->buf));
>  		}
>  	}
>  
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 8298d607c738..3bf3de86d429 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
>  char *ltrim(char *s);
>  char *rtrim(char *s);
>  
> +static inline char *trim(char *s)
> +{
> +	return ltrim(rtrim(s));
> +}
> +
>  void dump_stack(void);
>  void sighandler_dump_stack(int sig);
>  
> -- 
> 2.4.11

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

* Re: [PATCH 1/3] perf tools: Introduce trim function
  2016-04-07 13:50 ` [PATCH 1/3] perf tools: Introduce trim function Arnaldo Carvalho de Melo
@ 2016-04-07 14:03   ` Jiri Olsa
  2016-04-07 15:45     ` Milian Wolff
  0 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-04-07 14:03 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Andreas Hollmann, Milian Wolff

On Thu, Apr 07, 2016 at 10:50:47AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> > To be used in cases for both sides trim.
> > 
> > Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> 
> Thanks, applied.
> 
> Will try Milian's 'perf trace' callchain patch soon, any updates on that one?

nope, nothing yet

jirka

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

* Re: [PATCH 1/3] perf tools: Introduce trim function
  2016-04-07 14:03   ` Jiri Olsa
@ 2016-04-07 15:45     ` Milian Wolff
  0 siblings, 0 replies; 9+ messages in thread
From: Milian Wolff @ 2016-04-07 15:45 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Andreas Hollmann

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

On Thursday, April 7, 2016 4:03:21 PM CEST Jiri Olsa wrote:
> On Thu, Apr 07, 2016 at 10:50:47AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> > > To be used in cases for both sides trim.
> > > 
> > > Link:
> > > http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > 
> > Thanks, applied.
> > 
> > Will try Milian's 'perf trace' callchain patch soon, any updates on that
> > one?
> nope, nothing yet

I'll send a working solution based on Jiri's fix later when I'm back home. In 
the meantime, please have a look at my other patch regarding `perf inject` 
merging of trace events for sys_enter/exit.

Thanks

-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

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

* [tip:perf/core] perf tools: Introduce trim function
  2016-04-07  7:11 [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa
                   ` (2 preceding siblings ...)
  2016-04-07 13:50 ` [PATCH 1/3] perf tools: Introduce trim function Arnaldo Carvalho de Melo
@ 2016-04-13  7:16 ` tip-bot for Jiri Olsa
  3 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-04-13  7:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, a.p.zijlstra, hpa, hollmann, namhyung, dsahern, acme,
	mingo, jolsa, milian.wolff, linux-kernel

Commit-ID:  7d6a7e782558323364bc0ae59f3523175c10b258
Gitweb:     http://git.kernel.org/tip/7d6a7e782558323364bc0ae59f3523175c10b258
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Apr 2016 09:11:11 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 7 Apr 2016 10:21:49 -0300

perf tools: Introduce trim function

To be used in cases for both sides trim.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andreas Hollmann <hollmann@in.tum.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 3 +--
 tools/perf/ui/stdio/hist.c     | 3 +--
 tools/perf/util/util.h         | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2a83414..e70df2e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
 
 			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
 			dummy_hpp.buf[ret] = '\0';
-			rtrim(dummy_hpp.buf);
 
-			start = ltrim(dummy_hpp.buf);
+			start = trim(dummy_hpp.buf);
 			ret = strlen(start);
 
 			if (start != dummy_hpp.buf)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7aff5ac..560eb47 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
 			first_col = false;
 
 			fmt->header(fmt, hpp, hists_to_evsel(hists));
-			rtrim(hpp->buf);
 
-			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
+			header_width += fprintf(fp, "%s", trim(hpp->buf));
 		}
 	}
 
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 8298d60..3bf3de8 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+	return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 

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

* [tip:perf/core] perf tools: Add dedicated unwind addr_space member into thread struct
  2016-04-07  7:11 ` [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct Jiri Olsa
@ 2016-04-13  7:17   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-04-13  7:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, namhyung, acme, mingo, jolsa, a.p.zijlstra, hpa,
	hollmann, tglx, linux-kernel, milian.wolff

Commit-ID:  e583d70c54976f81855c7ca763b036bad399f4e0
Gitweb:     http://git.kernel.org/tip/e583d70c54976f81855c7ca763b036bad399f4e0
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Apr 2016 09:11:12 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Apr 2016 09:58:02 -0300

perf tools: Add dedicated unwind addr_space member into thread struct

Milian reported issue with thread::priv, which was double booked by perf
trace and DWARF unwind code. So using those together is impossible at
the moment.

Moving DWARF unwind private data into separate variable so perf trace
can keep using thread::priv.

Reported-and-Tested-by: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andreas Hollmann <hollmann@in.tum.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/thread.h           |  6 ++++++
 tools/perf/util/unwind-libunwind.c | 25 +++++++++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index a0ac031..e214207 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -9,6 +9,9 @@
 #include "symbol.h"
 #include <strlist.h>
 #include <intlist.h>
+#ifdef HAVE_LIBUNWIND_SUPPORT
+#include <libunwind.h>
+#endif
 
 struct thread_stack;
 
@@ -32,6 +35,9 @@ struct thread {
 
 	void			*priv;
 	struct thread_stack	*ts;
+#ifdef HAVE_LIBUNWIND_SUPPORT
+	unw_addr_space_t	addr_space;
+#endif
 };
 
 struct machine;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index ee7e372..63687d3 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -32,6 +32,7 @@
 #include "symbol.h"
 #include "util.h"
 #include "debug.h"
+#include "asm/bug.h"
 
 extern int
 UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
@@ -580,43 +581,33 @@ static unw_accessors_t accessors = {
 
 int unwind__prepare_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return 0;
 
-	addr_space = unw_create_addr_space(&accessors, 0);
-	if (!addr_space) {
+	thread->addr_space = unw_create_addr_space(&accessors, 0);
+	if (!thread->addr_space) {
 		pr_err("unwind: Can't create unwind address space.\n");
 		return -ENOMEM;
 	}
 
-	unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
-	thread__set_priv(thread, addr_space);
-
+	unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL);
 	return 0;
 }
 
 void unwind__flush_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
 
-	addr_space = thread__priv(thread);
-	unw_flush_cache(addr_space, 0, 0);
+	unw_flush_cache(thread->addr_space, 0, 0);
 }
 
 void unwind__finish_access(struct thread *thread)
 {
-	unw_addr_space_t addr_space;
-
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
 
-	addr_space = thread__priv(thread);
-	unw_destroy_addr_space(addr_space);
+	unw_destroy_addr_space(thread->addr_space);
 }
 
 static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
@@ -639,7 +630,9 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 	 * unwind itself.
 	 */
 	if (max_stack - 1 > 0) {
-		addr_space = thread__priv(ui->thread);
+		WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
+		addr_space = ui->thread->addr_space;
+
 		if (addr_space == NULL)
 			return -1;
 

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

* [tip:perf/core] perf script: Process event update events
  2016-04-07  7:11 ` [PATCH 3/3] perf script: Process event update events Jiri Olsa
@ 2016-04-13  7:17   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-04-13  7:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hollmann, mingo, jolsa, milian.wolff, tglx, dsahern, acme, hpa,
	linux-kernel, a.p.zijlstra, namhyung

Commit-ID:  91daee306a51ca7b4d3ca7fdcf7472b0ed2c80c1
Gitweb:     http://git.kernel.org/tip/91daee306a51ca7b4d3ca7fdcf7472b0ed2c80c1
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Apr 2016 09:11:13 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Apr 2016 09:58:12 -0300

perf script: Process event update events

Andreas reported following command produces no output:

  # cat test.py
  #!/usr/bin/env python

  def stat__krava(cpu, thread, time, val, ena, run):
      print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \
            ("krava", cpu, thread, time, val, ena, run)
  # perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py
  ^C
  #

The reason is that 'perf script' does not process event update events and
will never get the event name update thus the python callback is never
called.

The fix is just to add already existing callback we use in 'perf stat
report'.

Committer note:

After the patch:

  # perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py
  event krava cpu -1, thread -1, time 1000239179, val 1789051, ena 4000690920, run 4000690920
  event krava cpu -1, thread -1, time 2000479061, val 2391338, ena 4000879596, run 4000879596
  event krava cpu -1, thread -1, time 3000740802, val 1939121, ena 4000977209, run 4000977209
  event krava cpu -1, thread -1, time 4001006730, val 2356115, ena 4001000489, run 4001000489
  ^C
  #

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3d..59009aa 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1961,6 +1961,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 			.exit		 = perf_event__process_exit,
 			.fork		 = perf_event__process_fork,
 			.attr		 = process_attr,
+			.event_update   = perf_event__process_event_update,
 			.tracing_data	 = perf_event__process_tracing_data,
 			.build_id	 = perf_event__process_build_id,
 			.id_index	 = perf_event__process_id_index,

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

end of thread, other threads:[~2016-04-13  7:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07  7:11 [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa
2016-04-07  7:11 ` [PATCH 2/3] perf tools: Add dedicated unwind addr_space member into thread struct Jiri Olsa
2016-04-13  7:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-04-07  7:11 ` [PATCH 3/3] perf script: Process event update events Jiri Olsa
2016-04-13  7:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-04-07 13:50 ` [PATCH 1/3] perf tools: Introduce trim function Arnaldo Carvalho de Melo
2016-04-07 14:03   ` Jiri Olsa
2016-04-07 15:45     ` Milian Wolff
2016-04-13  7:16 ` [tip:perf/core] " tip-bot for Jiri Olsa

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).