[RFC PATCH v12 0/4] blk-iocost: BPF struct_ops cost model

From: Tao Cui

Date: Tue Nov 03 2026 - 08:43:30 EST


From: Tao Cui <cuitao@xxxxxxxxxx>

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-20261030.

Patches:

1/4 blk-iocost: add BPF struct_ops cost model support
2/4 blk-iocost: add iocost_ioc_tick tracepoint for per-period
device summary
3/4 selftests/bpf: add iocost cost model test
4/4 docs: cgroup-v2: document the iocost BPF cost model attachment

Changes since v11:

- dropped the cgroup callbacks (the models build their state in
calc_cost() anyway)
- dropped the queue freeze from detach
- folded everything into blk-iocost.c
- the selftest now uses cgroup_helpers: the tests create their own
cgroups and remove them on exit; io.cost.qos/io.cost.model are
root-only cgroupfs files and the test reverts them on its exit
paths

Tested on next-20261030 (qemu x86_64): the selftests pass, and the
2x example model doubles the charged cost over the builtin on a
rotational device (2.01x measured), returning to 1.00x after
"model=linear".

Link: https://lore.kernel.org/r/20261028143534.135968-1-cui.tao@xxxxxxxxx # v11