linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Inlined functions in perf report
@ 2016-12-20 11:59 Steinar H. Gunderson
  2016-12-20 12:17 ` Peter Zijlstra
  0 siblings, 1 reply; 16+ messages in thread
From: Steinar H. Gunderson @ 2016-12-20 11:59 UTC (permalink / raw)
  To: peterz; +Cc: linux-kernel

Hi Peter,

I can't find a good point of contact for perf, so I'm contacting you based on
the MAINTAINERS file; feel free to redirect somewhere if you're not the right
person.

I'm trying to figure out how to deal with perf report when there are inlined
functions; they don't generally seem to show up in the call stack, which
sometimes can make it very hard to figure out what is going, especially in
a code base one doesn't know too well. As an example, I threw together a
minimal test program:

  #include <stdlib.h>
  
  inline int foo()
  {
          int k = rand();
          int sum = 1;
          for (int i = 0; i < 10000000000; ++i)
          {
                  sum ^= k;
                  sum += k;
          }
          return sum;
  }
  
  int main(void)
  {
          return foo();
  }

Compiling with -O2 -g, and running perf record -g yields:

  # Samples: 6K of event 'cycles:ppp'
  # Event count (approx.): 5876825543
  #
  # Children      Self  Command  Shared Object      Symbol                
  # ........  ........  .......  .................  ......................
  #
      99.98%    99.98%  inline   inline             [.] main
              |
              ---0x706258d4c544155
                 main
  
      99.98%     0.00%  inline   [unknown]          [.] 0x0706258d4c544155
              |
              ---0x706258d4c544155
                 main

Is there a way I can get it to show “foo” in the call graph? (I suppose also
ideally, “foo” and not “main” should show up in a non-graph run.) Of course,
this gets even more confusing if foo calls bar, since it now looks like the
call chain is main -> bar directly.

I have debug information that should be sufficient in the binary, because if
I break in gdb, I definitely get the call stack:

  Program received signal SIGINT, Interrupt.
  0x0000555555554589 in foo () at inline.c:5
  5               int k = rand();
  (gdb) bt
  #0  0x0000555555554589 in foo () at inline.c:5
  #1  main () at inline.c:17
  (gdb) 

FWIW, this is with perf from 4.10 (git as of a few days ago) and GCC 6.2.1.

/* Steinar */
-- 
Homepage: https://www.sesse.net/

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

end of thread, other threads:[~2016-12-21 22:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 11:59 Inlined functions in perf report Steinar H. Gunderson
2016-12-20 12:17 ` Peter Zijlstra
2016-12-20 13:27   ` Milian Wolff
2016-12-20 13:43     ` Steinar H. Gunderson
2016-12-20 14:03       ` Milian Wolff
2016-12-20 13:54     ` Arnaldo Carvalho de Melo
2016-12-20 14:05       ` Milian Wolff
2016-12-20 14:08       ` Steinar H. Gunderson
2016-12-20 14:37         ` Arnaldo Carvalho de Melo
2016-12-20 17:01           ` Steinar H. Gunderson
2016-12-21  0:53             ` Jin, Yao
2016-12-21  9:58               ` Steinar H. Gunderson
2016-12-21 10:09                 ` Milian Wolff
2016-12-21 10:20                   ` Steinar H. Gunderson
2016-12-21 22:56                     ` Jin, Yao
2016-12-21 22:58                       ` Steinar H. Gunderson

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