bpf: Add bpf_ktime_get_coarse_ns helper
The helper uses CLOCK_MONOTONIC_COARSE source of time that is less accurate but more performant. We have a BPF CGROUP_SKB firewall that supports event logging through bpf_perf_event_output(). Each event has a timestamp and currently we use bpf_ktime_get_ns() for it. Use of bpf_ktime_get_coarse_ns() saves ~15-20 ns in time required for event logging. bpf_ktime_get_ns(): EgressLogByRemoteEndpoint 113.82ns 8.79M bpf_ktime_get_coarse_ns(): EgressLogByRemoteEndpoint 95.40ns 10.48M Signed-off-by:Dmitrii Banshchikov <me@ubique.spb.ru> Signed-off-by:
Daniel Borkmann <daniel@iogearbox.net> Acked-by:
Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20201117184549.257280-1-me@ubique.spb.ru
Showing
- include/linux/bpf.h 1 addition, 0 deletionsinclude/linux/bpf.h
- include/uapi/linux/bpf.h 11 additions, 0 deletionsinclude/uapi/linux/bpf.h
- kernel/bpf/core.c 1 addition, 0 deletionskernel/bpf/core.c
- kernel/bpf/helpers.c 13 additions, 0 deletionskernel/bpf/helpers.c
- kernel/trace/bpf_trace.c 2 additions, 0 deletionskernel/trace/bpf_trace.c
- tools/include/uapi/linux/bpf.h 11 additions, 0 deletionstools/include/uapi/linux/bpf.h
Loading
Please register or sign in to comment