bpf: Introduce BPF_F_PRESERVE_ELEMS for perf event array
authorSong Liu <songliubraving@fb.com>
Wed, 30 Sep 2020 22:49:26 +0000 (15:49 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 1 Oct 2020 06:18:12 +0000 (23:18 -0700)
commit792caccc4526bb489e054f9ab61d7c024b15dea2
tree3a37926e19cd8a4ad165269eb80c7b8d2096414e
parent3effc06a4dde3e2f6ee3d82e59d97ec357802a4b
bpf: Introduce BPF_F_PRESERVE_ELEMS for perf event array

Currently, perf event in perf event array is removed from the array when
the map fd used to add the event is closed. This behavior makes it
difficult to the share perf events with perf event array.

Introduce perf event map that keeps the perf event open with a new flag
BPF_F_PRESERVE_ELEMS. With this flag set, perf events in the array are not
removed when the original map fd is closed. Instead, the perf event will
stay in the map until 1) it is explicitly removed from the array; or 2)
the array is freed.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200930224927.1936644-2-songliubraving@fb.com
include/uapi/linux/bpf.h
kernel/bpf/arraymap.c
tools/include/uapi/linux/bpf.h