Re: [PATCH bpf-next] libbpf: Add '_wait()' and '_nowait()' macros for 'bpf_ring_buffer__poll()'

From
Song Liu <hidden>
Date
2021-03-29 16:34:40
Also in
linux-kselftest, lkml, netdev
Reply to
Pedro Tammela, 2021-03-28
quoted hunk ↗ jump to hunk
On Mar 28, 2021, at 9:10 AM, Pedro Tammela [off-list ref] wrote:

'bpf_ring_buffer__poll()' abstracts the polling method, so abstract the
constants that make the implementation don't wait or wait indefinetly
for data.

Signed-off-by: Pedro Tammela <redacted>
---
tools/lib/bpf/libbpf.h                                 | 3 +++
tools/testing/selftests/bpf/benchs/bench_ringbufs.c    | 2 +-
tools/testing/selftests/bpf/prog_tests/ringbuf.c       | 6 +++---
tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c | 4 ++--
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index f500621d28e5..3817d84f91c6 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -540,6 +540,9 @@ 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__epoll_fd(const struct ring_buffer *rb);

+#define ring_buffer__poll_wait(rb) ring_buffer__poll(rb, -1)
+#define ring_buffer__poll_nowait(rb) ring_buffer__poll(rb, 0)
I think we don't need ring_buffer__poll_wait() as ring_buffer__poll() already 
means "wait for timeout_ms". 

Actually, I think ring_buffer__poll() is enough. ring_buffer__poll_nowait() 
is not that useful either. 

Thanks,
Song
Thread (13 messages) 13 messages, 3 authors, last reply 2021-04-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help