Re: [RFC PATCH v5 1/5] blk-iocost: add BPF struct_ops cost model support
From: Alexei Starovoitov
Date: Fri Sep 18 2026 - 13:02:16 EST
On Fri, Sep 18, 2026 at 11:17 AM Tao Cui <cui.tao@xxxxxxxxx> wrote:
> The registration and binding model follows the TCP congestion
> model registration pattern: registering a struct_ops makes the model
> available by its name (char name[IOCOST_MODEL_NAME_LEN], validated at
> init_member), while
> io.cost.model binds one registered model to a device with
> "model=<name>" and unbinds with "model=linear" or "ctrl=auto/user".
> Unregistering a model removes it from the registry, but its name
I don't think it's what Tejun asked for in v1. He asked for a per-device
struct_ops instance where attaching switches the device to bpf and
detaching switches it back. Instead there is a global name registry,
a lifecycle list, an "unregistered but still bound" state and a
refcount_t on top of bpf_struct_ops_get(), and every version since v3
had a lifetime bug in exactly that code.
Do it like hid_bpf_ops does with hid_id: device in the struct_ops,
bind in .reg, unbind in .unreg, and le
t struct_ops own the lifetime.
pls wait for Tejun's feedback before respinning.
pw-bot: cr