From: Song Liu <songliubraving@fb.com>
To: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: bpf <bpf@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"live-patching@vger.kernel.org" <live-patching@vger.kernel.org>,
Song Liu <song@kernel.org>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"jolsa@kernel.org" <jolsa@kernel.org>,
Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH v5 bpf-next 2/4] ftrace: Allow IPMODIFY and DIRECT ops on the same function
Date: Fri, 9 Sep 2022 14:05:27 +0000 [thread overview]
Message-ID: <B59F0FD0-FA3E-4A8B-B588-8F9AA8AC602A@fb.com> (raw)
In-Reply-To: <1662724350.8os86rhyxk.naveen@linux.ibm.com>
> On Sep 9, 2022, at 4:58 AM, Naveen N. Rao <naveen.n.rao@linux.ibm.com> wrote:
>
> Song Liu wrote:
[...]
>> +
>> /**
>> * register_ftrace_function - register a function for profiling
>> * @ops: ops structure that holds the function for profiling.
>> @@ -8018,14 +8206,15 @@ int register_ftrace_function(struct ftrace_ops *ops)
>> {
>> int ret;
>> - ftrace_ops_init(ops);
>> -
>> - mutex_lock(&ftrace_lock);
>> -
>> - ret = ftrace_startup(ops, 0);
>> + lock_direct_mutex();
>
> Trying to enable ftrace direct on powerpc, this is resulting in a hung task when testing samples/ftrace/ftrace-direct-modify.c
>
> Essentially, the sample calls modify_ftrace_direct(), which grabs direct_mutex before calling ftrace_modify_direct_caller()->register_ftrace_function().
>
Thanks for the report. Would the following change fix the issue?
Song
diff --git i/kernel/trace/ftrace.c w/kernel/trace/ftrace.c
index bc921a3f7ea8..2f1e6cfa834e 100644
--- i/kernel/trace/ftrace.c
+++ w/kernel/trace/ftrace.c
@@ -5496,7 +5496,7 @@ int __weak ftrace_modify_direct_caller(struct ftrace_func_entry *entry,
if (ret)
goto out_lock;
- ret = register_ftrace_function(&stub_ops);
+ ret = register_ftrace_function_nolock(&stub_ops);
if (ret) {
ftrace_set_filter_ip(&stub_ops, ip, 1, 0);
goto out_lock;
>
> - Naveen
>
>
>> + ret = prepare_direct_functions_for_ipmodify(ops);
>> + if (ret < 0)
>> + goto out_unlock;
>> - mutex_unlock(&ftrace_lock);
>> + ret = register_ftrace_function_nolock(ops);
>> +out_unlock:
>> + unlock_direct_mutex();
>> return ret;
>> }
>> EXPORT_SYMBOL_GPL(register_ftrace_function);
>> @@ -8044,6 +8233,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
>> ret = ftrace_shutdown(ops, 0);
>> mutex_unlock(&ftrace_lock);
>> + cleanup_direct_functions_after_ipmodify(ops);
>> return ret;
>> }
>> EXPORT_SYMBOL_GPL(unregister_ftrace_function);
>> --
>> 2.30.2
next prev parent reply other threads:[~2022-09-09 14:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 0:21 [PATCH v5 bpf-next 0/4] ftrace: host klp and bpf trampoline together Song Liu
2022-07-20 0:21 ` [PATCH v5 bpf-next 1/4] ftrace: Add modify_ftrace_direct_multi_nolock Song Liu
2022-07-20 0:21 ` [PATCH v5 bpf-next 2/4] ftrace: Allow IPMODIFY and DIRECT ops on the same function Song Liu
2022-09-09 11:58 ` Naveen N. Rao
2022-09-09 14:05 ` Song Liu [this message]
2022-09-09 18:13 ` Naveen N. Rao
2022-07-20 0:21 ` [PATCH v5 bpf-next 3/4] bpf, x64: Allow to use caller address from stack Song Liu
2022-07-20 0:21 ` [PATCH v5 bpf-next 4/4] bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch) Song Liu
2022-07-22 7:31 ` Jiri Olsa
2022-07-22 15:58 ` Song Liu
2022-07-21 22:59 ` [PATCH v5 bpf-next 0/4] ftrace: host klp and bpf trampoline together Song Liu
2022-07-22 16:56 ` Steven Rostedt
2022-07-22 18:02 ` Song Liu
2022-07-22 20:10 ` patchwork-bot+netdevbpf
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=B59F0FD0-FA3E-4A8B-B588-8F9AA8AC602A@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=rostedt@goodmis.org \
--cc=song@kernel.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
all inboxes | Powered by JetHome®