mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 09:09:06 +08:00
bpf: add bpf_ktime_get_boot_ns()
On a device like a cellphone which is constantly suspending and resuming CLOCK_MONOTONIC is not particularly useful for keeping track of or reacting to external network events. Instead you want to use CLOCK_BOOTTIME. Hence add bpf_ktime_get_boot_ns() as a mirror of bpf_ktime_get_ns() based around CLOCK_BOOTTIME instead of CLOCK_MONOTONIC. Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Andrii Nakryiko
parent
ba344d9494
commit
625f64a126
@@ -652,6 +652,8 @@ union bpf_attr {
|
|||||||
* u64 bpf_ktime_get_ns(void)
|
* u64 bpf_ktime_get_ns(void)
|
||||||
* Description
|
* Description
|
||||||
* Return the time elapsed since system boot, in nanoseconds.
|
* Return the time elapsed since system boot, in nanoseconds.
|
||||||
|
* Does not include time the system was suspended.
|
||||||
|
* See: clock_gettime(CLOCK_MONOTONIC)
|
||||||
* Return
|
* Return
|
||||||
* Current *ktime*.
|
* Current *ktime*.
|
||||||
*
|
*
|
||||||
@@ -3025,6 +3027,14 @@ union bpf_attr {
|
|||||||
* * **-EOPNOTSUPP** Unsupported operation, for example a
|
* * **-EOPNOTSUPP** Unsupported operation, for example a
|
||||||
* call from outside of TC ingress.
|
* call from outside of TC ingress.
|
||||||
* * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport).
|
* * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport).
|
||||||
|
*
|
||||||
|
* u64 bpf_ktime_get_boot_ns(void)
|
||||||
|
* Description
|
||||||
|
* Return the time elapsed since system boot, in nanoseconds.
|
||||||
|
* Does include the time the system was suspended.
|
||||||
|
* See: clock_gettime(CLOCK_BOOTTIME)
|
||||||
|
* Return
|
||||||
|
* Current *ktime*.
|
||||||
*/
|
*/
|
||||||
#define __BPF_FUNC_MAPPER(FN) \
|
#define __BPF_FUNC_MAPPER(FN) \
|
||||||
FN(unspec), \
|
FN(unspec), \
|
||||||
@@ -3151,7 +3161,8 @@ union bpf_attr {
|
|||||||
FN(xdp_output), \
|
FN(xdp_output), \
|
||||||
FN(get_netns_cookie), \
|
FN(get_netns_cookie), \
|
||||||
FN(get_current_ancestor_cgroup_id), \
|
FN(get_current_ancestor_cgroup_id), \
|
||||||
FN(sk_assign),
|
FN(sk_assign), \
|
||||||
|
FN(ktime_get_boot_ns),
|
||||||
|
|
||||||
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
||||||
* function eBPF program intends to call
|
* function eBPF program intends to call
|
||||||
|
|||||||
Reference in New Issue
Block a user