mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: linux-kernel@vger.kernel.org, Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH] bpf: ringbuf: add wakeup coalescing
Date: Thu, 3 Dec 2026 02:00:42 -0500	[thread overview]
Message-ID: <20261203014921-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <DNASS50ALPB1.1MW0MMZFIKO4L@gmail.com>

On Thu, Dec 03, 2026 at 04:03:09AM +0000, Alexei Starovoitov wrote:
> On Tue, Dec 01, 2026 at 11:19 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >> No. Not every ringbuf is a stream of samples.
> >
> > Right.  What if I limit it per type or something? Can make it
> > palatable?
> 
> No. The type doesn't tell a stream of samples from a one-off signal.
> A ringbuf isn't tied to a prog type either.
> Progs of different types can share one.

Right. I don't have a better generic idea, to be frank.

> > Shrug. I didn't write this thing.  So what can be done about misbehaving
> > ones, that hammer the box with wakeups on every event anywhere under /?
> > Any idea?
> 
> It's a wakeup per event only while the consumer keeps up with the prog.
> bpf_ringbuf_commit() with flags == 0:
> 
> 	else if (cons_pos == rec_pos && !(flags & BPF_RB_NO_WAKEUP))
> 		irq_work_queue(&rb->work);
> 
> So slow down the consumer. Try cpu.max on the cgroup of the tool.
> Once the tool is out of quota:
> 
>   prog                               consumer
>   rec 1: cons_pos == rec_pos
>     wakeup
>                                      throttled before it reads rec 1
>   rec 2 to N: cons_pos != rec_pos
>     no wakeup
>                                      next period: reads rec 1 to N
> 
> That's per box and per tool. No need for kernel changes.
> If the quota is too low the ring fills up and records are lost.

Lost records is exactly the problem with this approach. If I wanted lost
records, I could just stop the monitor, see? What my patch does is
basically like NAPI for networking. This way, the records are not
lost.

I think I will just have to carry an out of tree patch for now.  It's a
bit of a hassle but hey.
-- 
MST

      reply	other threads:[~2026-12-03  7:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 14:39 Michael S. Tsirkin
2026-12-02  0:09 ` Alexei Starovoitov
2026-12-02  0:29   ` Michael S. Tsirkin
2026-12-02  0:54     ` Alexei Starovoitov
2026-12-02  1:00       ` Michael S. Tsirkin
2026-12-02  1:19         ` Alexei Starovoitov
2026-12-02  7:19           ` Michael S. Tsirkin
2026-12-03  4:03             ` Alexei Starovoitov
2026-12-03  7:00               ` Michael S. Tsirkin [this message]

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=20261203014921-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®