From: Xu Kuohai <xukuohai@huaweicloud.com>
To: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Yonghong Song <yhs@fb.com>,
Song Liu <song@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
Shuah Khan <shuah@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Willem de Bruijn <willemb@google.com>,
Jason Xing <kerneljasonxing@gmail.com>,
Paul Chaignon <paul.chaignon@gmail.com>,
Tao Chen <chen.dylane@linux.dev>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin Kelly <martin.kelly@crowdstrike.com>
Subject: [PATCH bpf-next 0/4] Add overwrite mode for bpf ring buffer
Date: Mon, 4 Aug 2025 10:20:56 +0800 [thread overview]
Message-ID: <20250804022101.2171981-1-xukuohai@huaweicloud.com> (raw)
From: Xu Kuohai <xukuohai@huawei.com>
When the bpf ring buffer is full, new events can not be recorded util
the consumer consumes some events to free space. This may cause critical
events to be discarded, such as in fault diagnostic, where recent events
are more critical than older ones.
So add ovewrite mode for bpf ring buffer. In this mode, the new event
overwrites the oldest event when the buffer is full.
Xu Kuohai (4):
bpf: Add overwrite mode for bpf ring buffer
libbpf: ringbuf: Add overwrite ring buffer process
selftests/bpf: Add test for overwrite ring buffer
selftests/bpf/benchs: Add overwrite mode bench for rb-libbpf
include/uapi/linux/bpf.h | 4 +
kernel/bpf/ringbuf.c | 159 +++++++++++++++---
tools/include/uapi/linux/bpf.h | 4 +
tools/lib/bpf/ringbuf.c | 103 +++++++++++-
tools/testing/selftests/bpf/Makefile | 3 +-
.../selftests/bpf/benchs/bench_ringbufs.c | 22 ++-
.../bpf/benchs/run_bench_ringbufs.sh | 4 +
.../selftests/bpf/prog_tests/ringbuf.c | 74 ++++++++
.../bpf/progs/test_ringbuf_overwrite.c | 98 +++++++++++
9 files changed, 442 insertions(+), 29 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/test_ringbuf_overwrite.c
--
2.43.0
next reply other threads:[~2025-08-04 2:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 2:20 Xu Kuohai [this message]
2025-08-04 2:20 ` [PATCH bpf-next 1/4] bpf: Add overwrite mode for bpf ring buffer Xu Kuohai
2025-08-08 21:39 ` Alexei Starovoitov
2025-08-12 4:02 ` Xu Kuohai
2025-08-13 13:22 ` Jordan Rome
2025-08-14 13:59 ` Xu Kuohai
2025-08-04 2:20 ` [PATCH bpf-next 2/4] libbpf: ringbuf: Add overwrite ring buffer process Xu Kuohai
2025-08-13 18:21 ` Zvi Effron
2025-08-14 14:10 ` Xu Kuohai
2025-08-14 19:34 ` Eduard Zingerman
2025-08-14 21:20 ` Zvi Effron
2025-08-22 21:23 ` Andrii Nakryiko
2025-08-23 14:38 ` Xu Kuohai
2025-08-04 2:20 ` [PATCH bpf-next 3/4] selftests/bpf: Add test for overwrite ring buffer Xu Kuohai
2025-08-04 2:21 ` [PATCH bpf-next 4/4] selftests/bpf/benchs: Add overwrite mode bench for rb-libbpf Xu Kuohai
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=20250804022101.2171981-1-xukuohai@huaweicloud.com \
--to=xukuohai@huaweicloud.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chen.dylane@linux.dev \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.kelly@crowdstrike.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mykolal@fb.com \
--cc=paul.chaignon@gmail.com \
--cc=sdf@fomichev.me \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=willemb@google.com \
--cc=yhs@fb.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).