From: Tejun Heo <tj@kernel.org>
To: Tao Cui <cui.tao@linux.dev>
Cc: tj@kernel.org, josef@toxicopanda.com, axboe@kernel.dk,
ameryhung@gmail.com, cgroups@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, andrii@kernel.org, eddyz87@gmail.com,
ast@kernel.org, daniel@iogearbox.net,
linux-kselftest@vger.kernel.org, Tao Cui <cuitao@kylinos.cn>
Subject: Re: [RFC PATCH v6 0/5] blk-iocost: BPF struct_ops cost model
Date: Mon, 21 Sep 2026 09:37:13 -1000 [thread overview]
Message-ID: <e5656ccd4760f26772f5db86dfdea80a@kernel.org> (raw)
In-Reply-To: <20260918055001.1273840-1-cui.tao@linux.dev>
Hello, Tao.
On Fri, 18 Sep 2026 13:49:56 +0800, Tao Cui wrote:
> The registration and binding model follows the TCP congestion
> control model registration pattern: registering a struct_ops makes
> the model available by its name, while io.cost.model binds one
> registered model to a device with "model=<name>" and restores the
> builtin model with "model=linear".
Alexei is right, this isn't what I meant. One struct_ops instance per
device: attaching binds the instance to the device and switches the device
to the model, detaching switches it back to the builtin. That removes the
name registry, the lifecycle list and the refcounting on top of the
struct_ops map reference. Putting the device id in the struct_ops the way
hid_bpf_ops does works fine. I don't have a strong opinion on how the
device is identified.
> u64 calc_cost(u64 opf, u64 nbytes, sector_t sector,
> struct blkcg *blkcg, u64 model_flags)
Why not pass the bio itself? The model can read whatever it needs from it.
The merge indicator still needs the flags argument as it isn't a property
of the bio.
> blkcg is passed so the model can key
> per-cgroup state; state stored in BPF_MAP_TYPE_CGRP_STORAGE
> follows the cgroup lifetime, and optional blkcg_online()/
> blkcg_offline() callbacks mirror the css lifecycle for models
> which want eager setup or teardown.
With a per-device instance, these should be bound to the iocg pd init and
free rather than the blkcg css. That gives the model the same per cgroup
per device lifetime as the builtin cursor and drops the global mutex from
the cgroup online and offline paths.
> The completion-time request sizing for the
> latency met/missed accounting still uses the builtin coefficients
> (the request's bio, and with it the issuing cgroup, is gone by then);
> extending the model there is left open by this interface.
Let's be explicit here. For now, the struct_ops should carry the transfer
cost coefficients, vtime per page for reads and writes, and the builtin
latency tracking and vrate adjustment should use these instead of the
linear coefficients while the model is attached.
Down the line, a model should be able to take over the QoS side too. The
vrate adjustment is driven by an empirically derived table and being able
to replace it is a good part of the value of a pluggable model. The shape
I have in mind is an rq_done(struct request *) callback which disables the
builtin latency tracking and periodic vrate adjustment, with the model
modulating directly through kfuncs to set the base vrate and the
saturation state and to read the block layer clock. That doesn't have to
be part of this series.
While a model is attached, the linear coefficients are inert. Coefficient
writes can be stored and take effect again on detach, autop shouldn't step
profiles based on vrate the same way it doesn't when the cost model is
user-set, and io.cost.model can report the model in the model field, in a
form which identifies it as a BPF model, with ctrl still describing the
coefficients.
Thanks.
--
tejun
next prev parent reply other threads:[~2026-09-21 19:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 5:49 Tao Cui
2026-09-18 5:49 ` [RFC PATCH v6 1/5] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-09-21 19:37 ` Tejun Heo
2026-09-22 13:17 ` Tao Cui
2026-09-18 5:49 ` [RFC PATCH v6 2/5] selftests/bpf: add iocost cost model test Tao Cui
2026-09-18 5:49 ` [RFC PATCH v6 3/5] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-09-21 19:37 ` Tejun Heo
2026-09-22 13:18 ` Tao Cui
2026-09-18 5:50 ` [RFC PATCH v6 4/5] selftests/bpf: add multi-stream sequentiality example model Tao Cui
2026-09-18 5:50 ` [RFC PATCH v6 5/5] docs: cgroup-v2: document io.cost model=<name> binding Tao Cui
2026-09-21 19:37 ` Tejun Heo [this message]
2026-09-22 13:11 ` [RFC PATCH v6 0/5] blk-iocost: BPF struct_ops cost model Tao Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5656ccd4760f26772f5db86dfdea80a@kernel.org \
--to=tj@kernel.org \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=josef@toxicopanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®