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

From: Tejun Heo

Date: Tue Dec 01 2026 - 10:05:03 EST


Hello, Tao.

On Tue, Dec 01, 2026 at 09:26:21PM +0800, Tao Cui wrote:
> The question is what happens to the per-iocg vtime state on the
> switch. The debt and delays built up under the old model were priced
> with coefficients that don't apply anymore, and paying them back can
> keep the cgroup stalled for a long time. My current branch treats a
> model switch as a fresh start: abs_vdebt and delay are cleared and
> each active iocg's vtime is moved to the activation target budget, the
> same one iocg_activate() gives a newly activated iocg.

Between two working models, I don't think it matters much as what's
carried over is transient. However, a misbehaving BPF model can leave
things in a state which is hard to get out of and switching the model is
how the admin would recover, so being able to reset when switching away
from a BPF model makes sense.

I think the waiters need to be covered too. A bio waiting on iocg->waitq
keeps the cost it was queued with and nothing behind it can go before it
does. Also, the model write freezes the queue, which waits for the
waiters, so AFAICS the switch itself can get stuck behind them. Maybe
something like the following?

1. When switching away from a BPF model, clear ioc->bpf_model and wait
for an RCU grace period. If the RCU read section in the throttle and
merge paths covers from calc_vtime_cost() to where the bio is
committed, charged as debt or put on the waitq, every bio priced by
the BPF model is accounted for after the grace period.

2. Reset all active iocgs - clear the debts and delays, release all the
waiters and then move vtime to the activation target as you're doing
now.

3. Freeze the queue and refresh the params as now.

Thanks.

--
tejun