From: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Kristen Carlson Accardi <kristen@linux.intel.com>,
live-patching@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: Re: [PATCH] perf-probe: dso: Add symbols in .text.* subsections to text symbol map in kenrel modules
Date: Wed, 24 Feb 2021 10:47:23 +0300 [thread overview]
Message-ID: <49a63bb9-8f0d-755f-cfec-6ebe58ac9519@virtuozzo.com> (raw)
In-Reply-To: <YDVhgENpshYqDqiO@kernel.org>
On 23.02.2021 23:11, Arnaldo Carvalho de Melo wrote:
> Em Tue, Feb 23, 2021 at 06:02:58PM +0300, Evgenii Shatokhin escreveu:
>> On 23.02.2021 10:37, Masami Hiramatsu wrote:
>>> The kernel modules have .text.* subsections such as .text.unlikely.
>>> Since dso__process_kernel_symbol() only identify the symbols in the ".text"
>>> section as the text symbols and inserts it in the default dso in the map,
>>> the symbols in such subsections can not be found by map__find_symbol().
>>>
>>> This adds the symbols in those subsections to the default dso in the map so
>>> that map__find_symbol() can find them. This solves the perf-probe issue on
>>> probing online module.
>>>
>>> Without this fix, probing on a symbol in .text.unlikely fails.
>>> ----
>>> # perf probe -m nf_conntrack nf_l4proto_log_invalid
>>> Probe point 'nf_l4proto_log_invalid' not found.
>>> Error: Failed to add events.
>>> ----
>>>
>>> With this fix, it works because map__find_symbol() can find the symbol
>>> correctly.
>>> ----
>>> # perf probe -m nf_conntrack nf_l4proto_log_invalid
>>> Added new event:
>>> probe:nf_l4proto_log_invalid (on nf_l4proto_log_invalid in nf_conntrack)
>>>
>>> You can now use it in all perf tools, such as:
>>>
>>> perf record -e probe:nf_l4proto_log_invalid -aR sleep 1
>>>
>>> ----
>>>
>>> Reported-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
>>> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
>>
>> Thanks for the fix!
>>
>> It looks like it helps, at least with nf_conntrack in kernel 5.11:
>
> So I'm taking this as you providing a:
>
> Tested-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
>
> ok?
Sure, thanks!
>
> - Arnaldo
>
>> ---------------------
>> # ./perf probe -v -m nf_conntrack nf_ct_resolve_clash
>> probe-definition(0): nf_ct_resolve_clash
>> symbol:nf_ct_resolve_clash file:(null) line:0 offset:0 return:0 lazy:(null)
>> 0 arguments
>> Failed to get build-id from nf_conntrack.
>> Cache open error: -1
>> Open Debuginfo file:
>> /lib/modules/5.11.0-test01/kernel/net/netfilter/nf_conntrack.ko
>> Try to find probe point from debuginfo.
>> Matched function: nf_ct_resolve_clash [33616]
>> Probe point found: nf_ct_resolve_clash+0
>> Found 1 probe_trace_events.
>> Opening /sys/kernel/tracing//kprobe_events write=1
>> Opening /sys/kernel/tracing//README write=0
>> Writing event: p:probe/nf_ct_resolve_clash
>> nf_conntrack:nf_ct_resolve_clash+0
>> Added new event:
>> probe:nf_ct_resolve_clash (on nf_ct_resolve_clash in nf_conntrack)
>>
>> You can now use it in all perf tools, such as:
>>
>> perf record -e probe:nf_ct_resolve_clash -aR sleep 1
>> ---------------------
>>
>> I guess, the patch is suitable for stable kernel branches as well.
>>
>> Without the patch, the workaround you suggested earlier (using the full path
>> to nf_conntrack.ko) works too.
>>
>>> ---
>>> tools/perf/util/symbol-elf.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
>>> index 6dff843fd883..0c1113236913 100644
>>> --- a/tools/perf/util/symbol-elf.c
>>> +++ b/tools/perf/util/symbol-elf.c
>>> @@ -985,7 +985,9 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
>>> if (strcmp(section_name, (curr_dso->short_name + dso->short_name_len)) == 0)
>>> return 0;
>>> - if (strcmp(section_name, ".text") == 0) {
>>> + /* .text and .text.* are included in the text dso */
>>> + if (strncmp(section_name, ".text", 5) == 0 &&
>>> + (section_name[5] == '\0' || section_name[5] == '.')) {
>>> /*
>>> * The initial kernel mapping is based on
>>> * kallsyms and identity maps. Overwrite it to
>>>
>>> .
>>>
>>
>> Regards,
>> Evgenii
>
prev parent reply other threads:[~2021-02-24 7:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 17:09 'perf probe' and symbols from .text.<something> Evgenii Shatokhin
2021-02-18 19:35 ` Josh Poimboeuf
2021-02-22 15:05 ` Masami Hiramatsu
2021-02-22 15:12 ` Masami Hiramatsu
2021-02-22 17:51 ` Josh Poimboeuf
2021-02-23 1:23 ` Masami Hiramatsu
2021-02-23 7:36 ` Masami Hiramatsu
2021-02-23 19:45 ` Josh Poimboeuf
2021-02-24 8:00 ` Masami Hiramatsu
2021-02-23 1:48 ` [PATCH] perf-probe: Failback to symbol-base probe for probes on module Masami Hiramatsu
2021-02-23 7:36 ` Masami Hiramatsu
2021-02-23 7:09 ` 'perf probe' and symbols from .text.<something> Masami Hiramatsu
2021-02-23 7:37 ` [PATCH] perf-probe: dso: Add symbols in .text.* subsections to text symbol map in kenrel modules Masami Hiramatsu
2021-02-23 15:02 ` Evgenii Shatokhin
2021-02-23 20:11 ` Arnaldo Carvalho de Melo
2021-02-24 7:47 ` Evgenii Shatokhin [this message]
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=49a63bb9-8f0d-755f-cfec-6ebe58ac9519@virtuozzo.com \
--to=eshatokhin@virtuozzo.com \
--cc=acme@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=khorenko@virtuozzo.com \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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).