Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1271296 > unrolled thread
| Started by | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| First post | 2015-11-17 16:10 +0100 |
| Last post | 2015-11-26 09:20 +0100 |
| Articles | 14 — 6 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 05:20 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Namhyung Kim <namhyung@kernel.org> - 2015-11-18 06:50 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 08:40 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Namhyung Kim <namhyung@kernel.org> - 2015-11-22 16:30 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-18 09:30 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-18 09:30 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Namhyung Kim <namhyung@gmail.com> - 2015-11-18 10:30 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-18 09:00 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 09:10 +0100
Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-18 09:20 +0100
[PATCHv2 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-18 09:00 +0100
Re: [PATCHv2 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 10:50 +0100
[tip:perf/core] perf callchain: Add order support for libunwind DWARF unwinder tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:20 +0100
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2015-11-17 16:10 +0100 |
| Subject | [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qvQ3o-6Fs-7@gated-at.bofh.it> |
From: Jiri Olsa <jolsa@redhat.com>
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
Reported-by: Milian Wolff <milian.wolff@kdab.com>
Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 0ae8844fe7a6..705e1c19f1ea 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -615,34 +615,47 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg, int max_stack)
{
u64 val;
+ unw_word_t ips[max_stack];
unw_addr_space_t addr_space;
unw_cursor_t c;
- int ret;
+ int ret, i = 0;
ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
if (ret)
return ret;
- ret = entry(val, ui->thread, cb, arg);
- if (ret)
- return -ENOMEM;
+ ips[i++] = (unw_word_t) val;
- if (--max_stack == 0)
- return 0;
-
- addr_space = thread__priv(ui->thread);
- if (addr_space == NULL)
- return -1;
+ /*
+ * If we need more than one entry, do the DWARF
+ * unwind itself.
+ */
+ if (max_stack - 1 > 0) {
+ addr_space = thread__priv(ui->thread);
+ if (addr_space == NULL)
+ return -1;
+
+ ret = unw_init_remote(&c, addr_space, ui);
+ if (ret)
+ display_error(ret);
+
+ while (!ret && (unw_step(&c) > 0) && i < max_stack) {
+ unw_get_reg(&c, UNW_REG_IP, &ips[i]);
+ ++i;
+ }
- ret = unw_init_remote(&c, addr_space, ui);
- if (ret)
- display_error(ret);
+ max_stack = i;
+ }
- while (!ret && (unw_step(&c) > 0) && max_stack--) {
- unw_word_t ip;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < max_stack && !ret; i++) {
+ int j = i;
- unw_get_reg(&c, UNW_REG_IP, &ip);
- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
+ if (callchain_param.order == ORDER_CALLER)
+ j = max_stack - i - 1;
+ ret = entry(ips[j], ui->thread, cb, arg);
}
return ret;
--
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] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-18 05:20 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw2nU-6d6-13@gated-at.bofh.it> |
| In reply to | #1271296 |
On 2015/11/17 23:05, Jiri Olsa wrote:
> From: Jiri Olsa <jolsa@redhat.com>
>
> 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
>
> Reported-by: Milian Wolff <milian.wolff@kdab.com>
> Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
> Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
> 1 file changed, 30 insertions(+), 17 deletions(-)
>
> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> index 0ae8844fe7a6..705e1c19f1ea 100644
> --- a/tools/perf/util/unwind-libunwind.c
> +++ b/tools/perf/util/unwind-libunwind.c
[SNIP]
>
> - unw_get_reg(&c, UNW_REG_IP, &ip);
> - ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
In original code if ip == 0 entry() won't be called.
> + if (callchain_param.order == ORDER_CALLER)
> + j = max_stack - i - 1;
> + ret = entry(ips[j], ui->thread, cb, arg);
But in new code event if ips[j] == 0 an entry will be built, which causes
a behavior changes user noticable:
Before this patch:
# perf report --no-children --stdio --call-graph=callee
...
3.38% a.out a.out [.] funcc
|
---funcc
|
--2.70%-- funcb
funca
main
__libc_start_main
_start
After this patch:
# perf report --no-children --stdio --call-graph=callee
...
3.38% a.out a.out [.] funcc
|
---funcc
|
|--2.70%-- funcb
| funca
| main
| __libc_start_main
| _start
|
--0.68%-- 0
I'm not sure whether we can regard this behavior changing as a bugfix? I
think
there may be some reason the original code explicitly avoid creating an '0'
entry.
Then I tried to find why perf can't get call frame on my case, and
I guess there's something wrong whe dealing with 'call' command, because
the instruction on it I can't get callchain from libunwind is a 'callq':
...
4005bf: be 00 00 00 00 mov $0x0,%esi
4005c4: 48 89 c7 mov %rax,%rdi
4005c7: e8 74 fe ff ff callq 400440 <gettimeofday@plt>
us2 = tv2.tv_sec * 1000000 + tv2.tv_usec;
4005cc: 48 8b 04 24 mov (%rsp),%rax
...
But this is another problem, we can discuss it in a new thread.
Thank you.
--
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 | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2015-11-18 06:50 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw3N0-74f-7@gated-at.bofh.it> |
| In reply to | #1271841 |
On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote:
>
>
> On 2015/11/17 23:05, Jiri Olsa wrote:
> >From: Jiri Olsa <jolsa@redhat.com>
> >
> >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
> >
> >Reported-by: Milian Wolff <milian.wolff@kdab.com>
> >Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
> >Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
> >Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> >---
> > tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
> > 1 file changed, 30 insertions(+), 17 deletions(-)
> >
> >diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> >index 0ae8844fe7a6..705e1c19f1ea 100644
> >--- a/tools/perf/util/unwind-libunwind.c
> >+++ b/tools/perf/util/unwind-libunwind.c
>
> [SNIP]
>
> >- unw_get_reg(&c, UNW_REG_IP, &ip);
> >- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
>
> In original code if ip == 0 entry() won't be called.
>
> >+ if (callchain_param.order == ORDER_CALLER)
> >+ j = max_stack - i - 1;
> >+ ret = entry(ips[j], ui->thread, cb, arg);
>
> But in new code event if ips[j] == 0 an entry will be built, which causes
> a behavior changes user noticable:
>
> Before this patch:
>
>
> # perf report --no-children --stdio --call-graph=callee
> ...
> 3.38% a.out a.out [.] funcc
> |
> ---funcc
> |
> --2.70%-- funcb
> funca
> main
> __libc_start_main
> _start
>
> After this patch:
>
> # perf report --no-children --stdio --call-graph=callee
> ...
> 3.38% a.out a.out [.] funcc
> |
> ---funcc
> |
> |--2.70%-- funcb
> | funca
> | main
> | __libc_start_main
> | _start
> |
> --0.68%-- 0
>
>
> I'm not sure whether we can regard this behavior changing as a bugfix? I
> think
> there may be some reason the original code explicitly avoid creating an '0'
> entry.
I think callchain value being 0 is an error or marker for the end of
callchain. So it'd be better avoiding 0 entry.
But unfortunately, we have many 0 entries (and broken callchain after
them) with fp recording on optimized binaries. I think we should omit
those callchains.
Maybe something like this?
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 5ef90be2a249..22642c5719ab 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1850,6 +1850,15 @@ static int thread__resolve_callchain_sample(struct thread *thread,
#endif
ip = chain->ips[j];
+ /* callchain value inside zero page means it's broken, stop */
+ if (ip < 4096) {
+ if (callchain_param.order == ORDER_CALLER) {
+ callchain_cursor_reset(&callchain_cursor);
+ continue;
+ } else
+ break;
+ }
+
err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
if (err)
--
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 08:40 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw5vr-8gO-13@gated-at.bofh.it> |
| In reply to | #1271855 |
On 2015/11/18 13:41, Namhyung Kim wrote:
> On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote:
>>
>> On 2015/11/17 23:05, Jiri Olsa wrote:
>>> From: Jiri Olsa <jolsa@redhat.com>
>>>
>>> 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
>>>
>>> Reported-by: Milian Wolff <milian.wolff@kdab.com>
>>> Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
>>> Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>> ---
>>> tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
>>> 1 file changed, 30 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
>>> index 0ae8844fe7a6..705e1c19f1ea 100644
>>> --- a/tools/perf/util/unwind-libunwind.c
>>> +++ b/tools/perf/util/unwind-libunwind.c
>> [SNIP]
>>
>>> - unw_get_reg(&c, UNW_REG_IP, &ip);
>>> - ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
>> In original code if ip == 0 entry() won't be called.
>>
>>> + if (callchain_param.order == ORDER_CALLER)
>>> + j = max_stack - i - 1;
>>> + ret = entry(ips[j], ui->thread, cb, arg);
>> But in new code event if ips[j] == 0 an entry will be built, which causes
>> a behavior changes user noticable:
>>
>> Before this patch:
>>
>>
>> # perf report --no-children --stdio --call-graph=callee
>> ...
>> 3.38% a.out a.out [.] funcc
>> |
>> ---funcc
>> |
>> --2.70%-- funcb
>> funca
>> main
>> __libc_start_main
>> _start
>>
>> After this patch:
>>
>> # perf report --no-children --stdio --call-graph=callee
>> ...
>> 3.38% a.out a.out [.] funcc
>> |
>> ---funcc
>> |
>> |--2.70%-- funcb
>> | funca
>> | main
>> | __libc_start_main
>> | _start
>> |
>> --0.68%-- 0
>>
>>
>> I'm not sure whether we can regard this behavior changing as a bugfix? I
>> think
>> there may be some reason the original code explicitly avoid creating an '0'
>> entry.
> I think callchain value being 0 is an error or marker for the end of
> callchain. So it'd be better avoiding 0 entry.
>
> But unfortunately, we have many 0 entries (and broken callchain after
> them) with fp recording on optimized binaries. I think we should omit
> those callchains.
>
> Maybe something like this?
>
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 5ef90be2a249..22642c5719ab 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1850,6 +1850,15 @@ static int thread__resolve_callchain_sample(struct thread *thread,
> #endif
> ip = chain->ips[j];
>
> + /* callchain value inside zero page means it's broken, stop */
> + if (ip < 4096) {
> + if (callchain_param.order == ORDER_CALLER) {
> + callchain_cursor_reset(&callchain_cursor);
> + continue;
> + } else
> + break;
> + }
> +
> err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
>
> if (err)
Then we totally get rid of 0 entries, but how can we explain
the sum of overhead of different branches?
Is it possible to explicitly tell user the place where perf
failed to unwind call stack? For example:
3.38% a.out a.out [.] funcc
|
---funcc
|
|--2.70%-- funcb
| funca
| main
| __libc_start_main
| _start
|
--0.68%-- (unwind failure)
Thank you.
--
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 | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2015-11-22 16:30 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qxEKt-5Eu-3@gated-at.bofh.it> |
| In reply to | #1271895 |
Hello,
Sorry for late reply, I missed this in the mailbox..
On Wed, Nov 18, 2015 at 03:26:54PM +0800, Wangnan (F) wrote:
> On 2015/11/18 13:41, Namhyung Kim wrote:
> >On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote:
> >>
> >>On 2015/11/17 23:05, Jiri Olsa wrote:
> >>>From: Jiri Olsa <jolsa@redhat.com>
> >>>
> >>>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
> >>>
> >>>Reported-by: Milian Wolff <milian.wolff@kdab.com>
> >>>Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
> >>>Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
> >>>Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> >>>---
> >>> tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
> >>> 1 file changed, 30 insertions(+), 17 deletions(-)
> >>>
> >>>diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> >>>index 0ae8844fe7a6..705e1c19f1ea 100644
> >>>--- a/tools/perf/util/unwind-libunwind.c
> >>>+++ b/tools/perf/util/unwind-libunwind.c
> >>[SNIP]
> >>
> >>>- unw_get_reg(&c, UNW_REG_IP, &ip);
> >>>- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
> >>In original code if ip == 0 entry() won't be called.
> >>
> >>>+ if (callchain_param.order == ORDER_CALLER)
> >>>+ j = max_stack - i - 1;
> >>>+ ret = entry(ips[j], ui->thread, cb, arg);
> >>But in new code event if ips[j] == 0 an entry will be built, which causes
> >>a behavior changes user noticable:
> >>
> >>Before this patch:
> >>
> >>
> >># perf report --no-children --stdio --call-graph=callee
> >>...
> >> 3.38% a.out a.out [.] funcc
> >> |
> >> ---funcc
> >> |
> >> --2.70%-- funcb
> >> funca
> >> main
> >> __libc_start_main
> >> _start
> >>
> >>After this patch:
> >>
> >># perf report --no-children --stdio --call-graph=callee
> >>...
> >> 3.38% a.out a.out [.] funcc
> >> |
> >> ---funcc
> >> |
> >> |--2.70%-- funcb
> >> | funca
> >> | main
> >> | __libc_start_main
> >> | _start
> >> |
> >> --0.68%-- 0
> >>
> >>
> >>I'm not sure whether we can regard this behavior changing as a bugfix? I
> >>think
> >>there may be some reason the original code explicitly avoid creating an '0'
> >>entry.
> >I think callchain value being 0 is an error or marker for the end of
> >callchain. So it'd be better avoiding 0 entry.
> >
> >But unfortunately, we have many 0 entries (and broken callchain after
> >them) with fp recording on optimized binaries. I think we should omit
> >those callchains.
> >
> >Maybe something like this?
> >
> >
> >diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> >index 5ef90be2a249..22642c5719ab 100644
> >--- a/tools/perf/util/machine.c
> >+++ b/tools/perf/util/machine.c
> >@@ -1850,6 +1850,15 @@ static int thread__resolve_callchain_sample(struct thread *thread,
> > #endif
> > ip = chain->ips[j];
> >+ /* callchain value inside zero page means it's broken, stop */
> >+ if (ip < 4096) {
> >+ if (callchain_param.order == ORDER_CALLER) {
> >+ callchain_cursor_reset(&callchain_cursor);
> >+ continue;
> >+ } else
> >+ break;
> >+ }
> >+
> > err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
> > if (err)
>
> Then we totally get rid of 0 entries, but how can we explain
> the sum of overhead of different branches?
>
> Is it possible to explicitly tell user the place where perf
> failed to unwind call stack? For example:
>
> 3.38% a.out a.out [.] funcc
> |
> ---funcc
> |
> |--2.70%-- funcb
> | funca
> | main
> | __libc_start_main
> | _start
> |
> --0.68%-- (unwind failure)
Hmm.. we have something similar in the fractal callchain mode, but it
doesn't say about the failure.
I think it's hard for perf to know whether a given callchain is broken
or not. It seems that correct callchains end with 0 entry, but broken
chains all can have 0 entries in the middle.
Thanks,
Namhyung
--
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-18 09:30 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw6hP-nn-1@gated-at.bofh.it> |
| In reply to | #1271855 |
On Wed, Nov 18, 2015 at 02:41:14PM +0900, Namhyung Kim wrote:
SNIP
>
> I think callchain value being 0 is an error or marker for the end of
> callchain. So it'd be better avoiding 0 entry.
>
> But unfortunately, we have many 0 entries (and broken callchain after
> them) with fp recording on optimized binaries. I think we should omit
> those callchains.
>
> Maybe something like this?
>
>
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 5ef90be2a249..22642c5719ab 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1850,6 +1850,15 @@ static int thread__resolve_callchain_sample(struct thread *thread,
> #endif
> ip = chain->ips[j];
>
> + /* callchain value inside zero page means it's broken, stop */
> + if (ip < 4096) {
you could use page_size in here
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 | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-18 09:30 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw6hQ-nn-29@gated-at.bofh.it> |
| In reply to | #1271855 |
On Wed, Nov 18, 2015 at 02:41:14PM +0900, Namhyung Kim wrote:
SNIP
> > I'm not sure whether we can regard this behavior changing as a bugfix? I
> > think
> > there may be some reason the original code explicitly avoid creating an '0'
> > entry.
>
> I think callchain value being 0 is an error or marker for the end of
> callchain. So it'd be better avoiding 0 entry.
>
> But unfortunately, we have many 0 entries (and broken callchain after
> them) with fp recording on optimized binaries. I think we should omit
> those callchains.
>
> Maybe something like this?
>
>
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 5ef90be2a249..22642c5719ab 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1850,6 +1850,15 @@ static int thread__resolve_callchain_sample(struct thread *thread,
> #endif
> ip = chain->ips[j];
>
> + /* callchain value inside zero page means it's broken, stop */
> + if (ip < 4096) {
> + if (callchain_param.order == ORDER_CALLER) {
> + callchain_cursor_reset(&callchain_cursor);
hum, do we want to throw away whatever we have till now?
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 | Namhyung Kim <namhyung@gmail.com> |
|---|---|
| Date | 2015-11-18 10:30 +0100 |
| Message-ID | <qw7dT-10j-17@gated-at.bofh.it> |
| In reply to | #1271931 |
On November 18, 2015 5:25:25 PM GMT+09:00, Jiri Olsa <jolsa@redhat.com> wrote:
>On Wed, Nov 18, 2015 at 02:41:14PM +0900, Namhyung Kim wrote:
>
>SNIP
>
>> > I'm not sure whether we can regard this behavior changing as a
>bugfix? I
>> > think
>> > there may be some reason the original code explicitly avoid
>creating an '0'
>> > entry.
>>
>> I think callchain value being 0 is an error or marker for the end of
>> callchain. So it'd be better avoiding 0 entry.
>>
>> But unfortunately, we have many 0 entries (and broken callchain after
>> them) with fp recording on optimized binaries. I think we should
>omit
>> those callchains.
>>
>> Maybe something like this?
>>
>>
>>
>> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
>> index 5ef90be2a249..22642c5719ab 100644
>> --- a/tools/perf/util/machine.c
>> +++ b/tools/perf/util/machine.c
>> @@ -1850,6 +1850,15 @@ static int
>thread__resolve_callchain_sample(struct thread *thread,
>> #endif
>> ip = chain->ips[j];
>>
>> + /* callchain value inside zero page means it's broken, stop */
>> + if (ip < 4096) {
>> + if (callchain_param.order == ORDER_CALLER) {
>> + callchain_cursor_reset(&callchain_cursor);
>
>hum, do we want to throw away whatever we have till now?
For caller order, yes.
For callee order, everything after 0 value is garbage. So we need to discard any chains before the 0 for caller IMHO.
Thanks
Namhyung
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
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-18 09:00 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw5OO-8o2-11@gated-at.bofh.it> |
| In reply to | #1271841 |
On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote: SNIP > 3.38% a.out a.out [.] funcc > | > ---funcc > | > |--2.70%-- funcb > | funca > | main > | __libc_start_main > | _start > | > --0.68%-- 0 > > > I'm not sure whether we can regard this behavior changing as a bugfix? I > think > there may be some reason the original code explicitly avoid creating an '0' > entry. > > Then I tried to find why perf can't get call frame on my case, and > I guess there's something wrong whe dealing with 'call' command, because > the instruction on it I can't get callchain from libunwind is a 'callq': > > ... > 4005bf: be 00 00 00 00 mov $0x0,%esi > 4005c4: 48 89 c7 mov %rax,%rdi > 4005c7: e8 74 fe ff ff callq 400440 <gettimeofday@plt> > us2 = tv2.tv_sec * 1000000 + tv2.tv_usec; > 4005cc: 48 8b 04 24 mov (%rsp),%rax > ... > > But this is another problem, we can discuss it in a new thread. so the problem is you dont see the gettimeofday call at the end? could you share the test code? 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 | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-18 09:10 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw5Yu-fd-9@gated-at.bofh.it> |
| In reply to | #1271901 |
On 2015/11/18 15:54, Jiri Olsa wrote:
> On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote:
>
> SNIP
>
>> 3.38% a.out a.out [.] funcc
>> |
>> ---funcc
>> |
>> |--2.70%-- funcb
>> | funca
>> | main
>> | __libc_start_main
>> | _start
>> |
>> --0.68%-- 0
>>
>>
>> I'm not sure whether we can regard this behavior changing as a bugfix? I
>> think
>> there may be some reason the original code explicitly avoid creating an '0'
>> entry.
>>
>> Then I tried to find why perf can't get call frame on my case, and
>> I guess there's something wrong whe dealing with 'call' command, because
>> the instruction on it I can't get callchain from libunwind is a 'callq':
>>
>> ...
>> 4005bf: be 00 00 00 00 mov $0x0,%esi
>> 4005c4: 48 89 c7 mov %rax,%rdi
>> 4005c7: e8 74 fe ff ff callq 400440 <gettimeofday@plt>
>> us2 = tv2.tv_sec * 1000000 + tv2.tv_usec;
>> 4005cc: 48 8b 04 24 mov (%rsp),%rax
>> ...
>>
>> But this is another problem, we can discuss it in a new thread.
> so the problem is you dont see the gettimeofday call at the end?
No. The problem is when sample is taken at 'callq' perf is unable to
unwind correctly, even with dwarf and user stack.
> could you share the test code?
I have posted a detail analysis in [1] (rechecked, you are in cc-list).
Test code is here:
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
static volatile int x = 0;
int funcc(void)
{
struct timeval tv1, tv2;
unsigned long us1, us2;
gettimeofday(&tv1, NULL);
us1 = tv1.tv_sec * 1000000 + tv1.tv_usec;
while(1) {
x = x + 100;
gettimeofday(&tv2, NULL);
us2 = tv2.tv_sec * 1000000 + tv2.tv_usec;
if (us2 - us1 >= 3000000)
break;
}
return x;
}
int funcb(void) { return funcc();}
int funca(void) { return funcb();}
int main() { funca(); return 0;}
Thank you.
[1] http://lkml.kernel.org/r/564C26C4.2040603@huawei.com
>
> 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 | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-18 09:20 +0100 |
| Subject | Re: [PATCH 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw689-jO-9@gated-at.bofh.it> |
| In reply to | #1271901 |
On Wed, Nov 18, 2015 at 08:54:31AM +0100, Jiri Olsa wrote: > On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote: > > SNIP > > > 3.38% a.out a.out [.] funcc > > | > > ---funcc > > | > > |--2.70%-- funcb > > | funca > > | main > > | __libc_start_main > > | _start > > | > > --0.68%-- 0 > > > > > > I'm not sure whether we can regard this behavior changing as a bugfix? I > > think > > there may be some reason the original code explicitly avoid creating an '0' > > entry. > > > > Then I tried to find why perf can't get call frame on my case, and > > I guess there's something wrong whe dealing with 'call' command, because > > the instruction on it I can't get callchain from libunwind is a 'callq': > > > > ... > > 4005bf: be 00 00 00 00 mov $0x0,%esi > > 4005c4: 48 89 c7 mov %rax,%rdi > > 4005c7: e8 74 fe ff ff callq 400440 <gettimeofday@plt> > > us2 = tv2.tv_sec * 1000000 + tv2.tv_usec; > > 4005cc: 48 8b 04 24 mov (%rsp),%rax > > ... > > > > But this is another problem, we can discuss it in a new thread. > > so the problem is you dont see the gettimeofday call at the end? > > could you share the test code? just saw your other email on this issue.. let's continue there 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 | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2015-11-18 09:00 +0100 |
| Subject | [PATCHv2 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw5OO-8o2-15@gated-at.bofh.it> |
| In reply to | #1271841 |
On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote:
>
>
> On 2015/11/17 23:05, Jiri Olsa wrote:
> >From: Jiri Olsa <jolsa@redhat.com>
> >
> >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
> >
> >Reported-by: Milian Wolff <milian.wolff@kdab.com>
> >Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
> >Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
> >Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> >---
> > tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
> > 1 file changed, 30 insertions(+), 17 deletions(-)
> >
> >diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> >index 0ae8844fe7a6..705e1c19f1ea 100644
> >--- a/tools/perf/util/unwind-libunwind.c
> >+++ b/tools/perf/util/unwind-libunwind.c
>
> [SNIP]
>
> >- unw_get_reg(&c, UNW_REG_IP, &ip);
> >- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
>
> In original code if ip == 0 entry() won't be called.
>
> >+ if (callchain_param.order == ORDER_CALLER)
> >+ j = max_stack - i - 1;
> >+ ret = entry(ips[j], ui->thread, cb, arg);
ouch.. the intention was not to breake current behaviour ;-)
v2 is attached, it's also in perf/callchain_2 branch
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 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
Reported-by: Milian Wolff <milian.wolff@kdab.com>
Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 0ae8844fe7a6..3c258a0e4092 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -615,34 +615,47 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg, int max_stack)
{
u64 val;
+ unw_word_t ips[max_stack];
unw_addr_space_t addr_space;
unw_cursor_t c;
- int ret;
+ int ret, i = 0;
ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
if (ret)
return ret;
- ret = entry(val, ui->thread, cb, arg);
- if (ret)
- return -ENOMEM;
+ ips[i++] = (unw_word_t) val;
- if (--max_stack == 0)
- return 0;
-
- addr_space = thread__priv(ui->thread);
- if (addr_space == NULL)
- return -1;
+ /*
+ * If we need more than one entry, do the DWARF
+ * unwind itself.
+ */
+ if (max_stack - 1 > 0) {
+ addr_space = thread__priv(ui->thread);
+ if (addr_space == NULL)
+ return -1;
+
+ ret = unw_init_remote(&c, addr_space, ui);
+ if (ret)
+ display_error(ret);
+
+ while (!ret && (unw_step(&c) > 0) && i < max_stack) {
+ unw_get_reg(&c, UNW_REG_IP, &ips[i]);
+ ++i;
+ }
- ret = unw_init_remote(&c, addr_space, ui);
- if (ret)
- display_error(ret);
+ max_stack = i;
+ }
- while (!ret && (unw_step(&c) > 0) && max_stack--) {
- unw_word_t ip;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < max_stack && !ret; i++) {
+ int j = i;
- unw_get_reg(&c, UNW_REG_IP, &ip);
- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
+ if (callchain_param.order == ORDER_CALLER)
+ j = max_stack - i - 1;
+ ret = ips[j] ? entry(ips[j], ui->thread, cb, arg) : 0;
}
return ret;
--
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-18 10:50 +0100 |
| Subject | Re: [PATCHv2 2/3] perf tools: Add callchain order support for libunwind DWARF unwinder |
| Message-ID | <qw7xg-17g-3@gated-at.bofh.it> |
| In reply to | #1271902 |
On 2015/11/18 15:52, Jiri Olsa wrote: > On Wed, Nov 18, 2015 at 12:13:08PM +0800, Wangnan (F) wrote: >> >> On 2015/11/17 23:05, Jiri Olsa wrote: >>> From: Jiri Olsa <jolsa@redhat.com> >>> >>> 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 >>> >>> Reported-by: Milian Wolff <milian.wolff@kdab.com> >>> Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com> >>> Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org >>> Signed-off-by: Jiri Olsa <jolsa@kernel.org> >>> --- >>> tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++-------------- >>> 1 file changed, 30 insertions(+), 17 deletions(-) >>> >>> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c >>> index 0ae8844fe7a6..705e1c19f1ea 100644 >>> --- a/tools/perf/util/unwind-libunwind.c >>> +++ b/tools/perf/util/unwind-libunwind.c >> [SNIP] >> >>> - unw_get_reg(&c, UNW_REG_IP, &ip); >>> - ret = ip ? entry(ip, ui->thread, cb, arg) : 0; >> In original code if ip == 0 entry() won't be called. >> >>> + if (callchain_param.order == ORDER_CALLER) >>> + j = max_stack - i - 1; >>> + ret = entry(ips[j], ui->thread, cb, arg); > ouch.. the intention was not to breake current behaviour ;-) > > v2 is attached, it's also in perf/callchain_2 branch > > 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 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 > > Reported-by: Milian Wolff <milian.wolff@kdab.com> > Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com> > Link: http://lkml.kernel.org/n/tip-lmtbeqm403f3luw4jkjevsi5@git.kernel.org > Signed-off-by: Jiri Olsa <jolsa@kernel.org> This time behavior is not changed. Thank you. Tested-by: Wang Nan <wangnan0@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 | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-26 09:20 +0100 |
| Subject | [tip:perf/core] perf callchain: Add order support for libunwind DWARF unwinder |
| Message-ID | <qyZWy-2oi-25@gated-at.bofh.it> |
| In reply to | #1271902 |
Commit-ID: cb1dc22dce6e54dbd1eac213c9216e1aa57084da
Gitweb: http://git.kernel.org/tip/cb1dc22dce6e54dbd1eac213c9216e1aa57084da
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Wed, 18 Nov 2015 08:52:47 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Nov 2015 18:30:41 -0300
perf callchain: Add order support for libunwind 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 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
Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com>
Reported-and-Tested-by: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20151118075247.GA5416@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/unwind-libunwind.c | 47 ++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 0ae8844..3c258a0 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -615,34 +615,47 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg, int max_stack)
{
u64 val;
+ unw_word_t ips[max_stack];
unw_addr_space_t addr_space;
unw_cursor_t c;
- int ret;
+ int ret, i = 0;
ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
if (ret)
return ret;
- ret = entry(val, ui->thread, cb, arg);
- if (ret)
- return -ENOMEM;
+ ips[i++] = (unw_word_t) val;
- if (--max_stack == 0)
- return 0;
-
- addr_space = thread__priv(ui->thread);
- if (addr_space == NULL)
- return -1;
+ /*
+ * If we need more than one entry, do the DWARF
+ * unwind itself.
+ */
+ if (max_stack - 1 > 0) {
+ addr_space = thread__priv(ui->thread);
+ if (addr_space == NULL)
+ return -1;
+
+ ret = unw_init_remote(&c, addr_space, ui);
+ if (ret)
+ display_error(ret);
+
+ while (!ret && (unw_step(&c) > 0) && i < max_stack) {
+ unw_get_reg(&c, UNW_REG_IP, &ips[i]);
+ ++i;
+ }
- ret = unw_init_remote(&c, addr_space, ui);
- if (ret)
- display_error(ret);
+ max_stack = i;
+ }
- while (!ret && (unw_step(&c) > 0) && max_stack--) {
- unw_word_t ip;
+ /*
+ * Display what we got based on the order setup.
+ */
+ for (i = 0; i < max_stack && !ret; i++) {
+ int j = i;
- unw_get_reg(&c, UNW_REG_IP, &ip);
- ret = ip ? entry(ip, ui->thread, cb, arg) : 0;
+ if (callchain_param.order == ORDER_CALLER)
+ j = max_stack - i - 1;
+ ret = ips[j] ? entry(ips[j], ui->thread, cb, arg) : 0;
}
return ret;
--
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] | [standalone]
Back to top | Article view | linux.kernel
csiph-web