Re: [RFC PATCH v14 0/4] blk-iocost: BPF struct_ops cost model
From: Tao Cui
Date: Wed Nov 18 2026 - 08:17:54 EST
Hello, Alexei,
在 2026/11/18 21:10, Tao Cui 写道:
> 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-20261117.
p1 changed quite a bit since the version you acked, mostly from
tj's review and Sashiko's testing reports, so here's a quick
summary.
The flag enum and the model accessors are renamed. The merge flag
is now enum iocost_calc_flags with IOCOST_CALC_MERGE, calc_cost()
takes a calc_flags parameter, and ioc_model()/model become
ioc_bpf_model()/bpf_model so the builtin model is no longer
represented as a NULL model. The named enum also makes the flags
discoverable through BTF.
calc_cost() now has the same pricing scope as the builtin model:
bios with no data and no flush state and ops other than reads,
writes and zone appends cost nothing, flushes are passed through
so the model can price them from the bio flags, and
completion-time sizing now follows the model's transfer
coefficients.
On attach iocost holds its own reference on the struct_ops map,
so a model cannot go away while it is pricing. A dead owning map
reports -ENODEV instead of -EBUSY now, and the autop stepping
timestamps are cleared at attach so a stale pre-attach profile
cannot fire a step at the model=linear switchback.
The attached and attached_link updates also moved out of
ioc->lock: rq_qos_mutex already orders all their accessors, and
ioc->lock is only needed for publishing bpf_model to the timer
and show paths.
I'm still carrying your Acked-by. Since p1 changed quite a bit,
I'm happy to drop it until you've had a chance to take another
look if you'd prefer.
Thanks,
Tao