public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] perf report: Show inline stack
@ 2016-11-29 14:55 Jin Yao
  2016-11-29 14:55 ` [PATCH v1 1/4] perf report: Find the inline stack for a given address Jin Yao
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jin Yao @ 2016-11-29 14:55 UTC (permalink / raw)
  To: acme, jolsa; +Cc: Linux-kernel, ak, kan.liang, yao.jin

It would be useful for perf to support a mode to query the
inline stack for callgraph addresses. This would simplify
finding the right code in code that does a lot of inlining.

For example, the c code:

static inline void f3(void)
{
        int i;
        for (i = 0; i < 1000;) {

                if(i%2)
                        i++;
                else
                        i++;
        }
        printf("hello f3\n");   /* D */
}

/* < CALLCHAIN: f2 <- f1 > */
static inline void f2(void)
{
        int i;
        for (i = 0; i < 100; i++) {
                f3();   /* C */
        }
}

/* < CALLCHAIN: f1 <- main > */
static inline void f1(void)
{
        int i;
        for (i = 0; i < 100; i++) {
                f2();   /* B */
        }
}

/* < CALLCHAIN: main <- TOP > */
int main()
{
        struct timeval tv;
        time_t start, end;

        gettimeofday(&tv, NULL);
        start = end = tv.tv_sec;
        while((end - start) < 5) {
                f1();   /* A */
                gettimeofday(&tv, NULL);
                end = tv.tv_sec;
        }
        return 0;
}

The printed inline stack is:

0.05%  test2    test2              [.] main
       |
       ---/home/perf-dev/lck-2867/test/test2.c:27 (inline)
          /home/perf-dev/lck-2867/test/test2.c:35 (inline)
          /home/perf-dev/lck-2867/test/test2.c:45 (inline)
          /home/perf-dev/lck-2867/test/test2.c:61 (inline)

I tag A/B/C/D in above c code to indicate the source line,
actually the inline stack is equal to:

0.05%  test2    test2              [.] main
       |
       ---D
          C
          B
          A

Jin Yao (4):
  perf report: Find the inline stack for a given address
  perf report: Create a new option "--inline"
  perf report: Show inline stack in stdio mode
  perf report: Show inline stack in browser mode

 tools/perf/Documentation/perf-report.txt |   4 +
 tools/perf/builtin-report.c              |   2 +
 tools/perf/ui/browsers/hists.c           |  98 ++++++++++++++-
 tools/perf/ui/stdio/hist.c               |  56 ++++++++-
 tools/perf/util/hist.c                   |   5 +
 tools/perf/util/sort.h                   |   1 +
 tools/perf/util/srcline.c                | 206 ++++++++++++++++++++++++++-----
 tools/perf/util/symbol.h                 |   3 +-
 tools/perf/util/util.h                   |  15 +++
 9 files changed, 356 insertions(+), 34 deletions(-)

-- 
2.7.4

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

end of thread, other threads:[~2016-12-06 20:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 14:55 [PATCH v1 0/4] perf report: Show inline stack Jin Yao
2016-11-29 14:55 ` [PATCH v1 1/4] perf report: Find the inline stack for a given address Jin Yao
2016-12-06 20:02   ` Arnaldo Carvalho de Melo
2016-11-29 14:55 ` [PATCH v1 2/4] perf report: Create a new option "--inline" Jin Yao
2016-11-29 14:55 ` [PATCH v1 3/4] perf report: Show inline stack in stdio mode Jin Yao
2016-11-29 14:55 ` [PATCH v1 4/4] perf report: Show inline stack in browser mode Jin Yao
2016-12-06  0:35 ` [PATCH v1 0/4] perf report: Show inline stack Jin, Yao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox