From: Peter Zijlstra <peterz@infradead.org>
To: Alexei Starovoitov <ast@plumgrid.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@infradead.org>,
Jiri Olsa <jolsa@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
"David S. Miller" <davem@davemloft.net>,
Daniel Borkmann <dborkman@redhat.com>,
linux-api@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 tip 3/7] tracing: allow BPF programs to call ktime_get_ns()
Date: Sat, 28 Feb 2015 11:20:43 +0100 [thread overview]
Message-ID: <20150228102043.GX5029@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1425082135-11967-4-git-send-email-ast@plumgrid.com>
On Fri, Feb 27, 2015 at 04:08:51PM -0800, Alexei Starovoitov wrote:
> bpf_ktime_get_ns() is used by programs to compue time delta between events
> or as a timestamp
>
> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
> ---
> include/uapi/linux/bpf.h | 1 +
> kernel/trace/bpf_trace.c | 10 ++++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 4486d36d2e9e..101e509d1001 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -165,6 +165,7 @@ enum bpf_func_id {
> BPF_FUNC_map_update_elem, /* int map_update_elem(&map, &key, &value, flags) */
> BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */
> BPF_FUNC_probe_read, /* int bpf_probe_read(void *dst, int size, void *src) */
> + BPF_FUNC_ktime_get_ns, /* u64 bpf_ktime_get_ns(void) */
> __BPF_FUNC_MAX_ID,
> };
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index bcce9b238dad..64b918488607 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -36,6 +36,11 @@ static u64 bpf_probe_read(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
> return probe_kernel_read(dst, unsafe_ptr, size);
> }
>
> +static u64 bpf_ktime_get_ns(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
> +{
> + return ktime_get_ns();
> +}
Please use ktime_get_mono_fast_ns() instead. If you ever want to allow
running BPF stuff from general tracepoints and the like you need to
be NMI safe.
next prev parent reply other threads:[~2015-02-28 10:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-28 0:08 [PATCH v4 tip 0/7] tracing: attach eBPF programs to kprobes Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 1/7] bpf: make internal bpf API independent of CONFIG_BPF_SYSCALL ifdefs Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 2/7] tracing: attach BPF programs to kprobes Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 3/7] tracing: allow BPF programs to call ktime_get_ns() Alexei Starovoitov
2015-02-28 10:20 ` Peter Zijlstra [this message]
2015-02-28 0:08 ` [PATCH v4 tip 4/7] tracing: allow BPF programs to call bpf_trace_printk() Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 5/7] samples: bpf: simple non-portable kprobe filter example Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 6/7] samples: bpf: counting example for kfree_skb and write syscall Alexei Starovoitov
2015-02-28 0:08 ` [PATCH v4 tip 7/7] samples: bpf: IO latency analysis (iosnoop/heatmap) Alexei Starovoitov
2015-02-28 0:25 ` [PATCH v4 tip 0/7] tracing: attach eBPF programs to kprobes Alexei Starovoitov
2015-02-28 17:21 [PATCH v4 tip 3/7] tracing: allow BPF programs to call ktime_get_ns() Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150228102043.GX5029@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@infradead.org \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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