From: Tao Cui <cui.tao@linux.dev>
To: tj@kernel.org, josef@toxicopanda.com, axboe@kernel.dk,
ast@kernel.org, alexei.starovoitov@gmail.com
Cc: cui.tao@linux.dev, cgroups@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, andrii@kernel.org, eddyz87@gmail.com,
daniel@iogearbox.net, linux-kselftest@vger.kernel.org,
cuitao@kylinos.cn, ameryhung@gmail.com
Subject: Re: [PATCH v15 0/4] blk-iocost: BPF struct_ops cost model
Date: Fri, 4 Dec 2026 17:06:34 +0800 [thread overview]
Message-ID: <f9e1fa44-f925-4040-85c4-1b69ba832714@linux.dev> (raw)
In-Reply-To: <20261203150338.2625598-1-cui.tao@linux.dev>
在 2026/12/3 23:03, Tao Cui 写道:
> From: Tao Cui <cuitao@kylinos.cn>
>
> This series lets a BPF program take over the cost model of one
> device. The BPF model provides calc_cost() for charged IOs plus two
> transfer coefficients for the completion-time sizing, io.cost.model
> selects between the attached model and the builtin one, and enabling
> and disabling the controller stays with io.cost.qos.
>
> The builtin model is a linear formula derived from a handful of device
> parameters, and the right formula is device specific. A BPF model can
> be adapted to the device and updated without rebuilding the kernel.
>
> The series is based on next-20261201.
>
> Changes since v14:
> - p1: put the three BPF fields under CONFIG_BLK_CGROUP_IOCOST_BPF
> with stub helpers, and pass IOCOST_CALC_* flags into
> calc_vtime_cost() instead of a bool (review from tj)
> - p1: iocost_model_ops gains a name[] member; io.cost.model prints
> "model=bpf name=<name>" and the docs cover the new key (review
> from tj)
> - p1: rework the attach/detach lifecycle: .reg() keeps the bdev
> reference and stores the ops pointer in a private member,
> .unreg() reaches the queue through it and drops the reference,
> and ioc_rqos_exit() queues a work item running the usual
> .unreg(); a NULL-link attach is rejected with -EOPNOTSUPP
> (review from tj)
> - p1: switching the cost model resets the per-iocg vtime state
> accumulated under the old pricing: debts, delays and waiters are
> dropped and vtime snaps to the activation target. An RCU grace
> period before the reset ensures every bio priced by the outgoing
> model is accounted for; the accounting also resets on attach and
> on device removal, and the model write resets before freezing
> the queue so it cannot stall behind the waiters it releases
> (review from tj)
> - p1: clamp a bio's completion-time payoff to vtime so that stale
> costs from bios still in flight across a switch cannot push
> done_vtime past vtime
> - p2: drop the field documentation block that v14 added to the
> iocost_ioc_tick tracepoint and return it to its v13 form (report
> from bpf-ci)
> - p3: mount cgroup2 in a private mount namespace, return negative
> error codes from open_nullb_dev(), and preserve the working
> directory across the setns() unwind (reports from sashiko and
> bpf-ci)
> - p3: add the upper-bound validate case, snapshot the stream
> counters per phase so the assertions cover that phase alone, and
> probe the tracepoint via kallsyms instead of tracefs
> - p4: the coefficient readback under a BPF model shows only
> "model=bpf" plus the model name, and the io.cost.model key table
> lists name=
>
> The p1 lifecycle rework and the model-switch reset change the
> reference semantics Alexei's ack covered (the bdev handoff, the
> workfn eject, the new iocost_model_ops members and the NULL-link
> rejection); a re-review would be appreciated.
>
Hmm,v15 turned out to be the worst posting of this series,three
high-severity bugs in the lifecycle I had just reworked, one of them a
recurrence of a defect already reported on RFC v7, and none of it
caught before posting. Sorry for the noise, and v16 will address all of the reported problems.
Thanks,
Tao
> Tested on next-20261201 (two qemu x86_64 VMs, rotational device):
> the builtin model collapses two sequential 4K readers to ~2 MB/s,
> switching to the attached BPF model completes the io.cost.model
> write in 0.02s and recovers immediately, and switching back
> collapses again; an overnight tidal run of 37 load cycles over 9.6h
> completed 13M+ transactions with all 37 model switches in
> 0.01-0.03s and nothing in dmesg. The selftests pass (3 tests,
> 0 skipped). The final tree also rebuilds cleanly from the four
> patches applied to a fresh next-20261201 tree, kernel and selftests
> alike.
>
> Link: https://lore.kernel.org/r/20261118131029.797007-1-cui.tao@linux.dev # v14
>
> Tao Cui (4):
> blk-iocost: add BPF struct_ops cost model support
> blk-iocost: add iocost_ioc_tick tracepoint for per-period device
> summary
> selftests/bpf: add iocost cost model test
> docs: cgroup-v2: document the iocost BPF cost model attachment
>
> Documentation/admin-guide/cgroup-v2.rst | 56 +-
> MAINTAINERS | 1 +
> block/Kconfig | 4 +
> block/blk-iocost.c | 705 ++++++++++++++-
> include/trace/events/iocost.h | 43 +
> tools/testing/selftests/bpf/config | 2 +
> .../selftests/bpf/prog_tests/iocost_model.c | 1021 +++++++++++++++
> .../selftests/bpf/progs/iocost_model.c | 189 +++
> tools/testing/selftests/bpf/progs/iocost_ms.c | 206 +++
> 9 files changed, 2192 insertions(+), 35 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/iocost_model.c
> create mode 100644 tools/testing/selftests/bpf/progs/iocost_model.c
> create mode 100644 tools/testing/selftests/bpf/progs/iocost_ms.c
>
> --
> 2.53.0
prev parent reply other threads:[~2026-12-04 9:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 15:03 [PATCH v15 0/4] blk-iocost: BPF struct_ops cost model Tao Cui
2026-12-03 15:03 ` [PATCH v15 1/4] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-12-03 15:44 ` bot+bpf-ci
2026-12-04 9:27 ` Tao Cui
2026-12-03 15:46 ` sashiko-bot
2026-12-04 9:33 ` Tao Cui
2026-12-03 15:03 ` [PATCH v15 2/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-12-03 15:03 ` [PATCH v15 3/4] selftests/bpf: add iocost cost model test Tao Cui
2026-12-03 15:32 ` sashiko-bot
2026-12-03 15:33 ` bot+bpf-ci
2026-12-03 15:03 ` [PATCH v15 4/4] docs: cgroup-v2: document the iocost BPF cost model attachment Tao Cui
2026-12-03 15:19 ` sashiko-bot
2026-12-04 9:06 ` Tao Cui [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=f9e1fa44-f925-4040-85c4-1b69ba832714@linux.dev \
--to=cui.tao@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@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=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=josef@toxicopanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=tj@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.