Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1271299 > unrolled thread
| Started by | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| First post | 2015-11-17 16:10 +0100 |
| Last post | 2015-11-22 20:20 +0100 |
| Articles | 12 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
[PATCH 3/3] perf test: Add callchain order setup for DWARF unwinder test Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
[tip:perf/core] perf test: Add callchain order setup for DWARF unwinder test tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:30 +0100
Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 05:30 +0100
[PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-19 12:30 +0100
Re: [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-19 13:20 +0100
Re: [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-19 13:20 +0100
[PATCHv2 4/3] perf tools: Add callchain order support for libdw DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-19 14:10 +0100
[tip:perf/core] perf callchain: Add order support for libdw DWARF unwinder tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:30 +0100
Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-19 20:20 +0100
Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Jiri Olsa <jolsa@redhat.com> - 2015-11-20 09:40 +0100
Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Milian Wolff <milian.wolff@kdab.com> - 2015-11-22 20:20 +0100
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2015-11-17 16:10 +0100 |
| Subject | [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support |
| Message-ID | <qvQ3o-6Fs-9@gated-at.bofh.it> |
hi,
as reported by Milian, currently for DWARF unwind (both libdw
and libunwind) we display callchain in callee order only.
Adding the support to follow callchain order setup to libunwind
DWARF unwinder, so we could get following output for report:
$ perf record --call-graph dwarf ls
...
$ perf report --no-children --stdio
39.26% ls libc-2.21.so [.] __strcoll_l
|
---__strcoll_l
mpsort_with_tmp
mpsort_with_tmp
sort_files
main
__libc_start_main
_start
0
$ perf report -g caller --no-children --stdio
...
39.26% ls libc-2.21.so [.] __strcoll_l
|
---0
_start
__libc_start_main
main
sort_files
mpsort_with_tmp
mpsort_with_tmp
__strcoll_l
Tested on x86_64. The change is in generic code only,
so it should not affect other archs. Still it would be
nice to have some confirmation.. Wang Nan? ;-)
It'd be nice to have this for libdw unwind as well,
but it looks like it's out of reach for perf code.. Jan?
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/callchain_1
thanks,
jirka
Cc: Jan Kratochvil <jkratoch@redhat.com>
---
Jiri Olsa (3):
perf tools: Move initial entry call into get_entries function
perf tools: Add callchain order support for libunwind DWARF unwinder
perf test: Add callchain order setup for DWARF unwinder test
tools/perf/tests/dwarf-unwind.c | 22 +++++++++++++++++++---
tools/perf/util/unwind-libunwind.c | 60 +++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 58 insertions(+), 24 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2015-11-17 16:10 +0100 |
| Subject | [PATCH 3/3] perf test: Add callchain order setup for DWARF unwinder test |
| Message-ID | <qvQ3p-6Fs-27@gated-at.bofh.it> |
| In reply to | #1271299 |
Adding callchain order setup for DWARF unwinder test. The test
now runs unwinder for both callee and caller orders.
Link: http://lkml.kernel.org/n/tip-zz3q3vrre3re8efdw3c89aef@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/tests/dwarf-unwind.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 07221793a3ac..05d9ba387c43 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -51,6 +51,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
"krava_1",
"test__dwarf_unwind"
};
+ /*
+ * The funcs[MAX_STACK] array index, based on the
+ * callchain order setup.
+ */
+ int idx = callchain_param.order == ORDER_CALLER ?
+ MAX_STACK - *cnt - 1 : *cnt;
if (*cnt >= MAX_STACK) {
pr_debug("failed: crossed the max stack value %d\n", MAX_STACK);
@@ -63,8 +69,10 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
return -1;
}
- pr_debug("got: %s 0x%" PRIx64 "\n", symbol, entry->ip);
- return strcmp((const char *) symbol, funcs[(*cnt)++]);
+ (*cnt)++;
+ pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n",
+ symbol, entry->ip, funcs[idx]);
+ return strcmp((const char *) symbol, funcs[idx]);
}
__attribute__ ((noinline))
@@ -105,8 +113,16 @@ static int compare(void *p1, void *p2)
/* Any possible value should be 'thread' */
struct thread *thread = *(struct thread **)p1;
- if (global_unwind_retval == -INT_MAX)
+ if (global_unwind_retval == -INT_MAX) {
+ /* Call unwinder twice for both callchain orders. */
+ callchain_param.order = ORDER_CALLER;
+
global_unwind_retval = unwind_thread(thread);
+ if (!global_unwind_retval) {
+ callchain_param.order = ORDER_CALLEE;
+ global_unwind_retval = unwind_thread(thread);
+ }
+ }
return p1 - p2;
}
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-26 09:30 +0100 |
| Subject | [tip:perf/core] perf test: Add callchain order setup for DWARF unwinder test |
| Message-ID | <qz06d-2tb-15@gated-at.bofh.it> |
| In reply to | #1271301 |
Commit-ID: 8dc0564d809e3903834950e2d12f6d1d2fcff708
Gitweb: http://git.kernel.org/tip/8dc0564d809e3903834950e2d12f6d1d2fcff708
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 17 Nov 2015 16:05:39 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Nov 2015 18:31:01 -0300
perf test: Add callchain order setup for DWARF unwinder test
Adding callchain order setup for DWARF unwinder test. The test now runs
unwinder for both callee and caller orders.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Milian Wolff <milian.wolff@kdab.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1447772739-18471-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/dwarf-unwind.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 01f0b61..b2357e8 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -51,6 +51,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
"krava_1",
"test__dwarf_unwind"
};
+ /*
+ * The funcs[MAX_STACK] array index, based on the
+ * callchain order setup.
+ */
+ int idx = callchain_param.order == ORDER_CALLER ?
+ MAX_STACK - *cnt - 1 : *cnt;
if (*cnt >= MAX_STACK) {
pr_debug("failed: crossed the max stack value %d\n", MAX_STACK);
@@ -63,8 +69,10 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
return -1;
}
- pr_debug("got: %s 0x%" PRIx64 "\n", symbol, entry->ip);
- return strcmp((const char *) symbol, funcs[(*cnt)++]);
+ (*cnt)++;
+ pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n",
+ symbol, entry->ip, funcs[idx]);
+ return strcmp((const char *) symbol, funcs[idx]);
}
__attribute__ ((noinline))
@@ -105,8 +113,16 @@ static int compare(void *p1, void *p2)
/* Any possible value should be 'thread' */
struct thread *thread = *(struct thread **)p1;
- if (global_unwind_retval == -INT_MAX)
+ if (global_unwind_retval == -INT_MAX) {
+ /* Call unwinder twice for both callchain orders. */
+ callchain_param.order = ORDER_CALLER;
+
global_unwind_retval = unwind_thread(thread);
+ if (!global_unwind_retval) {
+ callchain_param.order = ORDER_CALLEE;
+ global_unwind_retval = unwind_thread(thread);
+ }
+ }
return p1 - p2;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-18 05:30 +0100 |
| Message-ID | <qw2xz-6ho-1@gated-at.bofh.it> |
| In reply to | #1271299 |
Hi Jiri,
On 2015/11/17 23:05, Jiri Olsa wrote:
> hi,
> as reported by Milian, currently for DWARF unwind (both libdw
> and libunwind) we display callchain in callee order only.
>
> Adding the support to follow callchain order setup to libunwind
> DWARF unwinder, so we could get following output for report:
>
> $ perf record --call-graph dwarf ls
> ...
> $ perf report --no-children --stdio
>
> 39.26% ls libc-2.21.so [.] __strcoll_l
> |
> ---__strcoll_l
> mpsort_with_tmp
> mpsort_with_tmp
> sort_files
> main
> __libc_start_main
> _start
> 0
>
> $ perf report -g caller --no-children --stdio
> ...
> 39.26% ls libc-2.21.so [.] __strcoll_l
> |
> ---0
> _start
> __libc_start_main
> main
> sort_files
> mpsort_with_tmp
> mpsort_with_tmp
> __strcoll_l
>
> Tested on x86_64. The change is in generic code only,
> so it should not affect other archs. Still it would be
> nice to have some confirmation.. Wang Nan? ;-)
>
> It'd be nice to have this for libdw unwind as well,
> but it looks like it's out of reach for perf code.. Jan?
>
> Also available in:
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> perf/callchain_1
Thanks for notifying me about this. I have tested it in my environment.
It works well for me except a small behavior changing. Please see below.
Before applying these patch set:
# perf report --no-children --stdio --call-graph=callee
# Overhead Command Shared Object Symbol
# ........ ....... ................ .........................
#
96.61% a.out [vdso] [.] __vdso_gettimeofday
|
---__vdso_gettimeofday
funcc
funcb
funca
main
__libc_start_main
_start
3.38% a.out a.out [.] funcc
|
---funcc
|
--2.70%-- funcb
funca
main
__libc_start_main
_start
0.02% pref_re [kernel.vmlinux] [k] sched_clock
|
---sched_clock
perf_event_nmi_handler
nmi_handle
...
And caller:
# ./perf report --no-children --stdio --call-graph=caller
# Overhead Command Shared Object Symbol
# ........ ....... ................ .........................
#
96.61% a.out [vdso] [.] __vdso_gettimeofday
|
---__vdso_gettimeofday
funcc
funcb
funca
main
__libc_start_main
_start
3.38% a.out a.out [.] funcc
|
---funcc
|
--2.70%-- funcb
funca
main
__libc_start_main
_start
0.02% pref_re [kernel.vmlinux] [k] sched_clock
|
---return_from_execve
sys_execve
do_execveat_common.isra.27
The user code part of output are identical so I confirm the bug.
After applying this patchset:
# ./perf report --no-children --stdio --call-graph=callee
# Overhead Command Shared Object Symbol
# ........ ....... ................ .........................
#
96.61% a.out [vdso] [.] __vdso_gettimeofday
|
---__vdso_gettimeofday
funcc
funcb
funca
main
__libc_start_main
_start
3.38% a.out a.out [.] funcc
|
---funcc
|
|--2.70%-- funcb
| funca
| main
| __libc_start_main
| _start
|
--0.68%-- 0
0.02% pref_re [kernel.vmlinux] [k] sched_clock
|
---sched_clock
perf_event_nmi_handler
...
And caller:
# ./perf report --no-children --stdio --call-graph=caller
# Overhead Command Shared Object Symbol
# ........ ....... ................ .........................
#
96.61% a.out [vdso] [.] __vdso_gettimeofday
|
---_start
__libc_start_main
main
funca
funcb
funcc
__vdso_gettimeofday
3.38% a.out a.out [.] funcc
|
|--2.70%-- _start
| __libc_start_main
| main
| funca
| funcb
| funcc
|
--0.68%-- 0
funcc
0.02% pref_re [kernel.vmlinux] [k] sched_clock
|
---return_from_execve
sys_execve
...
It fixes the bug. However, do you see the extra "0.68%-- 0" in the tree?
I give a message on patch 2/3, please have a look. I think this change
would be okay for me if we treat the old behavior as a bug (for example:
sum of all branches not equal to the overhead of itself). However, the
original code explicitly avoid generating '0' entry so I think we
should make it clear.
Thank you.
> thanks,
> jirka
>
>
> Cc: Jan Kratochvil <jkratoch@redhat.com>
> ---
> Jiri Olsa (3):
> perf tools: Move initial entry call into get_entries function
> perf tools: Add callchain order support for libunwind DWARF unwinder
> perf test: Add callchain order setup for DWARF unwinder test
>
> tools/perf/tests/dwarf-unwind.c | 22 +++++++++++++++++++---
> tools/perf/util/unwind-libunwind.c | 60 +++++++++++++++++++++++++++++++++++++++---------------------
> 2 files changed, 58 insertions(+), 24 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-19 12:30 +0100 |
| Subject | [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder |
| Message-ID | <qwvzA-by-17@gated-at.bofh.it> |
| In reply to | #1271299 |
On Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa wrote:
SNIP
> Tested on x86_64. The change is in generic code only,
> so it should not affect other archs. Still it would be
> nice to have some confirmation.. Wang Nan? ;-)
>
> It'd be nice to have this for libdw unwind as well,
> but it looks like it's out of reach for perf code.. Jan?
>
> Also available in:
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> perf/callchain_1
adding also libdw support.. test with 'make NO_LIBUNWIND=1'
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/callchain_3
thanks,
jirka
---
As reported by Milian, currently for DWARF unwind (both libdw
and libunwind) we display callchain in callee order only.
Adding the support to follow callchain order setup to libdw
DWARF unwinder, so we could get following output for report:
$ perf record --call-graph dwarf ls
...
$ perf report --no-children --stdio
13.63% ls [kernel.vmlinux] [k] __rb_insert_augmented
|
---__rb_insert_augmented
__vma_link_rb
vma_link
do_brk
vm_brk
load_elf_binary
search_binary_handler
do_execveat_common.isra.29
sys_execve
return_from_execve
$ perf report --stdio --no-children -g caller
13.63% ls [kernel.vmlinux] [k] __rb_insert_augmented
|
---return_from_execve
sys_execve
do_execveat_common.isra.29
search_binary_handler
load_elf_binary
vm_brk
do_brk
vma_link
__vma_link_rb
__rb_insert_augmented
Reported-by: Milian Wolff <milian.wolff@kdab.com>
Link: http://lkml.kernel.org/n/tip-zk99ay9s71whl9qd9if28u8z@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/unwind-libdw.c | 53 ++++++++++++++++++++++++++++++------------
tools/perf/util/unwind-libdw.h | 2 ++
2 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 2dcfe9a7c8d0..db8142ba7cb9 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -11,6 +11,7 @@
#include <linux/types.h>
#include "event.h"
#include "perf_regs.h"
+#include "callchain.h"
static char *debuginfo_path;
@@ -52,25 +53,28 @@ static int report_module(u64 ip, struct unwind_info *ui)
return __report_module(&al, ip, ui);
}
+/*
+ * Store all entries within entries array,
+ * we will process it after we finish unwind.
+ */
static int entry(u64 ip, struct unwind_info *ui)
{
- struct unwind_entry e;
+ struct unwind_entry *e = &ui->entries[ui->idx++];
struct addr_location al;
if (__report_module(&al, ip, ui))
return -1;
- e.ip = ip;
- e.map = al.map;
- e.sym = al.sym;
+ e->ip = ip;
+ e->map = al.map;
+ e->sym = al.sym;
pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
al.sym ? al.sym->name : "''",
ip,
al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
-
- return ui->cb(&e, ui->arg);
+ return 0;
}
static pid_t next_thread(Dwfl *dwfl, void *arg, void **thread_argp)
@@ -168,7 +172,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct perf_sample *data,
int max_stack)
{
- struct unwind_info ui = {
+ struct unwind_info *ui, ui_buf = {
.sample = data,
.thread = thread,
.machine = thread->mg->machine,
@@ -177,35 +181,54 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
.max_stack = max_stack,
};
Dwarf_Word ip;
- int err = -EINVAL;
+ int err = -EINVAL, i;
if (!data->user_regs.regs)
return -EINVAL;
- ui.dwfl = dwfl_begin(&offline_callbacks);
- if (!ui.dwfl)
+ ui = zalloc(sizeof(ui_buf) + sizeof(ui_buf.entries[0]) * max_stack);
+ if (!ui)
+ return -ENOMEM;
+
+ *ui = ui_buf;
+
+ ui->dwfl = dwfl_begin(&offline_callbacks);
+ if (!ui->dwfl)
goto out;
err = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP);
if (err)
goto out;
- err = report_module(ip, &ui);
+ err = report_module(ip, ui);
if (err)
goto out;
- if (!dwfl_attach_state(ui.dwfl, EM_NONE, thread->tid, &callbacks, &ui))
+ if (!dwfl_attach_state(ui->dwfl, EM_NONE, thread->tid, &callbacks, ui))
goto out;
- err = dwfl_getthread_frames(ui.dwfl, thread->tid, frame_callback, &ui);
+ err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui);
- if (err && !ui.max_stack)
+ if (err && !ui->max_stack)
err = 0;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < ui->idx && !err; i++) {
+ int j = i;
+
+ if (callchain_param.order == ORDER_CALLER)
+ j = ui->idx - i - 1;
+
+ err = ui->entries[j].ip ? ui->cb(&ui->entries[j], ui->arg) : 0;
+ }
+
out:
if (err)
pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1));
- dwfl_end(ui.dwfl);
+ dwfl_end(ui->dwfl);
+ free(ui);
return 0;
}
diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h
index 417a1426f3ad..58328669ed16 100644
--- a/tools/perf/util/unwind-libdw.h
+++ b/tools/perf/util/unwind-libdw.h
@@ -16,6 +16,8 @@ struct unwind_info {
unwind_entry_cb_t cb;
void *arg;
int max_stack;
+ int idx;
+ struct unwind_entry entries[];
};
#endif /* __PERF_UNWIND_LIBDW_H */
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-19 13:20 +0100 |
| Subject | Re: [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder |
| Message-ID | <qwwlY-KP-11@gated-at.bofh.it> |
| In reply to | #1273049 |
On 2015/11/19 20:10, Wangnan (F) wrote: > > > On 2015/11/19 19:22, Jiri Olsa wrote: >> On Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa wrote: >> [SNIP] > In addition, just for your information, I find libdw can unwind call > chain I described yesterday in [1]. Please forget it. The problem is still their even with libdw. I forgot to add -fomit-frame-pointer. Thank you. > > Thank you. > > [1] https://lkml.kernel.org/g/564C26C4.2040603@huawei.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-19 13:20 +0100 |
| Subject | Re: [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF unwinder |
| Message-ID | <qwwlY-KP-13@gated-at.bofh.it> |
| In reply to | #1273049 |
On 2015/11/19 19:22, Jiri Olsa wrote: > On Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa wrote: > > SNIP > >> Tested on x86_64. The change is in generic code only, >> so it should not affect other archs. Still it would be >> nice to have some confirmation.. Wang Nan? ;-) >> >> It'd be nice to have this for libdw unwind as well, >> but it looks like it's out of reach for perf code.. Jan? >> >> Also available in: >> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git >> perf/callchain_1 > adding also libdw support.. test with 'make NO_LIBUNWIND=1' > > Also available in: > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git > perf/callchain_3 > > thanks, > jirka > > > --- > As reported by Milian, currently for DWARF unwind (both libdw > and libunwind) we display callchain in callee order only. > > Adding the support to follow callchain order setup to libdw > DWARF unwinder, so we could get following output for report: > > $ perf record --call-graph dwarf ls > ... > > $ perf report --no-children --stdio > > 13.63% ls [kernel.vmlinux] [k] __rb_insert_augmented > | > ---__rb_insert_augmented > __vma_link_rb > vma_link > do_brk > vm_brk > load_elf_binary > search_binary_handler > do_execveat_common.isra.29 > sys_execve > return_from_execve > > $ perf report --stdio --no-children -g caller > > 13.63% ls [kernel.vmlinux] [k] __rb_insert_augmented > | > ---return_from_execve > sys_execve > do_execveat_common.isra.29 > search_binary_handler > load_elf_binary > vm_brk > do_brk > vma_link > __vma_link_rb > __rb_insert_augmented > > Reported-by: Milian Wolff <milian.wolff@kdab.com> > Link: http://lkml.kernel.org/n/tip-zk99ay9s71whl9qd9if28u8z@git.kernel.org > Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Wang Nan <wangnan0@huawei.com> And I suggest you put a user space call graph to the commit message to show the result of this patch. What you show now is not related to this patch, right? In addition, just for your information, I find libdw can unwind call chain I described yesterday in [1]. Thank you. [1] https://lkml.kernel.org/g/564C26C4.2040603@huawei.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-19 14:10 +0100 |
| Subject | [PATCHv2 4/3] perf tools: Add callchain order support for libdw DWARF unwinder |
| Message-ID | <qwx8m-1jR-23@gated-at.bofh.it> |
| In reply to | #1273086 |
On Thu, Nov 19, 2015 at 08:10:45PM +0800, Wangnan (F) wrote:
SNIP
> > load_elf_binary
> > vm_brk
> > do_brk
> > vma_link
> > __vma_link_rb
> > __rb_insert_augmented
> >
> >Reported-by: Milian Wolff <milian.wolff@kdab.com>
> >Link: http://lkml.kernel.org/n/tip-zk99ay9s71whl9qd9if28u8z@git.kernel.org
> >Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>
> Tested-by: Wang Nan <wangnan0@huawei.com>
>
> And I suggest you put a user space call graph to the commit message
> to show the result of this patch. What you show now is not related
> to this patch, right?
oopsie.. sry ;-) attached v2
thanks,
jirka
---
As reported by Milian, currently for DWARF unwind (both libdw
and libunwind) we display callchain in callee order only.
Adding the support to follow callchain order setup to libdw
DWARF unwinder, so we could get following output for report:
$ perf record --call-graph dwarf ls
...
$ perf report --no-children --stdio
21.12% ls libc-2.21.so [.] __strcoll_l
|
---__strcoll_l
mpsort_with_tmp
mpsort_with_tmp
mpsort_with_tmp
sort_files
main
__libc_start_main
_start
$ perf report --stdio --no-children -g caller
21.12% ls libc-2.21.so [.] __strcoll_l
|
---_start
__libc_start_main
main
sort_files
mpsort_with_tmp
mpsort_with_tmp
mpsort_with_tmp
__strcoll_l
Tested-by: Wang Nan <wangnan0@huawei.com>
Reported-by: Milian Wolff <milian.wolff@kdab.com>
Link: http://lkml.kernel.org/n/tip-zk99ay9s71whl9qd9if28u8z@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/unwind-libdw.c | 53 ++++++++++++++++++++++++++++++------------
tools/perf/util/unwind-libdw.h | 2 ++
2 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 2dcfe9a7c8d0..db8142ba7cb9 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -11,6 +11,7 @@
#include <linux/types.h>
#include "event.h"
#include "perf_regs.h"
+#include "callchain.h"
static char *debuginfo_path;
@@ -52,25 +53,28 @@ static int report_module(u64 ip, struct unwind_info *ui)
return __report_module(&al, ip, ui);
}
+/*
+ * Store all entries within entries array,
+ * we will process it after we finish unwind.
+ */
static int entry(u64 ip, struct unwind_info *ui)
{
- struct unwind_entry e;
+ struct unwind_entry *e = &ui->entries[ui->idx++];
struct addr_location al;
if (__report_module(&al, ip, ui))
return -1;
- e.ip = ip;
- e.map = al.map;
- e.sym = al.sym;
+ e->ip = ip;
+ e->map = al.map;
+ e->sym = al.sym;
pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
al.sym ? al.sym->name : "''",
ip,
al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
-
- return ui->cb(&e, ui->arg);
+ return 0;
}
static pid_t next_thread(Dwfl *dwfl, void *arg, void **thread_argp)
@@ -168,7 +172,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct perf_sample *data,
int max_stack)
{
- struct unwind_info ui = {
+ struct unwind_info *ui, ui_buf = {
.sample = data,
.thread = thread,
.machine = thread->mg->machine,
@@ -177,35 +181,54 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
.max_stack = max_stack,
};
Dwarf_Word ip;
- int err = -EINVAL;
+ int err = -EINVAL, i;
if (!data->user_regs.regs)
return -EINVAL;
- ui.dwfl = dwfl_begin(&offline_callbacks);
- if (!ui.dwfl)
+ ui = zalloc(sizeof(ui_buf) + sizeof(ui_buf.entries[0]) * max_stack);
+ if (!ui)
+ return -ENOMEM;
+
+ *ui = ui_buf;
+
+ ui->dwfl = dwfl_begin(&offline_callbacks);
+ if (!ui->dwfl)
goto out;
err = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP);
if (err)
goto out;
- err = report_module(ip, &ui);
+ err = report_module(ip, ui);
if (err)
goto out;
- if (!dwfl_attach_state(ui.dwfl, EM_NONE, thread->tid, &callbacks, &ui))
+ if (!dwfl_attach_state(ui->dwfl, EM_NONE, thread->tid, &callbacks, ui))
goto out;
- err = dwfl_getthread_frames(ui.dwfl, thread->tid, frame_callback, &ui);
+ err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui);
- if (err && !ui.max_stack)
+ if (err && !ui->max_stack)
err = 0;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < ui->idx && !err; i++) {
+ int j = i;
+
+ if (callchain_param.order == ORDER_CALLER)
+ j = ui->idx - i - 1;
+
+ err = ui->entries[j].ip ? ui->cb(&ui->entries[j], ui->arg) : 0;
+ }
+
out:
if (err)
pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1));
- dwfl_end(ui.dwfl);
+ dwfl_end(ui->dwfl);
+ free(ui);
return 0;
}
diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h
index 417a1426f3ad..58328669ed16 100644
--- a/tools/perf/util/unwind-libdw.h
+++ b/tools/perf/util/unwind-libdw.h
@@ -16,6 +16,8 @@ struct unwind_info {
unwind_entry_cb_t cb;
void *arg;
int max_stack;
+ int idx;
+ struct unwind_entry entries[];
};
#endif /* __PERF_UNWIND_LIBDW_H */
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-26 09:30 +0100 |
| Subject | [tip:perf/core] perf callchain: Add order support for libdw DWARF unwinder |
| Message-ID | <qz06e-2tb-27@gated-at.bofh.it> |
| In reply to | #1273117 |
Commit-ID: 8bd508b001629a5d836987d9a0702a6bfc4fc705
Gitweb: http://git.kernel.org/tip/8bd508b001629a5d836987d9a0702a6bfc4fc705
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Thu, 19 Nov 2015 14:01:19 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Nov 2015 18:31:13 -0300
perf callchain: Add order support for libdw DWARF unwinder
As reported by Milian, currently for DWARF unwind (both libdw and
libunwind) we display callchain in callee order only.
Adding the support to follow callchain order setup to libdw DWARF
unwinder, so we could get following output for report:
$ perf record --call-graph dwarf ls
...
$ perf report --no-children --stdio
21.12% ls libc-2.21.so [.] __strcoll_l
|
---__strcoll_l
mpsort_with_tmp
mpsort_with_tmp
mpsort_with_tmp
sort_files
main
__libc_start_main
_start
$ perf report --stdio --no-children -g caller
21.12% ls libc-2.21.so [.] __strcoll_l
|
---_start
__libc_start_main
main
sort_files
mpsort_with_tmp
mpsort_with_tmp
mpsort_with_tmp
__strcoll_l
Reported-and-Tested-by: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jan Kratochvil <jkratoch@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20151119130119.GA26617@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/unwind-libdw.c | 53 ++++++++++++++++++++++++++++++------------
tools/perf/util/unwind-libdw.h | 2 ++
2 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 2dcfe9a..db8142b 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -11,6 +11,7 @@
#include <linux/types.h>
#include "event.h"
#include "perf_regs.h"
+#include "callchain.h"
static char *debuginfo_path;
@@ -52,25 +53,28 @@ static int report_module(u64 ip, struct unwind_info *ui)
return __report_module(&al, ip, ui);
}
+/*
+ * Store all entries within entries array,
+ * we will process it after we finish unwind.
+ */
static int entry(u64 ip, struct unwind_info *ui)
{
- struct unwind_entry e;
+ struct unwind_entry *e = &ui->entries[ui->idx++];
struct addr_location al;
if (__report_module(&al, ip, ui))
return -1;
- e.ip = ip;
- e.map = al.map;
- e.sym = al.sym;
+ e->ip = ip;
+ e->map = al.map;
+ e->sym = al.sym;
pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
al.sym ? al.sym->name : "''",
ip,
al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
-
- return ui->cb(&e, ui->arg);
+ return 0;
}
static pid_t next_thread(Dwfl *dwfl, void *arg, void **thread_argp)
@@ -168,7 +172,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct perf_sample *data,
int max_stack)
{
- struct unwind_info ui = {
+ struct unwind_info *ui, ui_buf = {
.sample = data,
.thread = thread,
.machine = thread->mg->machine,
@@ -177,35 +181,54 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
.max_stack = max_stack,
};
Dwarf_Word ip;
- int err = -EINVAL;
+ int err = -EINVAL, i;
if (!data->user_regs.regs)
return -EINVAL;
- ui.dwfl = dwfl_begin(&offline_callbacks);
- if (!ui.dwfl)
+ ui = zalloc(sizeof(ui_buf) + sizeof(ui_buf.entries[0]) * max_stack);
+ if (!ui)
+ return -ENOMEM;
+
+ *ui = ui_buf;
+
+ ui->dwfl = dwfl_begin(&offline_callbacks);
+ if (!ui->dwfl)
goto out;
err = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP);
if (err)
goto out;
- err = report_module(ip, &ui);
+ err = report_module(ip, ui);
if (err)
goto out;
- if (!dwfl_attach_state(ui.dwfl, EM_NONE, thread->tid, &callbacks, &ui))
+ if (!dwfl_attach_state(ui->dwfl, EM_NONE, thread->tid, &callbacks, ui))
goto out;
- err = dwfl_getthread_frames(ui.dwfl, thread->tid, frame_callback, &ui);
+ err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui);
- if (err && !ui.max_stack)
+ if (err && !ui->max_stack)
err = 0;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < ui->idx && !err; i++) {
+ int j = i;
+
+ if (callchain_param.order == ORDER_CALLER)
+ j = ui->idx - i - 1;
+
+ err = ui->entries[j].ip ? ui->cb(&ui->entries[j], ui->arg) : 0;
+ }
+
out:
if (err)
pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1));
- dwfl_end(ui.dwfl);
+ dwfl_end(ui->dwfl);
+ free(ui);
return 0;
}
diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h
index 417a142..5832866 100644
--- a/tools/perf/util/unwind-libdw.h
+++ b/tools/perf/util/unwind-libdw.h
@@ -16,6 +16,8 @@ struct unwind_info {
unwind_entry_cb_t cb;
void *arg;
int max_stack;
+ int idx;
+ struct unwind_entry entries[];
};
#endif /* __PERF_UNWIND_LIBDW_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-19 20:20 +0100 |
| Subject | Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support |
| Message-ID | <qwCUp-57G-13@gated-at.bofh.it> |
| In reply to | #1271299 |
Em Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa escreveu: > hi, > as reported by Milian, currently for DWARF unwind (both libdw > and libunwind) we display callchain in callee order only. Applied the latest versions, please check my perf/core branch to check that all is there as you expect. - Arnaldo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-20 09:40 +0100 |
| Subject | Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support |
| Message-ID | <qwPoD-4LV-41@gated-at.bofh.it> |
| In reply to | #1273422 |
On Thu, Nov 19, 2015 at 04:10:37PM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa escreveu: > > hi, > > as reported by Milian, currently for DWARF unwind (both libdw > > and libunwind) we display callchain in callee order only. > > Applied the latest versions, please check my perf/core branch to check > that all is there as you expect. looks ok, thanks jirka -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Milian Wolff <milian.wolff@kdab.com> |
|---|---|
| Date | 2015-11-22 20:20 +0100 |
| Message-ID | <qxIl4-85o-15@gated-at.bofh.it> |
| In reply to | #1273422 |
[Multipart message — attachments visible in raw view] — view raw
On Donnerstag, 19. November 2015 16:10:37 CET Arnaldo Carvalho de Melo wrote: > Em Tue, Nov 17, 2015 at 04:05:36PM +0100, Jiri Olsa escreveu: > > hi, > > as reported by Milian, currently for DWARF unwind (both libdw > > and libunwind) we display callchain in callee order only. > > Applied the latest versions, please check my perf/core branch to check > that all is there as you expect. Sorry for the late reply. I've just tested the current code in perf/core - works like a charm! Many thanks to Jiri for improving my initial take on this problem and also getting it fixed for libdw. Much appreciated! 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web