bpf: Introduce bpf_per_cpu_ptr()
authorHao Luo <haoluo@google.com>
Tue, 29 Sep 2020 23:50:47 +0000 (16:50 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 2 Oct 2020 22:00:49 +0000 (15:00 -0700)
commiteaa6bcb71ef6ed3dc18fc525ee7e293b06b4882b
treef942e4cd04a29b8f50ec5a57db535da79fcdd068
parent2c2f6abeff1322a61f5ad7ce0ecccabf53e4fad5
bpf: Introduce bpf_per_cpu_ptr()

Add bpf_per_cpu_ptr() to help bpf programs access percpu vars.
bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the kernel
except that it may return NULL. This happens when the cpu parameter is
out of range. So the caller must check the returned value.

Signed-off-by: Hao Luo <haoluo@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200929235049.2533242-5-haoluo@google.com
include/linux/bpf.h
include/linux/btf.h
include/uapi/linux/bpf.h
kernel/bpf/btf.c
kernel/bpf/helpers.c
kernel/bpf/verifier.c
kernel/trace/bpf_trace.c
tools/include/uapi/linux/bpf.h