diff options
author | Marcin Nowakowski <marcin.nowakowski@imgtec.com> | 2016-12-09 15:19:37 +0100 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2016-12-12 21:17:44 -0500 |
commit | f18f97ac43d72ae84fe012dd4f19fe3f8f901469 (patch) | |
tree | 7cea3fde1b2fda1c37fc6026110666e16e204969 | |
parent | 99e6f6e8134b0c9d5d82eb2af1068a57199125e4 (diff) | |
download | linux-f18f97ac43d72ae84fe012dd4f19fe3f8f901469.tar.gz linux-f18f97ac43d72ae84fe012dd4f19fe3f8f901469.tar.bz2 linux-f18f97ac43d72ae84fe012dd4f19fe3f8f901469.zip |
tracing/kprobes: Add a helper method to return number of probe hits
The number of probe hits is stored in a percpu variable and therefore
can't be read directly. Add a helper method trace_kprobe_nhit() that
performs the required calculation.
It will be used in a follow-up commit that changes kprobe selftests to
verify the number of probe hits.
Link: http://lkml.kernel.org/r/1481293178-3128-1-git-send-email-marcin.nowakowski@imgtec.com
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace_kprobe.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index eb6c9f1d3a93..a2af1bceca29 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -73,6 +73,17 @@ static nokprobe_inline bool trace_kprobe_is_on_module(struct trace_kprobe *tk) return !!strchr(trace_kprobe_symbol(tk), ':'); } +static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk) +{ + unsigned long nhit = 0; + int cpu; + + for_each_possible_cpu(cpu) + nhit += *per_cpu_ptr(tk->nhit, cpu); + + return nhit; +} + static int register_kprobe_event(struct trace_kprobe *tk); static int unregister_kprobe_event(struct trace_kprobe *tk); @@ -882,14 +893,10 @@ static const struct file_operations kprobe_events_ops = { static int probes_profile_seq_show(struct seq_file *m, void *v) { struct trace_kprobe *tk = v; - unsigned long nhit = 0; - int cpu; - - for_each_possible_cpu(cpu) - nhit += *per_cpu_ptr(tk->nhit, cpu); seq_printf(m, " %-44s %15lu %15lu\n", - trace_event_name(&tk->tp.call), nhit, + trace_event_name(&tk->tp.call), + trace_kprobe_nhit(tk), tk->rp.kp.nmissed); return 0; |