Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: bpftool: improve accuracy of load time

BPF program load time is reported from the kernel relative to boot time.
If conversion to wall clock does not take nanosecond parts into account,
the load time reported by bpftool may differ by one second from run to
run. This means JSON object reported by bpftool for a program will
randomly change.

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Jakub Kicinski and committed by
Daniel Borkmann
07480cbc 3bce593a

+3 -1
+3 -1
tools/bpf/bpftool/prog.c
··· 90 90 } 91 91 92 92 wallclock_secs = (real_time_ts.tv_sec - boot_time_ts.tv_sec) + 93 - nsecs / 1000000000; 93 + (real_time_ts.tv_nsec - boot_time_ts.tv_nsec + nsecs) / 94 + 1000000000; 95 + 94 96 95 97 if (!localtime_r(&wallclock_secs, &load_tm)) { 96 98 snprintf(buf, size, "%llu", nsecs / 1000000000);