From: Ziyang Men <ziyang.meme@gmail.com>
To: kernel-team@meta.com, Jens Axboe <axboe@kernel.dk>,
Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Shuah Khan" <shuah@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"JP Kobryn" <inwardvessel@gmail.com>,
"Mykola Lysenko" <mykolal@meta.com>,
"Ziyang Men" <ziyang.meme@gmail.com>,
linux-block@vger.kernel.org, bpf@vger.kernel.org,
cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] block: expose blkcg io.stat to BPF
Date: Mon, 17 Aug 2026 14:42:03 -0700 [thread overview]
Message-ID: <20260817214205.723267-1-ziyang.meme@gmail.com> (raw)
Collecting cgroup statistics is expensive: the existing method is to
open and parse a cgroup file for every cgroup of interest. The memory
controller already has an efficient alternative through BPF; this series
extends that model to the block I/O controller's per-device io.stat.
Patch 1 adds the blkcg flush and per-device iterator.
Patch 2 adds a selftest that performs direct I/O on a private loop
device and compares every counter read by BPF with io.stat.
===
Changes since v1.
- Drop the blkcg acquire/release helpers. The program reads the io
controller's css from cgroup->subsys[] under RCU instead.
- Remove the kfuncs that read the blkg device ID and counters; BPF
programs can read those fields with BPF_CORE_READ().
- Keep the flush sleepable. It now takes a struct cgroup * and pins its
CSS internally.
- Make the blkg iterator take an RCU-protected CSS.
Tested on VM with v7.2-rc5.
Ziyang Men (2):
block: add BPF kfuncs to read blkcg io.stat
selftests/bpf: add test for blkcg io.stat BPF kfuncs
MAINTAINERS | 1 +
block/Makefile | 3 +
block/blk-cgroup.c | 2 +-
block/blk-cgroup.h | 1 +
block/bpf_blkcg.c | 154 ++++++++++
tools/testing/selftests/bpf/cgroup_iter_io.h | 17 ++
tools/testing/selftests/bpf/config | 1 +
.../selftests/bpf/prog_tests/cgroup_iter_io.c | 277 ++++++++++++++++++
.../selftests/bpf/progs/cgroup_iter_io.c | 99 +++++++
9 files changed, 554 insertions(+), 1 deletion(-)
create mode 100644 block/bpf_blkcg.c
create mode 100644 tools/testing/selftests/bpf/cgroup_iter_io.h
create mode 100644 tools/testing/selftests/bpf/prog_tests/cgroup_iter_io.c
create mode 100644 tools/testing/selftests/bpf/progs/cgroup_iter_io.c
--
2.53.0-Meta
next reply other threads:[~2026-08-17 21:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 21:42 Ziyang Men [this message]
2026-08-17 21:42 ` [PATCH v2 1/2] block: add BPF kfuncs to read blkcg io.stat Ziyang Men
2026-08-17 22:08 ` sashiko-bot
2026-08-17 22:28 ` bot+bpf-ci
2026-08-18 17:21 ` Tejun Heo
2026-08-18 22:31 ` Ziyang Men
2026-08-18 22:42 ` Tejun Heo
2026-08-18 23:01 ` Ziyang Men
2026-08-19 20:43 ` Tejun Heo
2026-08-19 22:20 ` Ziyang Men
2026-08-19 22:51 ` Tejun Heo
2026-08-19 23:59 ` Ziyang Men
2026-08-17 21:42 ` [PATCH v2 2/2] selftests/bpf: add test for blkcg io.stat BPF kfuncs Ziyang Men
2026-08-17 22:41 ` bot+bpf-ci
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=20260817214205.723267-1-ziyang.meme@gmail.com \
--to=ziyang.meme@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hannes@cmpxchg.org \
--cc=inwardvessel@gmail.com \
--cc=jolsa@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mkoutny@suse.com \
--cc=mykolal@meta.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tj@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