From: Zheng Yejian <zhengyejian1@huawei.com>
To: Martin Kelly <martin.kelly@crowdstrike.com>,
"masahiroy@kernel.org" <masahiroy@kernel.org>,
"ojeda@kernel.org" <ojeda@kernel.org>,
"jpoimboe@kernel.org" <jpoimboe@kernel.org>,
"pasha.tatashin@soleen.com" <pasha.tatashin@soleen.com>,
"mhiramat@kernel.org" <mhiramat@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"james.clark@arm.com" <james.clark@arm.com>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"nicolas@fjasle.eu" <nicolas@fjasle.eu>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"christophe.leroy@csgroup.eu" <christophe.leroy@csgroup.eu>,
"nathan@kernel.org" <nathan@kernel.org>,
"npiggin@gmail.com" <npiggin@gmail.com>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"surenb@google.com" <surenb@google.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"naveen.n.rao@linux.ibm.com" <naveen.n.rao@linux.ibm.com>,
"kent.overstreet@linux.dev" <kent.overstreet@linux.dev>,
"bp@alien8.de" <bp@alien8.de>,
"yeweihua4@huawei.com" <yeweihua4@huawei.com>,
"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
"mcgrof@kernel.org" <mcgrof@kernel.org>
Cc: Amit Dang <amit.dang@crowdstrike.com>,
"linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
"linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-trace-kernel@vger.kernel.org"
<linux-trace-kernel@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH v2 0/5] kallsyms: Emit symbol for holes in text and fix weak function issue
Date: Sat, 14 Dec 2024 16:37:59 +0800 [thread overview]
Message-ID: <7266ee61-3085-74fc-2560-c62fc34c2148@huawei.com> (raw)
In-Reply-To: <30ee9989044dad1a7083a85316d77b35f838e622.camel@crowdstrike.com>
On 2024/12/14 03:31, Martin Kelly wrote:
> On Thu, 2024-12-12 at 17:52 +0800, Zheng Yejian wrote:
>> On 2024/12/11 04:49, Martin Kelly wrote:
>>>
>>>
>>> Zheng, do you plan to send a v3? I'd be happy to help out with this
>>> patch series if you'd like, as I'm hoping to get this issue
>>> resolved
>>> (though I am not an ftrace expert).
>>
>> Sorry to rely so late. Thanks for your feedback!
>>
>> Steve recently started a discussion of the issue in:
>>
>> https://lore.kernel.org/all/20241015100111.37adfb28@gandalf.local.home/
>> but there's no conclusion.
>>
>> I can rebase this patch series and send a new version first, and
>> I'm also hoping to get more feedbacks and help to resolve the issue.
>>
>
> Hi Zheng,
>
> I may have misunderstood, but based on the final message from Steven, I
> got the sense that the idea listed in that thread didn't work out and
> we should proceed with your current approach.
This patch set attempts to add length information of symbols to kallsyms,
which can then ensure that there is only one valid fentry within the range
of function length.
However, I think this patch set actually has some performance implications,
including:
1. Adding hole symbols may cause the symbol table to grow significantly;
2. When parsing fentry tables, excluding invalid fentries through kallsyms lookups
may also increase boot or module load times slightly.
The direct cause of this issue is the wrong fentry being founded by ftrace_location(),
following the approach of "FTRACE_MCOUNT_MAX_OFFSET", narrowing down the search range
and re-finding may also solve this problem, demo patch like below (not
fully tested):
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9b17efb1a87d..7d34320ca9d1 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1678,8 +1678,11 @@ unsigned long ftrace_location(unsigned long ip)
goto out;
/* map sym+0 to __fentry__ */
- if (!offset)
+ if (!offset) {
loc = ftrace_location_range(ip, ip + size - 1);
+ while (loc > ip && loc - ip > FTRACE_MCOUNT_MAX_OFFSET)
+ loc = ftrace_location_range(ip, loc - 1);
+ }
}
Steve, Peter, what do you think?
>
> Please consider me an interested party for this patch series, and let
> me know if there's anything I can do to help speed it along (co-
> develop, test, anything else). And of course, thanks very much for your
> work thus far!
--
Thanks,
Zheng Yejian
next prev parent reply other threads:[~2024-12-14 8:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 6:32 [PATCH v2 0/5] kallsyms: Emit symbol for holes in text and fix weak function issue Zheng Yejian
2024-07-23 6:32 ` [PATCH v2 1/5] kallsyms: Emit symbol at the holes in the text Zheng Yejian
2024-07-23 6:32 ` [PATCH v2 2/5] module: kallsyms: Determine exact function size Zheng Yejian
2024-07-23 6:32 ` [PATCH v2 3/5] ftrace: Skip invalid __fentry__ in ftrace_process_locs() Zheng Yejian
2024-07-23 6:32 ` [PATCH v2 4/5] ftrace: Fix possible out-of-bound issue " Zheng Yejian
2024-07-23 6:32 ` [PATCH v2 5/5] ftrace: Revert the FTRACE_MCOUNT_MAX_OFFSET workaround Zheng Yejian
2024-12-10 19:15 ` [PATCH v2 0/5] kallsyms: Emit symbol for holes in text and fix weak function issue Martin Kelly
2024-12-10 20:01 ` Christophe Leroy
2024-12-10 20:49 ` Martin Kelly
2024-12-12 9:52 ` Zheng Yejian
2024-12-13 19:31 ` Martin Kelly
2024-12-14 8:37 ` Zheng Yejian [this message]
2025-01-21 17:48 ` Steven Rostedt
2025-02-07 3:16 ` Zheng Yejian
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=7266ee61-3085-74fc-2560-c62fc34c2148@huawei.com \
--to=zhengyejian1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=amit.dang@crowdstrike.com \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=james.clark@arm.com \
--cc=jpoimboe@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=martin.kelly@crowdstrike.com \
--cc=masahiroy@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=nathan@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=nicolas@fjasle.eu \
--cc=npiggin@gmail.com \
--cc=ojeda@kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yeweihua4@huawei.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