> blk-iocost: add BPF struct_ops cost model support

TL;DR: Documentation issue only: cgroup-v2.rst isn't updated for io.cost.model
accepting "model=bpf", and writing "model=linear" now switches a device off an
attached BPF model, which may surprise existing tools.

> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 2745bffcd5ee..509ae36f99ed 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c

[ ... ]

> @@ -3536,9 +3961,25 @@ static ssize_t ioc_cost_model_write(struct 
> kernfs_open_file *of, char *input,
>                       continue;
>               case COST_MODEL:
>                       match_strlcpy(buf, &args[0], sizeof(buf));
> -                     if (strcmp(buf, "linear"))
> -                             goto unlock;
> -                     continue;
> +                     if (!strcmp(buf, "linear")) {
> +                             /* staged and committed below, so a parse
> +                              * error later in the same write leaves
> +                              * the model selection untouched
> +                              */
> +                             new_model = NULL;
> +                             model_write = true;
> +                             continue;
> +                     }
> +                     if (!strcmp(buf, "bpf")) {
> +                             new_model = rcu_dereference_protected(
> +                                             ioc->attached,
> +                                             lockdep_is_held(&ioc->lock));
> +                             if (!new_model)
> +                                     goto unlock;
> +                             model_write = true;
> +                             continue;
> +                     }
> +                     goto unlock;
>               }

Does this change to the io.cost.model interface need a matching update to
Documentation/admin-guide/cgroup-v2.rst?

ioc_cost_model_write() now accepts "model=bpf", and "model=linear" is no
longer only a value check.  It now clears ioc->model and moves the device
off an attached BPF model.  ioc_cost_model_prfill() can also print
"model=bpf".

The documentation still describes the key as:

  model         The cost model in use - "linear"

and says nothing about "bpf" or the new effect of writing "linear".

Existing tools that write lines like "MAJ:MIN ctrl=user model=linear
rbps=..." will now silently switch a device away from an attached BPF
model.  Could cgroup-v2.rst be updated to cover the new value and the
changed semantics?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/37124306614

Reply via email to