From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Mark Rutland <mark.rutland@arm.com>,
lkml <linux-kernel@vger.kernel.org>,
linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH] fprobe: Ensure running fprobe_exit_handler() finished before calling rethook_free()
Date: Fri, 7 Jul 2023 09:17:12 +0900 [thread overview]
Message-ID: <20230707091712.e478e0b6e8f5c1ab0802a510@kernel.org> (raw)
In-Reply-To: <20230706095624.3a846b8e@gandalf.local.home>
On Thu, 6 Jul 2023 09:56:24 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 6 Jul 2023 14:10:12 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
>
> > With only Jiri's patch, following flow can happen;
> >
> > ------
> > CPU1 CPU2
> > call unregister_fprobe()
> > ...
> > __fprobe_handler()
> > rethook_hook() on probed function
> > unregister_ftrace_function()
> > return from probed function
> > rethook hooks
> > find rh->handler == fprobe_exit_handler
> > call fprobe_exit_handler()
> > rethook_free():
> > set rh->handler = NULL;
> > return from unreigster_fprobe;
> > call fp->exit_handler() <- (*)
> >
> > (*) In this point, the exit handler is called after returning from
> > unregister_fprobe().
> > ------
> >
> > So, this patch changes it as following;
> > ------
> > CPU1 CPU2
> > call unregister_fprobe()
> > ...
> > rethook_stop():
> > set rh->handler = NULL;
> > __fprobe_handler()
> > rethook_hook() on probed function
> > unregister_ftrace_function()
> > return from probed function
> > rethook hooks
> > find rh->handler == NULL
> > return from rethook
> > rethook_free()
> > return from unreigster_fprobe;
> > ------
> >
> > I can also just put a synchronize_sched_rcu() right after rethook_free()
> > to wait for all running fprobe_exit_handler() too.
> >
>
> This makes more sense. Can you please add the above to the change log.
OK, let me update it.
Thanks!
>
> Thanks,
>
> -- Steve
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2023-07-07 0:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 11:52 [PATCH] fprobe: Release rethook after the ftrace_ops is unregistered Jiri Olsa
2023-06-15 12:59 ` Steven Rostedt
2023-06-23 11:11 ` Jiri Olsa
2023-06-27 14:33 ` Masami Hiramatsu
2023-06-27 16:23 ` Masami Hiramatsu
2023-06-28 14:44 ` [PATCH] fprobe: Ensure running fprobe_exit_handler() finished before calling rethook_free() Masami Hiramatsu (Google)
2023-07-05 23:59 ` Masami Hiramatsu
2023-07-06 1:26 ` Steven Rostedt
2023-07-06 5:10 ` Masami Hiramatsu
2023-07-06 13:56 ` Steven Rostedt
2023-07-07 0:17 ` 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=20230707091712.e478e0b6e8f5c1ab0802a510@kernel.org \
--to=mhiramat@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rostedt@goodmis.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).