Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1436438 > unrolled thread

[PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access

Started byJiri Olsa <jolsa@kernel.org>
First post2016-07-04 14:20 +0200
Last post2016-07-05 12:30 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access Jiri Olsa <jolsa@kernel.org> - 2016-07-04 14:20 +0200
    Re: [PATCH 3/4] perf tools: Add initialized arg into  unwind__prepare_access Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-04 21:30 +0200
      Re: [PATCH 3/4] perf tools: Add initialized arg into  unwind__prepare_access Jiri Olsa <jolsa@redhat.com> - 2016-07-05 08:30 +0200
    [tip:perf/core] perf unwind: Add initialized arg into  unwind__prepare_access tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-07-05 12:30 +0200

#1436438 — [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access

FromJiri Olsa <jolsa@kernel.org>
Date2016-07-04 14:20 +0200
Subject[PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access
Message-ID<rRb0Z-5uY-15@gated-at.bofh.it>
Adding initialized arg into unwind__prepare_access
to get feedback about the initialization state.

It's not possible to get it from error code, because
we return 0 even in case we don't recognize dso, which
is valid.

The 'initialized' value is used in following patch
to speedup unwind__prepare_access calls logic in
fork path.

Cc: He Kuang <hekuang@huawei.com>
Link: http://lkml.kernel.org/n/tip-vzmw5piz7diqa7rd6c49mjph@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/thread.c           |  2 +-
 tools/perf/util/unwind-libunwind.c | 11 +++++++++--
 tools/perf/util/unwind.h           |  9 ++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index f30f9566fddc..2439b122a4e4 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -202,7 +202,7 @@ int thread__insert_map(struct thread *thread, struct map *map)
 {
 	int ret;
 
-	ret = unwind__prepare_access(thread, map);
+	ret = unwind__prepare_access(thread, map, NULL);
 	if (ret)
 		return ret;
 
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 854711966cad..6d542a4e0648 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -14,15 +14,19 @@ static void unwind__register_ops(struct thread *thread,
 	thread->unwind_libunwind_ops = ops;
 }
 
-int unwind__prepare_access(struct thread *thread, struct map *map)
+int unwind__prepare_access(struct thread *thread, struct map *map,
+			   bool *initialized)
 {
 	const char *arch;
 	enum dso_type dso_type;
 	struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
+	int err;
 
 	if (thread->addr_space) {
 		pr_debug("unwind: thread map already set, dso=%s\n",
 			 map->dso->name);
+		if (initialized)
+			*initialized = true;
 		return 0;
 	}
 
@@ -51,7 +55,10 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
 out_register:
 	unwind__register_ops(thread, ops);
 
-	return thread->unwind_libunwind_ops->prepare_access(thread);
+	err = thread->unwind_libunwind_ops->prepare_access(thread);
+	if (initialized)
+		*initialized = err ? false : true;
+	return err;
 }
 
 void unwind__flush_access(struct thread *thread)
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 84c6d44d52f9..17ea1f928f13 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -42,12 +42,14 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 #endif
 
 int LIBUNWIND__ARCH_REG_ID(int regnum);
-int unwind__prepare_access(struct thread *thread, struct map *map);
+int unwind__prepare_access(struct thread *thread, struct map *map,
+			   bool *initialized);
 void unwind__flush_access(struct thread *thread);
 void unwind__finish_access(struct thread *thread);
 #else
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
-					 struct map *map __maybe_unused)
+					 struct map *map __maybe_unused,
+					 bool *initialized __maybe_unused);
 {
 	return 0;
 }
@@ -67,7 +69,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
 }
 
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
-					 struct map *map __maybe_unused)
+					 struct map *map __maybe_unused,
+					 bool *initialized __maybe_unused);
 {
 	return 0;
 }
-- 
2.4.11

[toc] | [next] | [standalone]


#1436568 — Re: [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-07-04 21:30 +0200
SubjectRe: [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access
Message-ID<rRhJ7-17F-7@gated-at.bofh.it>
In reply to#1436438
Em Mon, Jul 04, 2016 at 02:16:22PM +0200, Jiri Olsa escreveu:
> Adding initialized arg into unwind__prepare_access
> to get feedback about the initialization state.
> 
> It's not possible to get it from error code, because
> we return 0 even in case we don't recognize dso, which
> is valid.
> 
> The 'initialized' value is used in following patch
> to speedup unwind__prepare_access calls logic in
> fork path.
> 
> Cc: He Kuang <hekuang@huawei.com>
> Link: http://lkml.kernel.org/n/tip-vzmw5piz7diqa7rd6c49mjph@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/thread.c           |  2 +-
>  tools/perf/util/unwind-libunwind.c | 11 +++++++++--
>  tools/perf/util/unwind.h           |  9 ++++++---
>  3 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index f30f9566fddc..2439b122a4e4 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -202,7 +202,7 @@ int thread__insert_map(struct thread *thread, struct map *map)
>  {
>  	int ret;
>  
> -	ret = unwind__prepare_access(thread, map);
> +	ret = unwind__prepare_access(thread, map, NULL);
>  	if (ret)
>  		return ret;
>  
> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> index 854711966cad..6d542a4e0648 100644
> --- a/tools/perf/util/unwind-libunwind.c
> +++ b/tools/perf/util/unwind-libunwind.c
> @@ -14,15 +14,19 @@ static void unwind__register_ops(struct thread *thread,
>  	thread->unwind_libunwind_ops = ops;
>  }
>  
> -int unwind__prepare_access(struct thread *thread, struct map *map)
> +int unwind__prepare_access(struct thread *thread, struct map *map,
> +			   bool *initialized)
>  {
>  	const char *arch;
>  	enum dso_type dso_type;
>  	struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
> +	int err;
>  
>  	if (thread->addr_space) {
>  		pr_debug("unwind: thread map already set, dso=%s\n",
>  			 map->dso->name);
> +		if (initialized)
> +			*initialized = true;
>  		return 0;
>  	}
>  
> @@ -51,7 +55,10 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
>  out_register:
>  	unwind__register_ops(thread, ops);
>  
> -	return thread->unwind_libunwind_ops->prepare_access(thread);
> +	err = thread->unwind_libunwind_ops->prepare_access(thread);
> +	if (initialized)
> +		*initialized = err ? false : true;
> +	return err;
>  }
>  
>  void unwind__flush_access(struct thread *thread)
> diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
> index 84c6d44d52f9..17ea1f928f13 100644
> --- a/tools/perf/util/unwind.h
> +++ b/tools/perf/util/unwind.h
> @@ -42,12 +42,14 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
>  #endif
>  
>  int LIBUNWIND__ARCH_REG_ID(int regnum);
> -int unwind__prepare_access(struct thread *thread, struct map *map);
> +int unwind__prepare_access(struct thread *thread, struct map *map,
> +			   bool *initialized);
>  void unwind__flush_access(struct thread *thread);
>  void unwind__finish_access(struct thread *thread);
>  #else
>  static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
> -					 struct map *map __maybe_unused)
> +					 struct map *map __maybe_unused,
> +					 bool *initialized __maybe_unused);
>  {
>  	return 0;
>  }
> @@ -67,7 +69,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
>  }
>  
>  static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
> -					 struct map *map __maybe_unused)
> +					 struct map *map __maybe_unused,
> +					 bool *initialized __maybe_unused);
>  {
>  	return 0;
>  }

That extra ; breaks the build on centos5 (i.e. on an arch where the
above code gets compiled:

  CC       /tmp/build/perf/bench/sched-pipe.o
In file included from util/machine.c:14:
util/unwind.h:74: error: expected identifier or '(' before '{' token
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/parse-events.o
mv: cannot stat `/tmp/build/perf/util/.machine.o.tmp': No such file or directory
make[3]: *** [/tmp/build/perf/util/machine.o] Error 1
make[3]: *** Waiting for unfinished jobs....
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/dso-data.o
make[2]: *** [util] Error 2
make[1]: *** [/tmp/build/perf/libperf-in.o] Error 2
make[1]: *** Waiting for unfinished jobs....
  MKDIR    /tmp/build/perf/tests/


Fixing it.
> -- 
> 2.4.11

[toc] | [prev] | [next] | [standalone]


#1436787 — Re: [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access

FromJiri Olsa <jolsa@redhat.com>
Date2016-07-05 08:30 +0200
SubjectRe: [PATCH 3/4] perf tools: Add initialized arg into unwind__prepare_access
Message-ID<rRs1P-7yT-1@gated-at.bofh.it>
In reply to#1436568
On Mon, Jul 04, 2016 at 04:25:11PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

> >  }
> > @@ -67,7 +69,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
> >  }
> >  
> >  static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
> > -					 struct map *map __maybe_unused)
> > +					 struct map *map __maybe_unused,
> > +					 bool *initialized __maybe_unused);
> >  {
> >  	return 0;
> >  }
> 
> That extra ; breaks the build on centos5 (i.e. on an arch where the
> above code gets compiled:
> 
>   CC       /tmp/build/perf/bench/sched-pipe.o
> In file included from util/machine.c:14:
> util/unwind.h:74: error: expected identifier or '(' before '{' token
>   MKDIR    /tmp/build/perf/tests/
>   CC       /tmp/build/perf/tests/parse-events.o
> mv: cannot stat `/tmp/build/perf/util/.machine.o.tmp': No such file or directory
> make[3]: *** [/tmp/build/perf/util/machine.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
>   MKDIR    /tmp/build/perf/tests/
>   CC       /tmp/build/perf/tests/dso-data.o
> make[2]: *** [util] Error 2
> make[1]: *** [/tmp/build/perf/libperf-in.o] Error 2
> make[1]: *** Waiting for unfinished jobs....
>   MKDIR    /tmp/build/perf/tests/
> 
> 
> Fixing it.

oops, thanks

jirka

[toc] | [prev] | [next] | [standalone]


#1436909 — [tip:perf/core] perf unwind: Add initialized arg into unwind__prepare_access

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-07-05 12:30 +0200
Subject[tip:perf/core] perf unwind: Add initialized arg into unwind__prepare_access
Message-ID<rRvM6-1wX-29@gated-at.bofh.it>
In reply to#1436438
Commit-ID:  a2873325ffb21cecca8032673eb698cb4d778dc6
Gitweb:     http://git.kernel.org/tip/a2873325ffb21cecca8032673eb698cb4d778dc6
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 4 Jul 2016 14:16:22 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 4 Jul 2016 20:27:12 -0300

perf unwind: Add initialized arg into unwind__prepare_access

Adding initialized arg into unwind__prepare_access to get feedback about
the initialization state.

It's not possible to get it from error code, because we return 0 even in
case we don't recognize dso, which is valid.

The 'initialized' value is used in following patch to speedup
unwind__prepare_access calls logic in fork path.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467634583-29147-4-git-send-email-jolsa@kernel.org
[ Remove ; after static inline function signatures, fixes build break ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/thread.c           |  2 +-
 tools/perf/util/unwind-libunwind.c | 11 +++++++++--
 tools/perf/util/unwind.h           |  9 ++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index f30f956..2439b12 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -202,7 +202,7 @@ int thread__insert_map(struct thread *thread, struct map *map)
 {
 	int ret;
 
-	ret = unwind__prepare_access(thread, map);
+	ret = unwind__prepare_access(thread, map, NULL);
 	if (ret)
 		return ret;
 
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 8547119..6d542a4 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -14,15 +14,19 @@ static void unwind__register_ops(struct thread *thread,
 	thread->unwind_libunwind_ops = ops;
 }
 
-int unwind__prepare_access(struct thread *thread, struct map *map)
+int unwind__prepare_access(struct thread *thread, struct map *map,
+			   bool *initialized)
 {
 	const char *arch;
 	enum dso_type dso_type;
 	struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
+	int err;
 
 	if (thread->addr_space) {
 		pr_debug("unwind: thread map already set, dso=%s\n",
 			 map->dso->name);
+		if (initialized)
+			*initialized = true;
 		return 0;
 	}
 
@@ -51,7 +55,10 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
 out_register:
 	unwind__register_ops(thread, ops);
 
-	return thread->unwind_libunwind_ops->prepare_access(thread);
+	err = thread->unwind_libunwind_ops->prepare_access(thread);
+	if (initialized)
+		*initialized = err ? false : true;
+	return err;
 }
 
 void unwind__flush_access(struct thread *thread)
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 84c6d44..61fb1e9 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -42,12 +42,14 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 #endif
 
 int LIBUNWIND__ARCH_REG_ID(int regnum);
-int unwind__prepare_access(struct thread *thread, struct map *map);
+int unwind__prepare_access(struct thread *thread, struct map *map,
+			   bool *initialized);
 void unwind__flush_access(struct thread *thread);
 void unwind__finish_access(struct thread *thread);
 #else
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
-					 struct map *map __maybe_unused)
+					 struct map *map __maybe_unused,
+					 bool *initialized __maybe_unused)
 {
 	return 0;
 }
@@ -67,7 +69,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
 }
 
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
-					 struct map *map __maybe_unused)
+					 struct map *map __maybe_unused,
+					 bool *initialized __maybe_unused)
 {
 	return 0;
 }

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web