From: "Wangnan (F)" <wangnan0@huawei.com>
To: "平松雅巳 / HIRAMATU,MASAMI" <masami.hiramatsu.pt@hitachi.com>,
"'ltc-kernel@ml.yrl.intra.hitachi.co.jp'"
<ltc-kernel@ml.yrl.intra.hitachi.co.jp>,
"'acme@kernel.org'" <acme@kernel.org>
Cc: "namhyung@kernel.org" <namhyung@kernel.org>,
"lizefan@huawei.com" <lizefan@huawei.com>,
"pi3orama@163.com" <pi3orama@163.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jolsa@kernel.org" <jolsa@kernel.org>
Subject: Re: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success
Date: Fri, 6 Nov 2015 17:27:06 +0800 [thread overview]
Message-ID: <563C726A.4060209@huawei.com> (raw)
In-Reply-To: <563C6539.7030605@huawei.com>
On 2015/11/6 16:30, Wangnan (F) wrote:
>
>
> On 2015/11/6 15:12, 平松雅巳 / HIRAMATU,MASAMI wrote:
>> From: acme@kernel.org [mailto:acme@kernel.org]
>>>> Em Thu, Nov 05, 2015 at 02:08:48PM +0000, 平松雅巳 /
>>>> HIRAMATU,MASAMI escreveu:
>>>>> From: Wang Nan [mailto:wangnan0@huawei.com]
[SNIP]
>> Ah, finally I got what happened. I guess the problem may happen when
>> we put
>> a probe on the kernel somewhere outside of any functions and run
>> "perf probe -l".
>> I think it should not be allowed to put the probe outside any symbol.
>>
>> The background is here, at first "perf-probe -a somewhere" defines a
>> probe in
>> the kernel but its address is relative from "_text". (thus, vfs_read
>> becomes "_text+2348080"
>> for example). Since it is not readable by human, perf probe -l
>> tries to get an appropriate
>> symbol from the "_text+OFFSET".
>> For the purpose, the first kernel_get_symbol_address_by_name() is for
>> translating _text to
>> an address, and the second __find_kernel_function() is for finding a
>> symbol from the
>> address+OFFSET.
>> Then, if the address+OFFSET is out of the symbol map, the second one
>> can fail.
>> This means the first symbol and the second symbol is not same.
>>
>> So, the direction of Wang solution is good :). Just a cleanup is
>> required.
>>
>> Thank you!
>
> I also tried to finger out the problem for all day and made some
> progress. It is another
> problem. It happeneds when probing an address reside in a module on
> aarch64 system.
>
> On my aarch64 system I use kcore. Different from x86, on aarch64,
> modules address is lower
> than normal kernel. For example:
>
> On x86_64:
>
> # readelf -a /proc/kcore
>
> Type Offset VirtAddr PhysAddr
> FileSiz MemSiz Flags Align
> ...
> LOAD 0x00007fff81003000 0xffffffff81000000
> 0x0000000000000000 <-- kernel
> 0x0000000001026000 0x0000000001026000 RWE 1000
> LOAD 0x00007fffa0003000 0xffffffffa0000000
> 0x0000000000000000 <-- module
> 0x000000005f000000 0x000000005f000000 RWE 1000
>
> On aarch64:
>
> Type Offset VirtAddr PhysAddr
> FileSiz MemSiz Flags Align
> ...
> LOAD 0x0000000000002000 0xffffffc000000000
> 0x0000000000000000 <-- kernel
> 0x000000007fc00000 0x000000007fc00000 RWE 1000
> LOAD 0xfffffffffc002000 0xffffffbffc000000
> 0x0000000000000000 <-- module
> 0x0000000004000000 0x0000000004000000 RWE 1000
>
> See? On aarch64, Offset field of module address area is negative.
>
One thing should be noticed that, even if normal kernel code and modules
use different
'struct map', they share a same dso. Please see dso__load_kcore, notice
how it initialize
parameters (md) before calling file__read_maps().
> Which causes a problem in dso__split_kallsyms_for_kcore(): when it
> adjusting symbols
> using "pos->start -= curr_map->start - curr_map->pgoff", the relative
> order between
> module functions and normal kernel function is changed.
>
> For example:
>
> funca at 0xffffffc00021b428 is a normal kernel function.
> funcb at 0xffffffbffc000000 is a function in kernel.
>
> During parsing /proc/kallsyms, address of funca > address of funcb.
>
> However, after the adjusting:
>
> funca becomes:
>
> 0xffffffc00021b428 - (0xffffffc000000000 - 0x2000) = 0x21d428
>
> funcb becomes:
>
> 0xffffffbffc000000 - (0xffffffbffc000000 - 0xfffffffffc002000) =
> 0xfffffffffc002000
>
> address of funca < address of funcb.
>
> Unfortunately, the rbtree is not adjusted in this case.
>
Even if they are in different maps, they share a same dso here, so a
same rbtree.
Thank you.
next prev parent reply other threads:[~2015-11-06 9:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 13:19 [PATCH 0/2] perf tools: Two bugfixs related to perf probe Wang Nan
2015-11-05 13:19 ` [PATCH 1/2] perf probe: Only call probe_file__get_events() when fd is valid Wang Nan
2015-11-05 14:23 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 14:57 ` Arnaldo Carvalho de Melo
2015-11-05 15:07 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 15:58 ` 'Arnaldo Carvalho de Melo'
2015-11-06 9:50 ` [PATCH v2] perf probe: Verify parameters for two functions Wang Nan
2015-11-06 10:03 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-11 7:00 ` Wangnan (F)
2015-11-12 6:43 ` [tip:perf/urgent] perf probe: Verify parameters in " tip-bot for Wang Nan
2015-11-05 13:19 ` [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success Wang Nan
2015-11-05 14:08 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 16:00 ` acme
2015-11-06 6:28 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-06 7:12 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-06 8:30 ` Wangnan (F)
2015-11-06 9:27 ` Wangnan (F) [this message]
2015-11-06 13:43 ` Arnaldo Carvalho de Melo
2015-11-08 7:31 ` [tip:perf/urgent] perf tools: Fix find_perf_probe_point_from_map( ) " tip-bot for Wang Nan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=563C726A.4060209@huawei.com \
--to=wangnan0@huawei.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=ltc-kernel@ml.yrl.intra.hitachi.co.jp \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).