Hi Alexei, 在 2026/9/18 23:43, Alexei Starovoitov 写道: > On Fri, Sep 18, 2026 at 11:17 AM Tao Cui <[email protected]> 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. >
Thanks for pointing this out. You are right. I misunderstood Tejun's comment from v1. I took "per-device" as selecting a registered model by name for each device, which led to the current registry/lifecycle design. My original implementation followed the tcp-cc style named model approach, but that was not what Tejun was suggesting. The intended model should be a per-device struct_ops instance, with attach/detach controlling the switch between the BPF model and the builtin model, and the struct_ops core owning the lifetime. > pls wait for Tejun's feedback before respinning. > I'll rework the design in that direction and wait for Tejun's feedback before sending another revision. Thanks, Tao > pw-bot: cr

