Commit a4d2a7ad authored by Brendan Jackman's avatar Brendan Jackman Committed by Andrii Nakryiko

libbpf: Expose libbpf ring_buffer epoll_fd

This provides a convenient perf ringbuf -> libbpf ringbuf migration
path for users of external polling systems. It is analogous to
perf_buffer__epoll_fd.
Signed-off-by: default avatarBrendan Jackman <jackmanb@google.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201214113812.305274-1-jackmanb@google.com
parent 2e33f831
...@@ -536,6 +536,7 @@ LIBBPF_API int ring_buffer__add(struct ring_buffer *rb, int map_fd, ...@@ -536,6 +536,7 @@ LIBBPF_API int ring_buffer__add(struct ring_buffer *rb, int map_fd,
ring_buffer_sample_fn sample_cb, void *ctx); ring_buffer_sample_fn sample_cb, void *ctx);
LIBBPF_API int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms); LIBBPF_API int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms);
LIBBPF_API int ring_buffer__consume(struct ring_buffer *rb); LIBBPF_API int ring_buffer__consume(struct ring_buffer *rb);
LIBBPF_API int ring_buffer__epoll_fd(const struct ring_buffer *rb);
/* Perf buffer APIs */ /* Perf buffer APIs */
struct perf_buffer; struct perf_buffer;
......
...@@ -346,6 +346,7 @@ LIBBPF_0.3.0 { ...@@ -346,6 +346,7 @@ LIBBPF_0.3.0 {
btf__parse_split; btf__parse_split;
btf__new_empty_split; btf__new_empty_split;
btf__new_split; btf__new_split;
ring_buffer__epoll_fd;
xsk_setup_xdp_prog; xsk_setup_xdp_prog;
xsk_socket__update_xskmap; xsk_socket__update_xskmap;
} LIBBPF_0.2.0; } LIBBPF_0.2.0;
...@@ -282,3 +282,9 @@ int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms) ...@@ -282,3 +282,9 @@ int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms)
} }
return cnt < 0 ? -errno : res; return cnt < 0 ? -errno : res;
} }
/* Get an fd that can be used to sleep until data is available in the ring(s) */
int ring_buffer__epoll_fd(const struct ring_buffer *rb)
{
return rb->epoll_fd;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment