aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2015-03-25 15:49:21 -0400
committerIngo Molnar <mingo@kernel.org>2015-04-02 07:25:49 -0400
commitd9847d310ab4003725e6ed1822682e24bd406908 (patch)
treeab9935a7f11122988f9eba0290f04ffe572b44ac /kernel/trace
parent2541517c32be2531e0da59dfd7efc1ce844644f5 (diff)
tracing: Allow BPF programs to call bpf_ktime_get_ns()
bpf_ktime_get_ns() is used by programs to compute time delta between events or as a timestamp Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: David S. Miller <davem@davemloft.net> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1427312966-8434-5-git-send-email-ast@plumgrid.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/bpf_trace.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index f1e87da91da3..8f5787294971 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -78,6 +78,18 @@ static const struct bpf_func_proto bpf_probe_read_proto = {
78 .arg3_type = ARG_ANYTHING, 78 .arg3_type = ARG_ANYTHING,
79}; 79};
80 80
81static u64 bpf_ktime_get_ns(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
82{
83 /* NMI safe access to clock monotonic */
84 return ktime_get_mono_fast_ns();
85}
86
87static const struct bpf_func_proto bpf_ktime_get_ns_proto = {
88 .func = bpf_ktime_get_ns,
89 .gpl_only = true,
90 .ret_type = RET_INTEGER,
91};
92
81static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func_id) 93static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func_id)
82{ 94{
83 switch (func_id) { 95 switch (func_id) {
@@ -89,6 +101,8 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func
89 return &bpf_map_delete_elem_proto; 101 return &bpf_map_delete_elem_proto;
90 case BPF_FUNC_probe_read: 102 case BPF_FUNC_probe_read:
91 return &bpf_probe_read_proto; 103 return &bpf_probe_read_proto;
104 case BPF_FUNC_ktime_get_ns:
105 return &bpf_ktime_get_ns_proto;
92 default: 106 default:
93 return NULL; 107 return NULL;
94 } 108 }