From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: hannes@cmpxchg.org, mkoutny@suse.com, tj@kernel.org, bpf@vger.kernel.org
Subject: Re: [RFC PATCH v4 2/5] selftests/bpf: add iocost cost model test
Date: Wed, 16 Sep 2026 07:34:54 +0000 [thread overview]
Message-ID: <20260916073454.9CED51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916072302.1068871-3-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] bpf: iocost_2x model misses cursor updates during merges
- [Low] bpf: invalid multi-line comment style in bind_model
--
commit 0857836334950bc87bf809661e8e366dfa84c06a
Author: Tao Cui <cuitao@kylinos.cn>
selftests/bpf: add iocost cost model test
This commit adds an example cost model implementing the full builtin linear HDD
formula at double cost. It registers it as a struct_ops and binds it to a device
to verify readback and write operations.
> diff --git a/tools/testing/selftests/bpf/prog_tests/iocost_model.c b/tools/testing/selftests/bpf/prog_tests/iocost_model.c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/iocost_model.c
[ ... ]
> +static int bind_model(const char *dev, const char *name)
> +{
> + char buf[300], got[64];
> + int err;
> +
> + snprintf(buf, sizeof(buf), "%s model=%s\n", dev, name);
> + err = write_cost_model(buf);
> + if (err)
> + return err > 0 ? -err : -EIO;
> + err = readback_model(dev, got, sizeof(got));
> + if (!err && !strcmp(got, name)) {
> + /*
> + * restore the builtin linear model on every path so
> + * the device is not left bound to a model the caller
> + * may unregister right after; the write is checked too
> + */
> + snprintf(buf, sizeof(buf), "%s model=linear\n", dev);
> + err = write_cost_model(buf);
> + return err > 0 ? -err : (err ? -EIO : 0);
> + }
> +
> + /* bind failed or does not read back: still restore, but report
> + * the original failure rather than the restore result
> + */
[Severity: Low]
This isn't a bug, but does this multi-line comment violate the BPF subsystem's
strict comment style?
The opening `/*` must be on its own line, but here the text starts on the same
line.
> diff --git a/tools/testing/selftests/bpf/progs/iocost_model.c b/tools/testing/selftests/bpf/progs/iocost_model.c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/iocost_model.c
[ ... ]
> +SEC("struct_ops")
> +u64 BPF_PROG(iocost_2x_calc_cost, u64 opf, u64 nbytes, u64 sector,
> + struct blkcg *blkcg, u64 model_flags)
> +{
[ ... ]
> + cur = *cursor;
> + if (cur && priced) {
> + seek_pages = sector > cur ? sector - cur
> + : cur - sector;
> + seek_pages >>= IOC_SECT_TO_PAGE_SHIFT;
> + if (seek_pages > LCOEF_RANDIO_PAGES)
> + base = randio;
> + }
> + if (priced && nbytes &&
> + !(model_flags & IOCOST_COST_F_MERGE))
> + *cursor = sector + RU(nbytes, 512);
[Severity: Medium]
Does skipping the cursor update when IOCOST_COST_F_MERGE is set permanently
lose track of the end of merged requests?
If a sequence of backmerged bio submissions triggers calc_cost with
IOCOST_COST_F_MERGE set, it seems this branch will skip advancing the cursor,
leaving it pinned at the end of the first bio in the merged sequence.
If a stream builds up more than 16MB of data through merges, would subsequent
contiguous IOs calculate a seek distance > 16MB and falsely incur massive
random IO charges?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916072302.1068871-1-cui.tao@linux.dev?part=2
next prev parent reply other threads:[~2026-09-16 7:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 7:22 [RFC PATCH v4 0/5] blk-iocost: BPF struct_ops cost model Tao Cui
2026-09-16 7:22 ` [RFC PATCH v4 1/5] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-09-16 7:34 ` sashiko-bot
2026-09-16 10:31 ` Tao Cui
2026-09-16 7:22 ` [RFC PATCH v4 2/5] selftests/bpf: add iocost cost model test Tao Cui
2026-09-16 7:34 ` sashiko-bot [this message]
2026-09-16 7:23 ` [RFC PATCH v4 3/5] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-09-16 7:23 ` [RFC PATCH v4 4/5] selftests/bpf: add multi-stream sequentiality example model Tao Cui
2026-09-16 7:23 ` [RFC PATCH v4 5/5] docs: cgroup-v2: document io.cost model=<name> binding Tao Cui
2026-09-16 8:22 ` bot+bpf-ci
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=20260916073454.9CED51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cui.tao@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@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