* [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe()
@ 2018-07-26 16:11 Steven Rostedt
2018-07-26 16:43 ` Josh Poimboeuf
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2018-07-26 16:11 UTC (permalink / raw)
To: LKML; +Cc: Masami Hiramatsu, Josh Poimboeuf, Artem Savkov
[ Note this is applied on top of the other patch to quiet gcc ]
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
The function enable_trace_kprobe() performs slightly differently if the file
parameter is passed in as NULL on non-NULL. Instead of checking file twice,
move the code between the two tests into a static inline helper function to
make the code easier to follow.
Link: http://lkml.kernel.org/r/20180725224728.7b1d5db2@vmware.local.home
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 6b71860f3998..1dec0855a59a 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -393,6 +393,20 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
return NULL;
}
+static inline int enable_probe(struct trace_kprobe *tk)
+{
+ int ret = 0;
+
+ if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
+ if (trace_kprobe_is_return(tk))
+ ret = enable_kretprobe(&tk->rp);
+ else
+ ret = enable_kprobe(&tk->rp.kp);
+ }
+
+ return ret;
+}
+
/*
* Enable trace_probe
* if the file is NULL, enable "perf" handler, or enable "trace" handler.
@@ -400,7 +414,7 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
static int
enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
{
- struct event_file_link *link = NULL;
+ struct event_file_link *link;
int ret = 0;
if (file) {
@@ -414,26 +428,18 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
list_add_tail_rcu(&link->list, &tk->tp.files);
tk->tp.flags |= TP_FLAG_TRACE;
- } else
- tk->tp.flags |= TP_FLAG_PROFILE;
-
- if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
- if (trace_kprobe_is_return(tk))
- ret = enable_kretprobe(&tk->rp);
- else
- ret = enable_kprobe(&tk->rp.kp);
- }
-
- if (ret) {
- if (file) {
- /* Notice the if is true on not WARN() */
- if (!WARN_ON_ONCE(!link))
- list_del_rcu(&link->list);
+ ret = enable_probe(tk);
+ if (ret) {
+ list_del_rcu(&link->list);
kfree(link);
tk->tp.flags &= ~TP_FLAG_TRACE;
- } else {
- tk->tp.flags &= ~TP_FLAG_PROFILE;
}
+
+ } else {
+ tk->tp.flags |= TP_FLAG_PROFILE;
+ ret = enable_probe(tk);
+ if (ret)
+ tk->tp.flags &= ~TP_FLAG_PROFILE;
}
out:
return ret;
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe()
2018-07-26 16:11 [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe() Steven Rostedt
@ 2018-07-26 16:43 ` Josh Poimboeuf
2018-07-26 18:25 ` Steven Rostedt
2018-07-27 12:52 ` Masami Hiramatsu
0 siblings, 2 replies; 5+ messages in thread
From: Josh Poimboeuf @ 2018-07-26 16:43 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, Masami Hiramatsu, Artem Savkov
On Thu, Jul 26, 2018 at 12:11:52PM -0400, Steven Rostedt wrote:
>
> [ Note this is applied on top of the other patch to quiet gcc ]
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> The function enable_trace_kprobe() performs slightly differently if the file
> parameter is passed in as NULL on non-NULL. Instead of checking file twice,
> move the code between the two tests into a static inline helper function to
> make the code easier to follow.
>
> Link: http://lkml.kernel.org/r/20180725224728.7b1d5db2@vmware.local.home
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
The enable_probe() name is a bit confusing, since it's not clear what
the difference is between enable_probe() and enable_trace_kprobe()
without looking at the code.
Maybe call it __enable_trace_kprobe()?
Otherwise it's a definite improvement.
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
--
Josh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe()
2018-07-26 16:43 ` Josh Poimboeuf
@ 2018-07-26 18:25 ` Steven Rostedt
2018-07-27 12:52 ` Masami Hiramatsu
1 sibling, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2018-07-26 18:25 UTC (permalink / raw)
To: Josh Poimboeuf; +Cc: LKML, Masami Hiramatsu, Artem Savkov
On Thu, 26 Jul 2018 11:43:52 -0500
Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Thu, Jul 26, 2018 at 12:11:52PM -0400, Steven Rostedt wrote:
> >
> > [ Note this is applied on top of the other patch to quiet gcc ]
> >
> > From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> >
> > The function enable_trace_kprobe() performs slightly differently if the file
> > parameter is passed in as NULL on non-NULL. Instead of checking file twice,
> > move the code between the two tests into a static inline helper function to
> > make the code easier to follow.
> >
> > Link: http://lkml.kernel.org/r/20180725224728.7b1d5db2@vmware.local.home
> >
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> The enable_probe() name is a bit confusing, since it's not clear what
> the difference is between enable_probe() and enable_trace_kprobe()
> without looking at the code.
Yeah, I didn't like that name either.
>
> Maybe call it __enable_trace_kprobe()?
Hmm, that may work.
>
> Otherwise it's a definite improvement.
>
> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
>
Thanks,
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe()
2018-07-26 16:43 ` Josh Poimboeuf
2018-07-26 18:25 ` Steven Rostedt
@ 2018-07-27 12:52 ` Masami Hiramatsu
2018-07-27 13:38 ` [PATCH v2] " Steven Rostedt
1 sibling, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2018-07-27 12:52 UTC (permalink / raw)
To: Josh Poimboeuf; +Cc: Steven Rostedt, LKML, Masami Hiramatsu, Artem Savkov
On Thu, 26 Jul 2018 11:43:52 -0500
Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Thu, Jul 26, 2018 at 12:11:52PM -0400, Steven Rostedt wrote:
> >
> > [ Note this is applied on top of the other patch to quiet gcc ]
> >
> > From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> >
> > The function enable_trace_kprobe() performs slightly differently if the file
> > parameter is passed in as NULL on non-NULL. Instead of checking file twice,
> > move the code between the two tests into a static inline helper function to
> > make the code easier to follow.
> >
> > Link: http://lkml.kernel.org/r/20180725224728.7b1d5db2@vmware.local.home
> >
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> The enable_probe() name is a bit confusing, since it's not clear what
> the difference is between enable_probe() and enable_trace_kprobe()
> without looking at the code.
>
> Maybe call it __enable_trace_kprobe()?
+1, I this this is better.
With that function name change,
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thanks!
>
> Otherwise it's a definite improvement.
>
> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
>
> --
> Josh
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] tracing/kprobes: Simplify the logic of enable_trace_kprobe()
2018-07-27 12:52 ` Masami Hiramatsu
@ 2018-07-27 13:38 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2018-07-27 13:38 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Josh Poimboeuf, LKML, Artem Savkov
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
The function enable_trace_kprobe() performs slightly differently if the file
parameter is passed in as NULL on non-NULL. Instead of checking file twice,
move the code between the two tests into a static inline helper function to
make the code easier to follow.
Link: http://lkml.kernel.org/r/20180725224728.7b1d5db2@vmware.local.home
Link: http://lkml.kernel.org/r/20180726121152.4dd54330@gandalf.local.home
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 6b71860f3998..0534eb8b7640 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -393,6 +393,20 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
return NULL;
}
+static inline int __enable_trace_kprobe(struct trace_kprobe *tk)
+{
+ int ret = 0;
+
+ if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
+ if (trace_kprobe_is_return(tk))
+ ret = enable_kretprobe(&tk->rp);
+ else
+ ret = enable_kprobe(&tk->rp.kp);
+ }
+
+ return ret;
+}
+
/*
* Enable trace_probe
* if the file is NULL, enable "perf" handler, or enable "trace" handler.
@@ -400,7 +414,7 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
static int
enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
{
- struct event_file_link *link = NULL;
+ struct event_file_link *link;
int ret = 0;
if (file) {
@@ -414,26 +428,18 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
list_add_tail_rcu(&link->list, &tk->tp.files);
tk->tp.flags |= TP_FLAG_TRACE;
- } else
- tk->tp.flags |= TP_FLAG_PROFILE;
-
- if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
- if (trace_kprobe_is_return(tk))
- ret = enable_kretprobe(&tk->rp);
- else
- ret = enable_kprobe(&tk->rp.kp);
- }
-
- if (ret) {
- if (file) {
- /* Notice the if is true on not WARN() */
- if (!WARN_ON_ONCE(!link))
- list_del_rcu(&link->list);
+ ret = __enable_trace_kprobe(tk);
+ if (ret) {
+ list_del_rcu(&link->list);
kfree(link);
tk->tp.flags &= ~TP_FLAG_TRACE;
- } else {
- tk->tp.flags &= ~TP_FLAG_PROFILE;
}
+
+ } else {
+ tk->tp.flags |= TP_FLAG_PROFILE;
+ ret = __enable_trace_kprobe(tk);
+ if (ret)
+ tk->tp.flags &= ~TP_FLAG_PROFILE;
}
out:
return ret;
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-27 13:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 16:11 [PATCH] tracing/kprobes: Simplify the logic of enable_trace_kprobe() Steven Rostedt
2018-07-26 16:43 ` Josh Poimboeuf
2018-07-26 18:25 ` Steven Rostedt
2018-07-27 12:52 ` Masami Hiramatsu
2018-07-27 13:38 ` [PATCH v2] " Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.