linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf report: do not drop last inlined frame
@ 2017-05-18  8:38 Milian Wolff
  2017-05-18  9:55 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2017-05-18  8:38 UTC (permalink / raw)
  To: Linux-kernel
  Cc: linux-perf-users, Milian Wolff, Arnaldo Carvalho de Melo,
	David Ahern, Namhyung Kim, Peter Zijlstra, Yao Jin

The very last inlined frame, i.e. the one furthest away from the
non-inlined frame, was silently dropped. This is apparent when
comparing the output of `perf script` and `addr2line`:

~~~~~~
$ perf script --inline
...
a.out 26722 80836.309329:      72425 cycles:
                   21493 __hypot_finite (/usr/lib/libm-2.25.so)
                     a4a std::abs<double> (inline) (/tmp/a.out)
                     a4a std::_Norm_helper<true>::_S_do_it<double> (inline) (/tmp/a.out)
                     a4a std::norm<double> (inline) (/tmp/a.out)
                     a4a main (/tmp/a.out)
                   20510 __libc_start_main (/usr/lib/libc-2.25.so)
                     bd9 _start (/tmp/a.out)

$ addr2line -a -f -i -e /tmp/a.out a4a | c++filt
0x0000000000000a4a
std::__complex_abs(doublecomplex )
/usr/include/c++/6.3.1/complex:589
double std::abs<double>(std::complex<double> const&)
/usr/include/c++/6.3.1/complex:597
double std::_Norm_helper<true>::_S_do_it<double>(std::complex<double> const&)
/usr/include/c++/6.3.1/complex:654
double std::norm<double>(std::complex<double> const&)
/usr/include/c++/6.3.1/complex:664
main
/tmp/inlining.cpp:14
~~~~~

Note how `std::__complex_abs` is missing from the `perf script`
output. This is similarly showing up in `perf report`. The patch
here fixes this issue, and the output becomes:

~~~~~
a.out 26722 80836.309329:      72425 cycles:
                   21493 __hypot_finite (/usr/lib/libm-2.25.so)
                    ace3 hypot (/usr/lib/libm-2.25.so)
                     a4a std::__complex_abs (inline) (/tmp/a.out)
                     a4a std::abs<double> (inline) (/tmp/a.out)
                     a4a std::_Norm_helper<true>::_S_do_it<double> (inline) (/tmp/a.out)
                     a4a std::norm<double> (inline) (/tmp/a.out)
                     a4a main (/tmp/a.out)
                   20510 __libc_start_main (/usr/lib/libc-2.25.so)
                     bd9 _start (/tmp/a.out)
~~~~~

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Yao Jin <yao.jin@linux.intel.com>
Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
---
 tools/perf/util/srcline.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

v2:
- rebase against patch fixing memleak in addr2lines

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index bbba9c69cfec..168285d37cd2 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -203,6 +203,16 @@ static void addr2line_cleanup(struct a2l_data *a2l)
 
 #define MAX_INLINE_NEST 1024
 
+static int inline_list__append_dso_a2l(struct dso *dso,
+				       struct inline_node *node)
+{
+	struct a2l_data *a2l = dso->a2l;
+	char *funcname = a2l->funcname ? strdup(a2l->funcname) : NULL;
+	char *filename = a2l->filename ? strdup(a2l->filename) : NULL;
+
+	return inline_list__append(filename, funcname, a2l->line, node, dso);
+}
+
 static int addr2line(const char *dso_name, u64 addr,
 		     char **file, unsigned int *line, struct dso *dso,
 		     bool unwind_inlines, struct inline_node *node)
@@ -231,15 +241,15 @@ static int addr2line(const char *dso_name, u64 addr,
 	if (unwind_inlines) {
 		int cnt = 0;
 
+		if (node && inline_list__append_dso_a2l(dso, node))
+			return 0;
+
 		while (bfd_find_inliner_info(a2l->abfd, &a2l->filename,
 					     &a2l->funcname, &a2l->line) &&
 		       cnt++ < MAX_INLINE_NEST) {
 
 			if (node != NULL) {
-				if (inline_list__append(strdup(a2l->filename),
-							strdup(a2l->funcname),
-							a2l->line, node,
-							dso) != 0)
+				if (inline_list__append_dso_a2l(dso, node))
 					return 0;
 				// found at least one inline frame
 				ret = 1;
-- 
2.13.0

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

* Re: [PATCH v2] perf report: do not drop last inlined frame
  2017-05-18  8:38 [PATCH v2] perf report: do not drop last inlined frame Milian Wolff
@ 2017-05-18  9:55 ` Namhyung Kim
  2017-05-18 12:13   ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2017-05-18  9:55 UTC (permalink / raw)
  To: Milian Wolff
  Cc: Linux-kernel, linux-perf-users, Arnaldo Carvalho de Melo,
	David Ahern, Peter Zijlstra, Yao Jin, kernel-team

On Thu, May 18, 2017 at 10:38:22AM +0200, Milian Wolff wrote:
> The very last inlined frame, i.e. the one furthest away from the
> non-inlined frame, was silently dropped. This is apparent when
> comparing the output of `perf script` and `addr2line`:
> 
> ~~~~~~
> $ perf script --inline
> ...
> a.out 26722 80836.309329:      72425 cycles:
>                    21493 __hypot_finite (/usr/lib/libm-2.25.so)
>                      a4a std::abs<double> (inline) (/tmp/a.out)
>                      a4a std::_Norm_helper<true>::_S_do_it<double> (inline) (/tmp/a.out)
>                      a4a std::norm<double> (inline) (/tmp/a.out)
>                      a4a main (/tmp/a.out)
>                    20510 __libc_start_main (/usr/lib/libc-2.25.so)
>                      bd9 _start (/tmp/a.out)
> 
> $ addr2line -a -f -i -e /tmp/a.out a4a | c++filt
> 0x0000000000000a4a
> std::__complex_abs(doublecomplex )
> /usr/include/c++/6.3.1/complex:589
> double std::abs<double>(std::complex<double> const&)
> /usr/include/c++/6.3.1/complex:597
> double std::_Norm_helper<true>::_S_do_it<double>(std::complex<double> const&)
> /usr/include/c++/6.3.1/complex:654
> double std::norm<double>(std::complex<double> const&)
> /usr/include/c++/6.3.1/complex:664
> main
> /tmp/inlining.cpp:14
> ~~~~~
> 
> Note how `std::__complex_abs` is missing from the `perf script`
> output. This is similarly showing up in `perf report`. The patch
> here fixes this issue, and the output becomes:
> 
> ~~~~~
> a.out 26722 80836.309329:      72425 cycles:
>                    21493 __hypot_finite (/usr/lib/libm-2.25.so)
>                     ace3 hypot (/usr/lib/libm-2.25.so)

Why is the 'hypot' missing in the above perf script output?  Is it
another problem?

Thanks,
Namhyung


>                      a4a std::__complex_abs (inline) (/tmp/a.out)
>                      a4a std::abs<double> (inline) (/tmp/a.out)
>                      a4a std::_Norm_helper<true>::_S_do_it<double> (inline) (/tmp/a.out)
>                      a4a std::norm<double> (inline) (/tmp/a.out)
>                      a4a main (/tmp/a.out)
>                    20510 __libc_start_main (/usr/lib/libc-2.25.so)
>                      bd9 _start (/tmp/a.out)
> ~~~~~
> 
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Yao Jin <yao.jin@linux.intel.com>
> Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
> ---
>  tools/perf/util/srcline.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> v2:
> - rebase against patch fixing memleak in addr2lines
> 
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index bbba9c69cfec..168285d37cd2 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -203,6 +203,16 @@ static void addr2line_cleanup(struct a2l_data *a2l)
>  
>  #define MAX_INLINE_NEST 1024
>  
> +static int inline_list__append_dso_a2l(struct dso *dso,
> +				       struct inline_node *node)
> +{
> +	struct a2l_data *a2l = dso->a2l;
> +	char *funcname = a2l->funcname ? strdup(a2l->funcname) : NULL;
> +	char *filename = a2l->filename ? strdup(a2l->filename) : NULL;
> +
> +	return inline_list__append(filename, funcname, a2l->line, node, dso);
> +}
> +
>  static int addr2line(const char *dso_name, u64 addr,
>  		     char **file, unsigned int *line, struct dso *dso,
>  		     bool unwind_inlines, struct inline_node *node)
> @@ -231,15 +241,15 @@ static int addr2line(const char *dso_name, u64 addr,
>  	if (unwind_inlines) {
>  		int cnt = 0;
>  
> +		if (node && inline_list__append_dso_a2l(dso, node))
> +			return 0;
> +
>  		while (bfd_find_inliner_info(a2l->abfd, &a2l->filename,
>  					     &a2l->funcname, &a2l->line) &&
>  		       cnt++ < MAX_INLINE_NEST) {
>  
>  			if (node != NULL) {
> -				if (inline_list__append(strdup(a2l->filename),
> -							strdup(a2l->funcname),
> -							a2l->line, node,
> -							dso) != 0)
> +				if (inline_list__append_dso_a2l(dso, node))
>  					return 0;
>  				// found at least one inline frame
>  				ret = 1;
> -- 
> 2.13.0
> 

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

* Re: [PATCH v2] perf report: do not drop last inlined frame
  2017-05-18  9:55 ` Namhyung Kim
@ 2017-05-18 12:13   ` Milian Wolff
  0 siblings, 0 replies; 3+ messages in thread
From: Milian Wolff @ 2017-05-18 12:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Linux-kernel, linux-perf-users, Arnaldo Carvalho de Melo,
	David Ahern, Peter Zijlstra, Yao Jin, kernel-team

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

On Donnerstag, 18. Mai 2017 11:55:38 CEST Namhyung Kim wrote:
> On Thu, May 18, 2017 at 10:38:22AM +0200, Milian Wolff wrote:
> > The very last inlined frame, i.e. the one furthest away from the
> > non-inlined frame, was silently dropped. This is apparent when
> > comparing the output of `perf script` and `addr2line`:
> > 
> > ~~~~~~
> > $ perf script --inline
> > ...
> > 
> > a.out 26722 80836.309329:      72425 cycles:
> >                    21493 __hypot_finite (/usr/lib/libm-2.25.so)
> >                    
> >                      a4a std::abs<double> (inline) (/tmp/a.out)
> >                      a4a std::_Norm_helper<true>::_S_do_it<double>
> >                      (inline) (/tmp/a.out)
> >                      a4a std::norm<double> (inline) (/tmp/a.out)
> >                      a4a main (/tmp/a.out)
> >                    
> >                    20510 __libc_start_main (/usr/lib/libc-2.25.so)
> >                    
> >                      bd9 _start (/tmp/a.out)
> > 
> > $ addr2line -a -f -i -e /tmp/a.out a4a | c++filt
> > 0x0000000000000a4a
> > std::__complex_abs(doublecomplex )
> > /usr/include/c++/6.3.1/complex:589
> > double std::abs<double>(std::complex<double> const&)
> > /usr/include/c++/6.3.1/complex:597
> > double std::_Norm_helper<true>::_S_do_it<double>(std::complex<double>
> > const&) /usr/include/c++/6.3.1/complex:654
> > double std::norm<double>(std::complex<double> const&)
> > /usr/include/c++/6.3.1/complex:664
> > main
> > /tmp/inlining.cpp:14
> > ~~~~~
> > 
> > Note how `std::__complex_abs` is missing from the `perf script`
> > output. This is similarly showing up in `perf report`. The patch
> > here fixes this issue, and the output becomes:
> > 
> > ~~~~~
> > 
> > a.out 26722 80836.309329:      72425 cycles:
> >                    21493 __hypot_finite (/usr/lib/libm-2.25.so)
> >                    
> >                     ace3 hypot (/usr/lib/libm-2.25.so)
> 
> Why is the 'hypot' missing in the above perf script output?  Is it
> another problem?

Uhm, good question. I fear I messed up by testing this with other patches 
applied in the background. I just tested this in a stand-alone manner and I 
cannot reproduce this issue. The script output is different, too (based on 
your original patch). I'll update the commit message and send v3.

Before:

                   21561 __hypot_finite (/usr/lib/libm-2.25.so)
                    ace3 hypot (/usr/lib/libm-2.25.so)
                     a4a main (/home/milian/projects/src/perf-tests/inlining)
                         std::abs<double>
                         std::_Norm_helper<true>::_S_do_it<double>
                         std::norm<double>
                         main
                   20510 __libc_start_main (/usr/lib/libc-2.25.so)
                     bd9 _start (/home/milian/projects/src/perf-tests/
inlining)

After:
                   21561 __hypot_finite (/usr/lib/libm-2.25.so)
                    ace3 hypot (/usr/lib/libm-2.25.so)
                     a4a main (/home/milian/projects/src/perf-tests/inlining)
                         std::__complex_abs
                         std::abs<double>
                         std::_Norm_helper<true>::_S_do_it<double>
                         std::norm<double>
                         main
                   20510 __libc_start_main (/usr/lib/libc-2.25.so)
                     bd9 _start (/home/milian/projects/src/perf-tests/
inlining)

Btw, if you wonder why main is twice in there - that's going to be fixed by my 
upcoming patch series to rework inline frames.

Cheers

-- 
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] 3+ messages in thread

end of thread, other threads:[~2017-05-18 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18  8:38 [PATCH v2] perf report: do not drop last inlined frame Milian Wolff
2017-05-18  9:55 ` Namhyung Kim
2017-05-18 12:13   ` Milian Wolff

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