History

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.

Song Liu committed 6 years ago

Commit 792cacc1 parent 3effc063 files · +23 −2Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+3−0
@@ -414,6 +414,9 @@ enum { · 413 unmodified lines
414414
415415 /* Enable memory-mapping BPF map */
416416 BPF_F_MMAPABLE = (1U << 10),
417+
418+/* Share perf_event among processes */
419+ BPF_F_PRESERVE_ELEMS = (1U << 11),
417420 };
418421
419422 /* Flags for BPF_PROG_QUERY. */