BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/6] File descriptor interface for BPF streams
@ 2026-08-30  9:35 Kumar Kartikeya Dwivedi
  2026-08-30  9:35 ` [PATCH bpf-next v1 1/6] bpf: Add file descriptor interface for program streams Kumar Kartikeya Dwivedi
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-08-30  9:35 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, Emil Tsalapatis, Tejun Heo, kkd, kernel-team

BPF program stdout and stderr streams can currently be consumed only
through BPF_PROG_STREAM_READ_BY_FD. This requires repeated bpf() calls and
provides no way to block for output or integrate with poll-based event
loops.

Add BPF_PROG_STREAM_OPEN to return a read-only, close-on-exec descriptor
for a program stream. Reads block by default, with an option for
non-blocking mode. poll and epoll report readable data and report hangup
when the program is released, while allowing buffered data to be drained
before EOF. Stream descriptors retain the stream storage without retaining
the program itself.

Expose the command through libbpf and switch bpftool tracelog to blocking
stream reads. bpftool falls back to BPF_PROG_STREAM_READ_BY_FD on older
kernels, where an unknown bpf() command returns EINVAL. The legacy command
remains supported.

See commit logs for details.

Kumar Kartikeya Dwivedi (6):
  bpf: Add file descriptor interface for program streams
  bpf: Defer stream file notifications from NMI context
  bpf: Separate stream readiness from capacity accounting
  libbpf: Add bpf_prog_stream_open()
  bpftool: Read program streams through file descriptors
  selftests/bpf: Test program stream file descriptors

 include/linux/bpf.h                           |  13 +-
 include/uapi/linux/bpf.h                      |  36 ++
 kernel/bpf/core.c                             |  13 +-
 kernel/bpf/stream.c                           | 180 ++++++++-
 kernel/bpf/syscall.c                          |  27 ++
 tools/bpf/bpftool/prog.c                      |  29 +-
 tools/include/uapi/linux/bpf.h                |  36 ++
 tools/lib/bpf/bpf.c                           |  19 +
 tools/lib/bpf/bpf.h                           |  24 ++
 tools/lib/bpf/libbpf.map                      |   1 +
 .../testing/selftests/bpf/prog_tests/stream.c | 376 ++++++++++++++++++
 tools/testing/selftests/bpf/progs/stream.c    |  10 +
 12 files changed, 733 insertions(+), 31 deletions(-)


base-commit: fbc547151dbcd9b5eee54d6b29e924c760039638
-- 
2.53.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-08-30 10:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30  9:35 [PATCH bpf-next v1 0/6] File descriptor interface for BPF streams Kumar Kartikeya Dwivedi
2026-08-30  9:35 ` [PATCH bpf-next v1 1/6] bpf: Add file descriptor interface for program streams Kumar Kartikeya Dwivedi
2026-08-30  9:47   ` sashiko-bot
2026-08-30 10:47   ` bot+bpf-ci
2026-08-30  9:35 ` [PATCH bpf-next v1 2/6] bpf: Defer stream file notifications from NMI context Kumar Kartikeya Dwivedi
2026-08-30  9:35 ` [PATCH bpf-next v1 3/6] bpf: Separate stream readiness from capacity accounting Kumar Kartikeya Dwivedi
2026-08-30  9:45   ` sashiko-bot
2026-08-30 10:35   ` bot+bpf-ci
2026-08-30  9:35 ` [PATCH bpf-next v1 4/6] libbpf: Add bpf_prog_stream_open() Kumar Kartikeya Dwivedi
2026-08-30  9:35 ` [PATCH bpf-next v1 5/6] bpftool: Read program streams through file descriptors Kumar Kartikeya Dwivedi
2026-08-30 10:35   ` bot+bpf-ci
2026-08-30  9:35 ` [PATCH bpf-next v1 6/6] selftests/bpf: Test program stream " Kumar Kartikeya Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox