tracing/kprobes: 'nmissed' not showed correctly for kretprobe
PATCH 1/1 tracing/kprobes: 'nmissed' not showed correctly for kretprobe
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'
--- kernel/trace/trace_kprobe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_kprobe.c +3 -1
@@ -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 ; }
Signature · 1 line
2.25.1
Steven Rostedt
maintainerQuoted 15 lines · On Sat, 11 Dec 2021 23:00:32 +0800 Xiangyang Zhang <[email protected]> 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 <[email protected]>--- kernel/trace/trace_kprobe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/trace/trace_kprobe.c +0
-0
kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1178
Quoted 4 lines
kernel/trace/trace_kprobe.c +1
-0@@ -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.
kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1188
Quoted 11 lines
kernel/trace/trace_kprobe.c +2
-1if (!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
Quoted 3 lines
kernel/trace/trace_kprobe.c +0
-0return 0 ; }
Steven Rostedt
maintainerResending again, this time with Masami's working email address.
Quoted 45 lines · On Wed, 5 Jan 2022 14:15:56 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 15 lines · On Sat, 11 Dec 2021 23:00:32 +0800 Xiangyang Zhang <[email protected]> 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 <[email protected]>--- kernel/trace/trace_kprobe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/trace/trace_kprobe.c +0
-0kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1178
Quoted 4 lines
kernel/trace/trace_kprobe.c +1
-0@@ -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.
kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1188
Quoted 11 lines
kernel/trace/trace_kprobe.c +2
-1if (!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
Quoted 3 lines
kernel/trace/trace_kprobe.c +0
-0return 0 ; }
Masami Hiramatsu
maintainerQuoted 43 lines · On Wed, 5 Jan 2022 14:22:08 -0500 Steven Rostedt <[email protected]> wrote:
Resending again, this time with Masami's working email address.
Quoted 38 lines · On Wed, 5 Jan 2022 14:15:56 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 15 lines · On Sat, 11 Dec 2021 23:00:32 +0800 Xiangyang Zhang <[email protected]> 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 <[email protected]>--- kernel/trace/trace_kprobe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/trace/trace_kprobe.c +0
-0kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1178
Quoted 4 lines
kernel/trace/trace_kprobe.c +1
-0@@ -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.
kernel/trace/trace_kprobe.c static int probes_profile_seq_show(struct seq_file *m, void *v) · line 1188
Quoted 11 lines
kernel/trace/trace_kprobe.c +2
-1if (!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,
Quoted 8 lines
Quoted 7 lines
-- Steve
Quoted 3 lines
kernel/trace/trace_kprobe.c +0
-0return 0 ; }
Signature · 1 line
Masami Hiramatsu <[email protected]>
Steven Rostedt
maintainerQuoted 7 lines · On Thu, 6 Jan 2022 07:32:03 +0900 Masami Hiramatsu <[email protected]> wrote:
OK, this is a good catch :), but there are 2 issues.
1. kretprobe can be skipped by 2 reasons, shortage of
kretprobe_instancewhich 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'.
Quoted 5 lines
2. the commit
c31ffb3ff633is not actual commit which introduce this issue. this was introduced by4a846b443b4e("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
ok, I will send a v2 patch later
Quoted 22 lines · Steven Rostedt
Quoted 7 lines · On Thu, 6 Jan 2022 07:32:03 +0900 Masami Hiramatsu <[email protected]> wrote:
OK, this is a good catch :), but there are 2 issues.
1. kretprobe can be skipped by 2 reasons, shortage of
kretprobe_instancewhich 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'.Quoted 5 lines
2. the commit
c31ffb3ff633is not actual commit which introduce this issue. this was introduced by4a846b443b4e("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