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
Showing
- include/linux/bpf.h 4 additions, 0 deletionsinclude/linux/bpf.h
- include/linux/btf.h 11 additions, 0 deletionsinclude/linux/btf.h
- include/uapi/linux/bpf.h 18 additions, 0 deletionsinclude/uapi/linux/bpf.h
- kernel/bpf/btf.c 0 additions, 10 deletionskernel/bpf/btf.c
- kernel/bpf/helpers.c 18 additions, 0 deletionskernel/bpf/helpers.c
- kernel/bpf/verifier.c 61 additions, 3 deletionskernel/bpf/verifier.c
- kernel/trace/bpf_trace.c 2 additions, 0 deletionskernel/trace/bpf_trace.c
- tools/include/uapi/linux/bpf.h 18 additions, 0 deletionstools/include/uapi/linux/bpf.h
Loading
Please register or sign in to comment