From: Steven Rostedt <rostedt@goodmis.org>
To: Song Liu <songliubraving@fb.com>
Cc: Song Liu <song@kernel.org>, Networking <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>, lkml <linux-kernel@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Kernel Team <Kernel-team@fb.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"mhiramat@kernel.org" <mhiramat@kernel.org>
Subject: Re: [PATCH v2 bpf-next 3/5] ftrace: introduce FTRACE_OPS_FL_SHARE_IPMODIFY
Date: Thu, 14 Jul 2022 20:48:17 -0400 [thread overview]
Message-ID: <20220714204817.2889e280@rorschach.local.home> (raw)
In-Reply-To: <AA1D9833-DF67-4AFD-815C-DD89AB57B3A2@fb.com>
On Fri, 15 Jul 2022 00:13:51 +0000
Song Liu <songliubraving@fb.com> wrote:
> I think there is one more problem here. If we force all direct trampoline
> set IPMODIFY, and remove the SHARE_IPMODIFY flag. It may cause confusion
> and/or extra work here (__ftrace_hash_update_ipmodify).
I'm saying that the caller (BPF) does not need to set IPMODIFY. Just
change the ftrace.c to treat IPMODIFY the same as direct. In fact, the
two should be mutually exclusive (from a ftrace point of view). That
is, if DIRECT is set, then IPMODIFY must not be.
Again, ftrace will take care of the accounting of if a rec has both
IPMODIFY and DIRECT on it.
>
> Say __ftrace_hash_update_ipmodify() tries to attach an ops with IPMODIFY,
> and found the rec already has IPMODIFY. At this point, we have to iterate
> all ftrace ops (do_for_each_ftrace_op) to confirm whether the IPMODIFY is
> from
What I'm suggesting is that a DIRECT ops will never set IPMODIFY. Like
I mentioned before, ftrace doesn't care if the direct trampoline
modifies IP or not. All ftrace will do is ask the owner of the direct
ops if it is safe to have an IP modify attached to it or not. And at
the same time will tell the direct ops owner that it is adding an
IPMODIFY ops such that it can take the appropriate actions.
In other words, IPMODIFY on the rec means that it can not attach
anything else with an IPMODIFY on it.
The direct ops should only set the DIRECT flag. If an IPMODIFY ops is
being added, if it already has an IPMODIFY then it will fail right there.
If direct is set, then a loop for the direct ops will be done and the
callback is made. If the direct ops is OK with the IPMODIFY then it
will adjust itself to work with the IPMODIFY and the IPMODIFY will
continue to be added (and then set the rec IPMODIFY flag).
>
> 1) a direct ops that can share IPMODIFY, or
> 2) a direct ops that cannot share IPMODIFY, or
> 3) another non-direct ops with IPMODIFY.
>
> For the 1), this attach works, while for 2) and 3), the attach doesn't work.
>
> OTOH, with current version (v2), we trust the direct ops to set or clear
> IPMODIFY. rec with IPMODIFY makes it clear that it cannot share with another
> ops with IPMODIFY. Then we don't have to iterate over all ftrace ops here.
The only time an iterate should be done is if rec->flags is DIRECT and !IPMODIFY.
>
> Does this make sense? Did I miss some better solutions?
Did I fill in the holes? ;-)
-- Steve
next prev parent reply other threads:[~2022-07-15 0:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220602193706.2607681-1-song@kernel.org>
2022-06-06 22:57 ` [PATCH v2 bpf-next 0/5] ftrace: host klp and bpf trampoline together Song Liu
[not found] ` <20220602193706.2607681-6-song@kernel.org>
2022-07-06 19:38 ` [PATCH v2 bpf-next 5/5] bpf: trampoline: support FTRACE_OPS_FL_SHARE_IPMODIFY Steven Rostedt
2022-07-06 21:37 ` Song Liu
2022-07-06 21:40 ` Steven Rostedt
2022-07-06 21:50 ` Song Liu
2022-07-06 22:15 ` Song Liu
2022-07-06 22:29 ` Steven Rostedt
2022-07-07 0:19 ` Song Liu
2022-07-07 1:18 ` Steven Rostedt
2022-07-07 2:11 ` Song Liu
2022-07-11 23:55 ` [PATCH v2 bpf-next 0/5] ftrace: host klp and bpf trampoline together Steven Rostedt
2022-07-12 5:15 ` Song Liu
2022-07-12 13:36 ` Steven Rostedt
[not found] ` <20220602193706.2607681-2-song@kernel.org>
2022-07-13 23:18 ` [PATCH v2 bpf-next 1/5] ftrace: allow customized flags for ftrace_direct_multi ftrace_ops Steven Rostedt
2022-07-14 0:11 ` Song Liu
2022-07-14 0:38 ` Steven Rostedt
2022-07-14 1:42 ` Song Liu
2022-07-14 2:55 ` Steven Rostedt
2022-07-14 4:37 ` Song Liu
2022-07-14 13:22 ` Steven Rostedt
[not found] ` <20220602193706.2607681-4-song@kernel.org>
2022-06-06 8:20 ` [PATCH v2 bpf-next 3/5] ftrace: introduce FTRACE_OPS_FL_SHARE_IPMODIFY Jiri Olsa
2022-06-06 15:35 ` Song Liu
2022-07-14 0:33 ` Steven Rostedt
2022-07-15 0:13 ` Song Liu
2022-07-15 0:48 ` Steven Rostedt [this message]
2022-07-15 2:04 ` Song Liu
2022-07-15 2:46 ` Steven Rostedt
2022-07-15 2:50 ` Song Liu
2022-07-15 17:42 ` Song Liu
2022-07-15 19:12 ` Steven Rostedt
2022-07-15 19:49 ` Song Liu
2022-07-15 19:59 ` Steven Rostedt
2022-07-15 20:21 ` Song Liu
2022-07-15 21:29 ` Steven Rostedt
2022-07-15 21:48 ` Song Liu
2022-07-15 21:50 ` Steven Rostedt
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=20220714204817.2889e280@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=Kernel-team@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=songliubraving@fb.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).