From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ze Gao <zegao2021@gmail.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Ze Gao <zegao@tencent.com>, Yafang <laoar.shao@gmail.com>
Subject: Re: [PATCH v2] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock
Date: Fri, 7 Jul 2023 09:15:13 +0900 [thread overview]
Message-ID: <20230707091513.b0bbdf38dd276e054e293185@kernel.org> (raw)
In-Reply-To: <20230706120916.3c6abf15@gandalf.local.home>
On Thu, 6 Jul 2023 12:09:16 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 3 Jul 2023 17:23:36 +0800
> Ze Gao <zegao2021@gmail.com> wrote:
>
> > Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed
> > because of some running kprobe.
> >
> > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free")
> > Reported-by: Yafang <laoar.shao@gmail.com>
> > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/
> > Signed-off-by: Ze Gao <zegao@tencent.com>
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> > ---
> > kernel/trace/fprobe.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> > index 18d36842faf5..93b3e361bb97 100644
> > --- a/kernel/trace/fprobe.c
> > +++ b/kernel/trace/fprobe.c
> > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip,
> >
> > if (unlikely(kprobe_running())) {
>
> Off topic for this patch, but Masami, what's the purpose of not calling the
> fprobe when a kprobe is running? Does that mean it has probed another kprobe?
This is for the user who is sharing their handler with kprobes (like eBPF),
which may expect that the handler is not called recursively. (e.g. an interrupt
happens while kprobe handler is running and that interrupt calls a function
which is fprobed)
>
> Probably could add a comment here to explain the issue.
OK, it is also documented in Documentation/trace/fprobe.rst, but it is better
to comment in the code too.
Thanks,
>
> -- Steve
>
>
> > fp->nmissed++;
> > - return;
> > + goto recursion_unlock;
> > }
> >
> > kprobe_busy_begin();
> > __fprobe_handler(ip, parent_ip, ops, fregs);
> > kprobe_busy_end();
> > +
> > +recursion_unlock:
> > ftrace_test_recursion_unlock(bit);
> > }
> >
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2023-07-07 0:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 9:23 [PATCH v2] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock Ze Gao
2023-07-03 10:01 ` Masami Hiramatsu
2023-07-03 13:44 ` Yafang Shao
2023-07-06 16:09 ` Steven Rostedt
2023-07-07 0:15 ` Masami Hiramatsu [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=20230707091513.b0bbdf38dd276e054e293185@kernel.org \
--to=mhiramat@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=zegao2021@gmail.com \
--cc=zegao@tencent.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