OpenCloudOS-Kernel/tools/bpf/bpftool
Daniel Borkmann 0ee52c0f6c bpf, bpftool: Allow probing for CONFIG_HZ from kernel config
In Cilium we've recently switched to make use of bpf_jiffies64() for
parts of our tc and XDP datapath since bpf_ktime_get_ns() is more
expensive and high-precision is not needed for our timeouts we have
anyway. Our agent has a probe manager which picks up the json of
bpftool's feature probe and we also use the macro output in our C
programs e.g. to have workarounds when helpers are not available on
older kernels.

Extend the kernel config info dump to also include the kernel's
CONFIG_HZ, and rework the probe_kernel_image_config() for allowing a
macro dump such that CONFIG_HZ can be propagated to BPF C code as a
simple define if available via config. Latter allows to have _compile-
time_ resolution of jiffies <-> sec conversion in our code since all
are propagated as known constants.

Given we cannot generally assume availability of kconfig everywhere,
we also have a kernel hz probe [0] as a fallback. Potentially, bpftool
could have an integrated probe fallback as well, although to derive it,
we might need to place it under 'bpftool feature probe full' or similar
given it would slow down the probing process overall. Yet 'full' doesn't
fit either for us since we don't want to pollute the kernel log with
warning messages from bpf_probe_write_user() and bpf_trace_printk() on
agent startup; I've left it out for the time being.

  [0] https://github.com/cilium/cilium/blob/master/bpf/cilium-probe-kernel-hz.c

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200513075849.20868-1-daniel@iogearbox.net
2020-05-15 08:18:53 -07:00
..
Documentation tools, bpftool: Minor fixes for documentation 2020-05-11 21:20:50 +02:00
bash-completion tools/bpftool: Add bpf_iter support for bptool 2020-05-09 17:05:27 -07:00
skeleton bpftool: Use linux/types.h from source tree for profiler build 2020-03-12 16:22:41 +01:00
.gitignore SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
Makefile tools: bpftool: Make libcap dependency optional 2020-04-29 23:25:11 +02:00
btf.c tools/bpf/bpftool: Remove duplicate headers 2020-04-26 08:40:01 -07:00
btf_dumper.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
cfg.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
cfg.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00
cgroup.c bpftool: Expose attach_type-to-string array to non-cgroup code 2020-04-28 17:27:08 -07:00
common.c bpftool: Add bpf_link show and pin support 2020-04-28 17:27:08 -07:00
feature.c bpf, bpftool: Allow probing for CONFIG_HZ from kernel config 2020-05-15 08:18:53 -07:00
gen.c tools/bpf/bpftool: Remove duplicate headers 2020-04-26 08:40:01 -07:00
iter.c tools/bpftool: Add bpf_iter support for bptool 2020-05-09 17:05:27 -07:00
jit_disasm.c tools/bpf/bpftool: Remove duplicate headers 2020-04-26 08:40:01 -07:00
json_writer.c tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
json_writer.h tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
link.c tools/bpftool: Add bpf_iter support for bptool 2020-05-09 17:05:27 -07:00
main.c tools/bpftool: Add bpf_iter support for bptool 2020-05-09 17:05:27 -07:00
main.h tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
map.c tools, bpftool: Minor fixes for documentation 2020-05-11 21:20:50 +02:00
map_perf_ring.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
net.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.h tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
perf.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
prog.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
struct_ops.c bpftool: Respect the -d option in struct_ops cmd 2020-04-24 17:40:54 -07:00
tracelog.c tools: bpftool: add an option to prevent auto-mount of bpffs, tracefs 2018-12-18 14:47:17 +01:00
xlated_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
xlated_dumper.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00