linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode
@ 2015-03-27 15:08 David Hildenbrand
  2015-03-27 16:09 ` Liang, Kan
  2015-03-30  8:11 ` [PATCH v2] " David Hildenbrand
  0 siblings, 2 replies; 7+ messages in thread
From: David Hildenbrand @ 2015-03-27 15:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: dahi, a.p.zijlstra, paulus, mingo, acme, acme, jolsa, kan.liang,
	namhyung, adrian.hunter, ak, brueckner, schwidefsky

Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved,
observed when profiling the kernel), this statement is wrong. The cpumode
must be kept when iterating over all ips, otherwise the default
(PERF_RECORD_MISC_USER) will be used by error.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
---
 tools/perf/util/machine.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e335330..c843652 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
 static int add_callchain_ip(struct thread *thread,
 			    struct symbol **parent,
 			    struct addr_location *root_al,
-			    bool branch_history,
+			    u8 *cpumode,
 			    u64 ip)
 {
 	struct addr_location al;
 
 	al.filtered = 0;
 	al.sym = NULL;
-	if (branch_history)
+	if (!cpumode) {
 		thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
 						   ip, &al);
-	else {
-		u8 cpumode = PERF_RECORD_MISC_USER;
-
+	} else {
 		if (ip >= PERF_CONTEXT_MAX) {
 			switch (ip) {
 			case PERF_CONTEXT_HV:
-				cpumode = PERF_RECORD_MISC_HYPERVISOR;
+				*cpumode = PERF_RECORD_MISC_HYPERVISOR;
 				break;
 			case PERF_CONTEXT_KERNEL:
-				cpumode = PERF_RECORD_MISC_KERNEL;
+				*cpumode = PERF_RECORD_MISC_KERNEL;
 				break;
 			case PERF_CONTEXT_USER:
-				cpumode = PERF_RECORD_MISC_USER;
+				*cpumode = PERF_RECORD_MISC_USER;
 				break;
 			default:
 				pr_debug("invalid callchain context: "
@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
 			}
 			return 0;
 		}
-		thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
-				   ip, &al);
+		thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
+					   ip, &al);
 	}
 
 	if (al.sym != NULL) {
@@ -1604,6 +1602,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	struct branch_stack *branch = sample->branch_stack;
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	int skip_idx = -1;
 	int first_call = 0;
@@ -1669,10 +1668,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 
 		for (i = 0; i < nr; i++) {
 			err = add_callchain_ip(thread, parent, root_al,
-					       true, be[i].to);
+					       NULL, be[i].to);
 			if (!err)
 				err = add_callchain_ip(thread, parent, root_al,
-						       true, be[i].from);
+						       NULL, be[i].from);
 			if (err == -EINVAL)
 				break;
 			if (err)
@@ -1701,7 +1700,7 @@ check_calls:
 #endif
 		ip = chain->ips[j];
 
-		err = add_callchain_ip(thread, parent, root_al, false, ip);
+		err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 
 		if (err)
 			return (err < 0) ? err : 0;
-- 
2.1.4


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

* RE: [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode
  2015-03-27 15:08 [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode David Hildenbrand
@ 2015-03-27 16:09 ` Liang, Kan
  2015-03-27 19:12   ` David Hildenbrand
  2015-03-30  8:11 ` [PATCH v2] " David Hildenbrand
  1 sibling, 1 reply; 7+ messages in thread
From: Liang, Kan @ 2015-03-27 16:09 UTC (permalink / raw)
  To: David Hildenbrand, linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, acme, jolsa, namhyung, Hunter,
	Adrian, ak, brueckner, schwidefsky



> Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
> add_callchain_ip") promised "No change in behavior.".
> 
> As this commit breaks callchains on s390x (symbols not getting resolved,
> observed when profiling the kernel), this statement is wrong. The
> cpumode must be kept when iterating over all ips, otherwise the default
> (PERF_RECORD_MISC_USER) will be used by error.

Indeed.
Besides thread__resolve_callchain_sample, lbr path also need to 
be patched.

@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample
(struct thread *thread,
 {
        struct ip_callchain *chain = sample->callchain;
        int chain_nr = min(max_stack, (int)chain->nr);
+       u8 cpumode = PERF_RECORD_MISC_USER;
        int i, j, err;
        u64 ip;

@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample
(struct thread *thread,
                                        ip = lbr_stack->entries[0].to;
                        }

-                       err = add_callchain_ip(thread, parent, root_al, false, ip);
+                      err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
                        if (err)
                                return (err < 0) ? err : 0;
                }

Thanks,
Kan

> 
> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> ---
>  tools/perf/util/machine.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index
> e335330..c843652 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1408,29 +1408,27 @@ struct mem_info
> *sample__resolve_mem(struct perf_sample *sample,  static int
> add_callchain_ip(struct thread *thread,
>  			    struct symbol **parent,
>  			    struct addr_location *root_al,
> -			    bool branch_history,
> +			    u8 *cpumode,
>  			    u64 ip)
>  {
>  	struct addr_location al;
> 
>  	al.filtered = 0;
>  	al.sym = NULL;
> -	if (branch_history)
> +	if (!cpumode) {
>  		thread__find_cpumode_addr_location(thread,
> MAP__FUNCTION,
>  						   ip, &al);
> -	else {
> -		u8 cpumode = PERF_RECORD_MISC_USER;
> -
> +	} else {
>  		if (ip >= PERF_CONTEXT_MAX) {
>  			switch (ip) {
>  			case PERF_CONTEXT_HV:
> -				cpumode =
> PERF_RECORD_MISC_HYPERVISOR;
> +				*cpumode =
> PERF_RECORD_MISC_HYPERVISOR;
>  				break;
>  			case PERF_CONTEXT_KERNEL:
> -				cpumode = PERF_RECORD_MISC_KERNEL;
> +				*cpumode = PERF_RECORD_MISC_KERNEL;
>  				break;
>  			case PERF_CONTEXT_USER:
> -				cpumode = PERF_RECORD_MISC_USER;
> +				*cpumode = PERF_RECORD_MISC_USER;
>  				break;
>  			default:
>  				pr_debug("invalid callchain context: "
> @@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
>  			}
>  			return 0;
>  		}
> -		thread__find_addr_location(thread, cpumode,
> MAP__FUNCTION,
> -				   ip, &al);
> +		thread__find_addr_location(thread, *cpumode,
> MAP__FUNCTION,
> +					   ip, &al);
>  	}
> 
>  	if (al.sym != NULL) {
> @@ -1604,6 +1602,7 @@ static int
> thread__resolve_callchain_sample(struct thread *thread,
>  	struct branch_stack *branch = sample->branch_stack;
>  	struct ip_callchain *chain = sample->callchain;
>  	int chain_nr = min(max_stack, (int)chain->nr);
> +	u8 cpumode = PERF_RECORD_MISC_USER;
>  	int i, j, err;
>  	int skip_idx = -1;
>  	int first_call = 0;
> @@ -1669,10 +1668,10 @@ static int
> thread__resolve_callchain_sample(struct thread *thread,
> 
>  		for (i = 0; i < nr; i++) {
>  			err = add_callchain_ip(thread, parent, root_al,
> -					       true, be[i].to);
> +					       NULL, be[i].to);
>  			if (!err)
>  				err = add_callchain_ip(thread, parent,
> root_al,
> -						       true, be[i].from);
> +						       NULL, be[i].from);
>  			if (err == -EINVAL)
>  				break;
>  			if (err)
> @@ -1701,7 +1700,7 @@ check_calls:
>  #endif
>  		ip = chain->ips[j];
> 
> -		err = add_callchain_ip(thread, parent, root_al, false, ip);
> +		err = add_callchain_ip(thread, parent, root_al, &cpumode,
> ip);
> 
>  		if (err)
>  			return (err < 0) ? err : 0;
> --
> 2.1.4


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

* Re: [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode
  2015-03-27 16:09 ` Liang, Kan
@ 2015-03-27 19:12   ` David Hildenbrand
  0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2015-03-27 19:12 UTC (permalink / raw)
  To: Liang, Kan
  Cc: linux-kernel, a.p.zijlstra, paulus, mingo, acme, acme, jolsa,
	namhyung, Hunter, Adrian, ak, brueckner, schwidefsky

> 
> 
> > Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
> > add_callchain_ip") promised "No change in behavior.".
> > 
> > As this commit breaks callchains on s390x (symbols not getting resolved,
> > observed when profiling the kernel), this statement is wrong. The
> > cpumode must be kept when iterating over all ips, otherwise the default
> > (PERF_RECORD_MISC_USER) will be used by error.
> 
> Indeed.
> Besides thread__resolve_callchain_sample, lbr path also need to 
> be patched.

Thanks, I'll include that and send another version.

David

> 
> @@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample
> (struct thread *thread,
>  {
>         struct ip_callchain *chain = sample->callchain;
>         int chain_nr = min(max_stack, (int)chain->nr);
> +       u8 cpumode = PERF_RECORD_MISC_USER;
>         int i, j, err;
>         u64 ip;
> 
> @@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample
> (struct thread *thread,
>                                         ip = lbr_stack->entries[0].to;
>                         }
> 
> -                       err = add_callchain_ip(thread, parent, root_al, false, ip);
> +                      err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
>                         if (err)
>                                 return (err < 0) ? err : 0;
>                 }
> 
> Thanks,
> Kan
> 


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

* [PATCH v2] perf callchain: fix kernel symbol resolution by remembering the cpumode
  2015-03-27 15:08 [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode David Hildenbrand
  2015-03-27 16:09 ` Liang, Kan
@ 2015-03-30  8:11 ` David Hildenbrand
  2015-03-30  8:54   ` Jiri Olsa
  2015-04-02 12:23   ` [tip:perf/core] perf callchain: Fix " tip-bot for David Hildenbrand
  1 sibling, 2 replies; 7+ messages in thread
From: David Hildenbrand @ 2015-03-30  8:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: dahi, a.p.zijlstra, paulus, mingo, acme, acme, jolsa, kan.liang,
	namhyung, adrian.hunter, ak, brueckner, schwidefsky

Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved,
observed when profiling the kernel), this statement is wrong. The cpumode
must be kept when iterating over all ips, otherwise the default
(PERF_RECORD_MISC_USER) will be used by error.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
---
 tools/perf/util/machine.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e335330..e45c8f3 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
 static int add_callchain_ip(struct thread *thread,
 			    struct symbol **parent,
 			    struct addr_location *root_al,
-			    bool branch_history,
+			    u8 *cpumode,
 			    u64 ip)
 {
 	struct addr_location al;
 
 	al.filtered = 0;
 	al.sym = NULL;
-	if (branch_history)
+	if (!cpumode) {
 		thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
 						   ip, &al);
-	else {
-		u8 cpumode = PERF_RECORD_MISC_USER;
-
+	} else {
 		if (ip >= PERF_CONTEXT_MAX) {
 			switch (ip) {
 			case PERF_CONTEXT_HV:
-				cpumode = PERF_RECORD_MISC_HYPERVISOR;
+				*cpumode = PERF_RECORD_MISC_HYPERVISOR;
 				break;
 			case PERF_CONTEXT_KERNEL:
-				cpumode = PERF_RECORD_MISC_KERNEL;
+				*cpumode = PERF_RECORD_MISC_KERNEL;
 				break;
 			case PERF_CONTEXT_USER:
-				cpumode = PERF_RECORD_MISC_USER;
+				*cpumode = PERF_RECORD_MISC_USER;
 				break;
 			default:
 				pr_debug("invalid callchain context: "
@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
 			}
 			return 0;
 		}
-		thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
-				   ip, &al);
+		thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
+					   ip, &al);
 	}
 
 	if (al.sym != NULL) {
@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 {
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	u64 ip;
 
@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 					ip = lbr_stack->entries[0].to;
 			}
 
-			err = add_callchain_ip(thread, parent, root_al, false, ip);
+			err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 			if (err)
 				return (err < 0) ? err : 0;
 		}
@@ -1604,6 +1603,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	struct branch_stack *branch = sample->branch_stack;
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	int skip_idx = -1;
 	int first_call = 0;
@@ -1669,10 +1669,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 
 		for (i = 0; i < nr; i++) {
 			err = add_callchain_ip(thread, parent, root_al,
-					       true, be[i].to);
+					       NULL, be[i].to);
 			if (!err)
 				err = add_callchain_ip(thread, parent, root_al,
-						       true, be[i].from);
+						       NULL, be[i].from);
 			if (err == -EINVAL)
 				break;
 			if (err)
@@ -1701,7 +1701,7 @@ check_calls:
 #endif
 		ip = chain->ips[j];
 
-		err = add_callchain_ip(thread, parent, root_al, false, ip);
+		err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 
 		if (err)
 			return (err < 0) ? err : 0;
-- 
2.1.4


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

* Re: [PATCH v2] perf callchain: fix kernel symbol resolution by remembering the cpumode
  2015-03-30  8:11 ` [PATCH v2] " David Hildenbrand
@ 2015-03-30  8:54   ` Jiri Olsa
  2015-03-30  9:18     ` David Hildenbrand
  2015-04-02 12:23   ` [tip:perf/core] perf callchain: Fix " tip-bot for David Hildenbrand
  1 sibling, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2015-03-30  8:54 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, a.p.zijlstra, paulus, mingo, acme, acme, jolsa,
	kan.liang, namhyung, adrian.hunter, ak, brueckner, schwidefsky

On Mon, Mar 30, 2015 at 10:11:00AM +0200, David Hildenbrand wrote:
> Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
> add_callchain_ip") promised "No change in behavior.".
> 
> As this commit breaks callchains on s390x (symbols not getting resolved,

I think it's a generic problem not just s390x

the x86 archs were safe due to the (al->map == NULL) fallback
in thread__find_addr_map, where we rerun the lookup for kernel
maps.. I need to rethink this check :-\

perhaps s390x did not match the machine__kernel_ip condition?


> observed when profiling the kernel), this statement is wrong. The cpumode
> must be kept when iterating over all ips, otherwise the default
> (PERF_RECORD_MISC_USER) will be used by error.

anyway

Acked-by: Jiri Olsa <jolsa@kernel.org>


thanks,
jirka

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

* Re: [PATCH v2] perf callchain: fix kernel symbol resolution by remembering the cpumode
  2015-03-30  8:54   ` Jiri Olsa
@ 2015-03-30  9:18     ` David Hildenbrand
  0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2015-03-30  9:18 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, a.p.zijlstra, paulus, mingo, acme, acme, jolsa,
	kan.liang, namhyung, adrian.hunter, ak, brueckner, schwidefsky

> On Mon, Mar 30, 2015 at 10:11:00AM +0200, David Hildenbrand wrote:
> > Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
> > add_callchain_ip") promised "No change in behavior.".
> > 
> > As this commit breaks callchains on s390x (symbols not getting resolved,
> 
> I think it's a generic problem not just s390x
> 
> the x86 archs were safe due to the (al->map == NULL) fallback
> in thread__find_addr_map, where we rerun the lookup for kernel
> maps.. I need to rethink this check :-\
> 
> perhaps s390x did not match the machine__kernel_ip condition?

Most probably yes, in contrast to other archs, we can't really decide based on
the address if it belongs to user or kernel space. So we need the context.

> 
> 
> > observed when profiling the kernel), this statement is wrong. The cpumode
> > must be kept when iterating over all ips, otherwise the default
> > (PERF_RECORD_MISC_USER) will be used by error.
> 
> anyway
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> 
> 

Thanks!

David


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

* [tip:perf/core] perf callchain: Fix kernel symbol resolution by remembering the cpumode
  2015-03-30  8:11 ` [PATCH v2] " David Hildenbrand
  2015-03-30  8:54   ` Jiri Olsa
@ 2015-04-02 12:23   ` tip-bot for David Hildenbrand
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for David Hildenbrand @ 2015-04-02 12:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: ak, linux-kernel, a.p.zijlstra, schwidefsky, paulus, mingo,
	adrian.hunter, brueckner, tglx, acme, dahi, kan.liang, jolsa,
	hpa, namhyung

Commit-ID:  73dbcd6537f0ef6bf98d84f8fd7f8ab9994c6cd8
Gitweb:     http://git.kernel.org/tip/73dbcd6537f0ef6bf98d84f8fd7f8ab9994c6cd8
Author:     David Hildenbrand <dahi@linux.vnet.ibm.com>
AuthorDate: Mon, 30 Mar 2015 10:11:00 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 31 Mar 2015 17:52:17 -0300

perf callchain: Fix kernel symbol resolution by remembering the cpumode

Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to
add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved,
observed when profiling the kernel), this statement is wrong. The cpumode
must be kept when iterating over all ips, otherwise the default
(PERF_RECORD_MISC_USER) will be used by error.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1427703060-59883-1-git-send-email-dahi@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/machine.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e335330..e45c8f3 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
 static int add_callchain_ip(struct thread *thread,
 			    struct symbol **parent,
 			    struct addr_location *root_al,
-			    bool branch_history,
+			    u8 *cpumode,
 			    u64 ip)
 {
 	struct addr_location al;
 
 	al.filtered = 0;
 	al.sym = NULL;
-	if (branch_history)
+	if (!cpumode) {
 		thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
 						   ip, &al);
-	else {
-		u8 cpumode = PERF_RECORD_MISC_USER;
-
+	} else {
 		if (ip >= PERF_CONTEXT_MAX) {
 			switch (ip) {
 			case PERF_CONTEXT_HV:
-				cpumode = PERF_RECORD_MISC_HYPERVISOR;
+				*cpumode = PERF_RECORD_MISC_HYPERVISOR;
 				break;
 			case PERF_CONTEXT_KERNEL:
-				cpumode = PERF_RECORD_MISC_KERNEL;
+				*cpumode = PERF_RECORD_MISC_KERNEL;
 				break;
 			case PERF_CONTEXT_USER:
-				cpumode = PERF_RECORD_MISC_USER;
+				*cpumode = PERF_RECORD_MISC_USER;
 				break;
 			default:
 				pr_debug("invalid callchain context: "
@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
 			}
 			return 0;
 		}
-		thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
-				   ip, &al);
+		thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
+					   ip, &al);
 	}
 
 	if (al.sym != NULL) {
@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 {
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	u64 ip;
 
@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 					ip = lbr_stack->entries[0].to;
 			}
 
-			err = add_callchain_ip(thread, parent, root_al, false, ip);
+			err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 			if (err)
 				return (err < 0) ? err : 0;
 		}
@@ -1604,6 +1603,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	struct branch_stack *branch = sample->branch_stack;
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	int skip_idx = -1;
 	int first_call = 0;
@@ -1669,10 +1669,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 
 		for (i = 0; i < nr; i++) {
 			err = add_callchain_ip(thread, parent, root_al,
-					       true, be[i].to);
+					       NULL, be[i].to);
 			if (!err)
 				err = add_callchain_ip(thread, parent, root_al,
-						       true, be[i].from);
+						       NULL, be[i].from);
 			if (err == -EINVAL)
 				break;
 			if (err)
@@ -1701,7 +1701,7 @@ check_calls:
 #endif
 		ip = chain->ips[j];
 
-		err = add_callchain_ip(thread, parent, root_al, false, ip);
+		err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 
 		if (err)
 			return (err < 0) ? err : 0;

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

end of thread, other threads:[~2015-04-02 12:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27 15:08 [PATCH v1] perf callchain: fix kernel symbol resolution by remembering the cpumode David Hildenbrand
2015-03-27 16:09 ` Liang, Kan
2015-03-27 19:12   ` David Hildenbrand
2015-03-30  8:11 ` [PATCH v2] " David Hildenbrand
2015-03-30  8:54   ` Jiri Olsa
2015-03-30  9:18     ` David Hildenbrand
2015-04-02 12:23   ` [tip:perf/core] perf callchain: Fix " tip-bot for David Hildenbrand

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