* [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe
@ 2021-12-11 15:00 Xiangyang Zhang
2022-01-05 19:15 ` Steven Rostedt
0 siblings, 1 reply; 6+ messages in thread
From: Xiangyang Zhang @ 2021-12-11 15:00 UTC (permalink / raw)
To: rostedt, mingo
Cc: masami.hiramatsu.pt, oleg, namhyung.kim, linux-kernel, xyz.sun.ok
The 'nmissed' column of the 'kprobe_profile' file for kretprobe is
always zero, because 'nmissed' for kretprobe is maintained in
'tk->rp.nmissed' but not in 'tk->rp.kp.nmissed'
Fixes: c31ffb3ff633 ("tracing/kprobes: Factor out struct trace_probe")
Signed-off-by: Xiangyang Zhang <xyz.sun.ok@gmail.com>
---
kernel/trace/trace_kprobe.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index d10c01948e68..2b9de6826e94 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1175,15 +1175,17 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)
{
struct dyn_event *ev = v;
struct trace_kprobe *tk;
+ unsigned long nmissed = 0;
if (!is_trace_kprobe(ev))
return 0;
tk = to_trace_kprobe(ev);
+ nmissed = tk->rp.handler ? tk->rp.nmissed : tk->rp.kp.nmissed;
seq_printf(m, " %-44s %15lu %15lu\n",
trace_probe_name(&tk->tp),
trace_kprobe_nhit(tk),
- tk->rp.kp.nmissed);
+ nmissed);
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe 2021-12-11 15:00 [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe Xiangyang Zhang @ 2022-01-05 19:15 ` Steven Rostedt 2022-01-05 19:22 ` Steven Rostedt 0 siblings, 1 reply; 6+ messages in thread From: Steven Rostedt @ 2022-01-05 19:15 UTC (permalink / raw) To: Xiangyang Zhang Cc: mingo, masami.hiramatsu.pt, oleg, namhyung.kim, linux-kernel On Sat, 11 Dec 2021 23:00:32 +0800 Xiangyang Zhang <xyz.sun.ok@gmail.com> wrote: > The 'nmissed' column of the 'kprobe_profile' file for kretprobe is > always zero, because 'nmissed' for kretprobe is maintained in > 'tk->rp.nmissed' but not in 'tk->rp.kp.nmissed' > > Fixes: c31ffb3ff633 ("tracing/kprobes: Factor out struct trace_probe") > Signed-off-by: Xiangyang Zhang <xyz.sun.ok@gmail.com> > --- > kernel/trace/trace_kprobe.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c > index d10c01948e68..2b9de6826e94 100644 > --- a/kernel/trace/trace_kprobe.c > +++ b/kernel/trace/trace_kprobe.c > @@ -1175,15 +1175,17 @@ static int probes_profile_seq_show(struct seq_file *m, void *v) > { > struct dyn_event *ev = v; > struct trace_kprobe *tk; > + unsigned long nmissed = 0; No need to initialize this to zero, the first use is an assignment. > > if (!is_trace_kprobe(ev)) > return 0; > > tk = to_trace_kprobe(ev); > + nmissed = tk->rp.handler ? tk->rp.nmissed : tk->rp.kp.nmissed; > seq_printf(m, " %-44s %15lu %15lu\n", > trace_probe_name(&tk->tp), > trace_kprobe_nhit(tk), > - tk->rp.kp.nmissed); > + nmissed); Masami, what's your thoughts on this patch? -- Steve > > return 0; > } ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe 2022-01-05 19:15 ` Steven Rostedt @ 2022-01-05 19:22 ` Steven Rostedt 2022-01-05 22:32 ` Masami Hiramatsu 0 siblings, 1 reply; 6+ messages in thread From: Steven Rostedt @ 2022-01-05 19:22 UTC (permalink / raw) To: Xiangyang Zhang; +Cc: mingo, Masami Hiramatsu, oleg, namhyung.kim, linux-kernel Resending again, this time with Masami's working email address. On Wed, 5 Jan 2022 14:15:56 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > On Sat, 11 Dec 2021 23:00:32 +0800 > Xiangyang Zhang <xyz.sun.ok@gmail.com> wrote: > > > The 'nmissed' column of the 'kprobe_profile' file for kretprobe is > > always zero, because 'nmissed' for kretprobe is maintained in > > 'tk->rp.nmissed' but not in 'tk->rp.kp.nmissed' > > > > Fixes: c31ffb3ff633 ("tracing/kprobes: Factor out struct trace_probe") > > Signed-off-by: Xiangyang Zhang <xyz.sun.ok@gmail.com> > > --- > > kernel/trace/trace_kprobe.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c > > index d10c01948e68..2b9de6826e94 100644 > > --- a/kernel/trace/trace_kprobe.c > > +++ b/kernel/trace/trace_kprobe.c > > @@ -1175,15 +1175,17 @@ static int probes_profile_seq_show(struct seq_file *m, void *v) > > { > > struct dyn_event *ev = v; > > struct trace_kprobe *tk; > > + unsigned long nmissed = 0; > > No need to initialize this to zero, the first use is an assignment. > > > > > if (!is_trace_kprobe(ev)) > > return 0; > > > > tk = to_trace_kprobe(ev); > > + nmissed = tk->rp.handler ? tk->rp.nmissed : tk->rp.kp.nmissed; > > seq_printf(m, " %-44s %15lu %15lu\n", > > trace_probe_name(&tk->tp), > > trace_kprobe_nhit(tk), > > - tk->rp.kp.nmissed); > > + nmissed); > > Masami, what's your thoughts on this patch? > > -- Steve > > > > > return 0; > > } > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe 2022-01-05 19:22 ` Steven Rostedt @ 2022-01-05 22:32 ` Masami Hiramatsu 2022-01-05 23:10 ` Steven Rostedt 0 siblings, 1 reply; 6+ messages in thread From: Masami Hiramatsu @ 2022-01-05 22:32 UTC (permalink / raw) To: Steven Rostedt Cc: Xiangyang Zhang, mingo, Masami Hiramatsu, oleg, namhyung.kim, linux-kernel On Wed, 5 Jan 2022 14:22:08 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > Resending again, this time with Masami's working email address. > > On Wed, 5 Jan 2022 14:15:56 -0500 > Steven Rostedt <rostedt@goodmis.org> wrote: > > > On Sat, 11 Dec 2021 23:00:32 +0800 > > Xiangyang Zhang <xyz.sun.ok@gmail.com> wrote: > > > > > The 'nmissed' column of the 'kprobe_profile' file for kretprobe is > > > always zero, because 'nmissed' for kretprobe is maintained in > > > 'tk->rp.nmissed' but not in 'tk->rp.kp.nmissed' > > > > > > Fixes: c31ffb3ff633 ("tracing/kprobes: Factor out struct trace_probe") > > > Signed-off-by: Xiangyang Zhang <xyz.sun.ok@gmail.com> > > > --- > > > kernel/trace/trace_kprobe.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c > > > index d10c01948e68..2b9de6826e94 100644 > > > --- a/kernel/trace/trace_kprobe.c > > > +++ b/kernel/trace/trace_kprobe.c > > > @@ -1175,15 +1175,17 @@ static int probes_profile_seq_show(struct seq_file *m, void *v) > > > { > > > struct dyn_event *ev = v; > > > struct trace_kprobe *tk; > > > + unsigned long nmissed = 0; > > > > No need to initialize this to zero, the first use is an assignment. > > > > > > > > if (!is_trace_kprobe(ev)) > > > return 0; > > > > > > tk = to_trace_kprobe(ev); > > > + nmissed = tk->rp.handler ? tk->rp.nmissed : tk->rp.kp.nmissed; > > > seq_printf(m, " %-44s %15lu %15lu\n", > > > trace_probe_name(&tk->tp), > > > trace_kprobe_nhit(tk), > > > - tk->rp.kp.nmissed); > > > + nmissed); > > > > Masami, what's your thoughts on this patch? OK, this is a good catch :), but there are 2 issues. 1. kretprobe can be skipped by 2 reasons, shortage of kretprobe_instance which is counted by rp.nmissed, and kprobe itself is missed by some reason (this can be happen if KPROBE_EVENTS_ON_NOTRACE=n. Thus, better solution is to show 'tk->rp.nmissed + tk->rp.kp.nmissed'. 2. the commit c31ffb3ff633 is not actual commit which introduce this issue. this was introduced by 4a846b443b4e ("tracing/kprobes: Cleanup kprobe tracer code.") 'git blame' tells you the commit which changes that line, but that can be just a refactoring (renaming). I recommend you to search the correct one by 'git log -p'. Thank you, > > > > -- Steve > > > > > > > > return 0; > > > } > > > -- Masami Hiramatsu <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe 2022-01-05 22:32 ` Masami Hiramatsu @ 2022-01-05 23:10 ` Steven Rostedt 2022-01-06 2:14 ` xy zhang 0 siblings, 1 reply; 6+ messages in thread From: Steven Rostedt @ 2022-01-05 23:10 UTC (permalink / raw) To: Masami Hiramatsu; +Cc: Xiangyang Zhang, mingo, oleg, namhyung.kim, linux-kernel On Thu, 6 Jan 2022 07:32:03 +0900 Masami Hiramatsu <mhiramat@kernel.org> wrote: > OK, this is a good catch :), but there are 2 issues. > > 1. kretprobe can be skipped by 2 reasons, shortage of kretprobe_instance which > is counted by rp.nmissed, and kprobe itself is missed by some reason (this > can be happen if KPROBE_EVENTS_ON_NOTRACE=n. Thus, better solution is to show > 'tk->rp.nmissed + tk->rp.kp.nmissed'. > > 2. the commit c31ffb3ff633 is not actual commit which introduce this issue. > this was introduced by 4a846b443b4e ("tracing/kprobes: Cleanup kprobe tracer code.") > > 'git blame' tells you the commit which changes that line, but that can be just > a refactoring (renaming). I recommend you to search the correct one by 'git log -p'. Masami, thanks for the review. Xiangyang, can you please send a v2 with Masami's suggestions? -- Steve ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe 2022-01-05 23:10 ` Steven Rostedt @ 2022-01-06 2:14 ` xy zhang 0 siblings, 0 replies; 6+ messages in thread From: xy zhang @ 2022-01-06 2:14 UTC (permalink / raw) To: Steven Rostedt; +Cc: Masami Hiramatsu, mingo, oleg, namhyung.kim, linux-kernel ok, I will send a v2 patch later On Thu, Jan 6, 2022 at 7:10 AM Steven Rostedt <rostedt@goodmis.org> wrote: > > On Thu, 6 Jan 2022 07:32:03 +0900 > Masami Hiramatsu <mhiramat@kernel.org> wrote: > > > OK, this is a good catch :), but there are 2 issues. > > > > 1. kretprobe can be skipped by 2 reasons, shortage of kretprobe_instance which > > is counted by rp.nmissed, and kprobe itself is missed by some reason (this > > can be happen if KPROBE_EVENTS_ON_NOTRACE=n. Thus, better solution is to show > > 'tk->rp.nmissed + tk->rp.kp.nmissed'. > > > > 2. the commit c31ffb3ff633 is not actual commit which introduce this issue. > > this was introduced by 4a846b443b4e ("tracing/kprobes: Cleanup kprobe tracer code.") > > > > 'git blame' tells you the commit which changes that line, but that can be just > > a refactoring (renaming). I recommend you to search the correct one by 'git log -p'. > > Masami, thanks for the review. > > Xiangyang, can you please send a v2 with Masami's suggestions? > > -- Steve ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-06 2:12 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-12-11 15:00 [PATCH] tracing/kprobes: 'nmissed' not showed correctly for kretprobe Xiangyang Zhang 2022-01-05 19:15 ` Steven Rostedt 2022-01-05 19:22 ` Steven Rostedt 2022-01-05 22:32 ` Masami Hiramatsu 2022-01-05 23:10 ` Steven Rostedt 2022-01-06 2:14 ` xy zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome