bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org,  Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	 Emil Tsalapatis <emil@etsalapatis.com>,
	 Barret Rhoden <brho@google.com>,
	 kkd@meta.com, kernel-team@meta.com
Subject: Re: [RFC PATCH bpf-next/net v1 07/13] bpf: Introduce per-prog stdout/stderr streams
Date: Tue, 22 Apr 2025 15:09:42 -0700	[thread overview]
Message-ID: <m25xivrgpl.fsf@gmail.com> (raw)
In-Reply-To: <CAP01T77jqjoO3pc-V7qvsck1A9KJ-1u60ryouLL68ctHz2M=mQ@mail.gmail.com> (Kumar Kartikeya Dwivedi's message of "Thu, 17 Apr 2025 22:06:58 +0200")

Kumar Kartikeya Dwivedi <memxor@gmail.com> writes:

[...]

> > > +BTF_KFUNCS_START(stream_consumer_kfunc_set)
> > > +BTF_ID_FLAGS(func, bpf_stream_next_elem_batch, KF_ACQUIRE | KF_RET_NULL | KF_TRUSTED_ARGS)
> > > +BTF_ID_FLAGS(func, bpf_stream_free_elem_batch, KF_RELEASE)
> > > +BTF_ID_FLAGS(func, bpf_stream_next_elem, KF_ACQUIRE | KF_RET_NULL | KF_TRUSTED_ARGS)
> > > +BTF_ID_FLAGS(func, bpf_stream_free_elem, KF_RELEASE)
> > > +BTF_ID_FLAGS(func, bpf_prog_stream_get, KF_ACQUIRE | KF_RET_NULL)
> > > +BTF_ID_FLAGS(func, bpf_prog_stream_put, KF_RELEASE)
> > > +BTF_KFUNCS_END(stream_consumer_kfunc_set)
> >
> > This is a complicated API.
> > If we anticipate that users intend to write this info to ring buffers
> > maybe just provide a function doing that and do not expose complete API?
>
> I don't think anyone will use these functions directly, though they
> can if they want to.
> It's meant to be hidden behind bpftool, and macros to print stuff like
> bpf_printk().
>
> We cannot pop one message at a time, since they are not in FIFO order.
> So we need to splice out the whole batch queued and reverse it, before
> popping things.
> It's a consequence of using lockless lists.
>
> The other option is using a lock to protect the list, but using
> rqspinlock to then report messages about rqspinlock sounds like a
> circular dependency.

The API exposes 6 kfuncs and 3 data structures.
If things are exposed these things would be used, I wouldn't assume
that bpftool would be the only user. I'm sure people would craft their
own monitoring solutions.

Imo, exposing 9 entities is a lot. What I don't like about it,
is that API is not abstract:
- user cares about getting program log to some buffer, stream or file;
- user does not care how the strings are split internally in order to
  make logging efficient.

If at some point we decide to change implementation this API would be
hard to preserve.

Hence I suggest to instead provide a set of kfuncs that would drain
message queue into user provided ringbuf or buffer, w/o exposing
details.

A question: why exposing this functionality as kfuncs and not BPF
syscall commands?

  parent reply	other threads:[~2025-04-22 22:09 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 16:14 [RFC PATCH bpf-next/net v1 00/13] BPF Standard Streams Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 01/13] bpf: Tie dynptrs to referenced source objects Kumar Kartikeya Dwivedi
2025-04-14 19:58   ` Amery Hung
2025-04-17 19:53     ` Kumar Kartikeya Dwivedi
2025-04-16  5:52   ` Eduard Zingerman
2025-04-17 19:52     ` Kumar Kartikeya Dwivedi
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 19:51     ` Kumar Kartikeya Dwivedi
2025-04-22 21:09       ` Andrii Nakryiko
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 02/13] bpf: Compare dynptr_id in regsafe Kumar Kartikeya Dwivedi
2025-04-16  7:58   ` Eduard Zingerman
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 19:54     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 03/13] selftests/bpf: Convert dynptr_fail to use vmlinux.h Kumar Kartikeya Dwivedi
2025-04-16  8:41   ` Eduard Zingerman
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 04/13] selftests/bpf: Add tests for dynptr source object interaction Kumar Kartikeya Dwivedi
2025-04-16  8:40   ` Eduard Zingerman
2025-04-17 20:09     ` Kumar Kartikeya Dwivedi
2025-04-17 20:44       ` Eduard Zingerman
2025-04-17 21:10         ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 05/13] locking/local_lock, mm: Replace localtry_ helpers with local_trylock_t type Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 06/13] bpf: Introduce bpf_dynptr_from_mem_slice Kumar Kartikeya Dwivedi
2025-04-16 17:36   ` Eduard Zingerman
2025-04-17 20:07     ` Kumar Kartikeya Dwivedi
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 20:07     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 07/13] bpf: Introduce per-prog stdout/stderr streams Kumar Kartikeya Dwivedi
2025-04-16 21:49   ` Eduard Zingerman
2025-04-17 20:06     ` Kumar Kartikeya Dwivedi
2025-04-22  1:42       ` Alexei Starovoitov
2025-04-22  2:30         ` Kumar Kartikeya Dwivedi
2025-04-22 17:44           ` Alexei Starovoitov
2025-04-22 22:09       ` Eduard Zingerman [this message]
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 08/13] bpf: Add dump_stack() analogue to print to BPF stderr Kumar Kartikeya Dwivedi
2025-04-22 21:07   ` Eduard Zingerman
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 09/13] bpf: Report may_goto timeout " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 10/13] bpf: Report rqspinlock deadlocks/timeout " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 11/13] bpf: Report arena faults " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 12/13] bpftool: Add support for dumping streams Kumar Kartikeya Dwivedi
2025-04-22 20:30   ` Eduard Zingerman
2025-04-22 22:10   ` Quentin Monnet
2025-05-07 17:13     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 13/13] selftests/bpf: Add tests for prog streams Kumar Kartikeya Dwivedi
2025-04-22 19:12   ` Eduard Zingerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m25xivrgpl.fsf@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brho@google.com \
    --cc=daniel@iogearbox.net \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).