OSDN Git Service

bpf: Introducte bpf_this_cpu_ptr()
authorHao Luo <haoluo@google.com>
Tue, 29 Sep 2020 23:50:48 +0000 (16:50 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 2 Oct 2020 22:00:49 +0000 (15:00 -0700)
commit63d9b80dcf2c67bc5ade61cbbaa09d7af21f43f1
tree1eeb951bd0bc20041d49ef77f68cd17f8096fec6
parenteaa6bcb71ef6ed3dc18fc525ee7e293b06b4882b
bpf: Introducte bpf_this_cpu_ptr()

Add bpf_this_cpu_ptr() to help access percpu var on this cpu. This
helper always returns a valid pointer, therefore no need to check
returned value for NULL. Also note that all programs run with
preemption disabled, which means that the returned pointer is stable
during all the execution of the program.

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-6-haoluo@google.com
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/helpers.c
kernel/bpf/verifier.c
kernel/trace/bpf_trace.c
tools/include/uapi/linux/bpf.h