From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: tj@kernel.org, hannes@cmpxchg.org, bpf@vger.kernel.org, mkoutny@suse.com
Subject: Re: [RFC PATCH v7 2/4] selftests/bpf: add iocost cost model test
Date: Thu, 24 Sep 2026 05:57:10 +0000 [thread overview]
Message-ID: <20260924055710.80FD61F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260924054549.2271705-3-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/bpf: endianness bug when writing 64-bit device ID to 32-bit dev field
--
commit d5f4da7dcc6342f2064a4e05e68659fc439deaa1
Author: Tao Cui <cuitao@kylinos.cn>
selftests/bpf: add iocost cost model test
Add an example cost model implementing the full builtin linear HDD
formula at double cost, and a test which attaches it to one device:
the dev member of the struct_ops is written through the map's
initial value before load, as hid_bpf tests do with hid_id, and
attaching the struct_ops attaches the model to the device.
> diff --git a/tools/testing/selftests/bpf/prog_tests/iocost_model.c b/tools/testing/selftests/bpf/prog_tests/iocost_model.c
> new file mode 100644
> index 0000000000000..156c75367af05
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/iocost_model.c
> @@ -0,0 +1,182 @@
[ ... ]
> +void serial_test_iocost_model(void)
> +{
> + struct iocost_model *skel, *second;
> + unsigned int maj, min;
> + __u64 *ops_dev, *sdev;
> + int err;
> + char model[32], *dev;
[ ... ]
> + /* dev is the first member of struct iocost_model_ops */
> + ops_dev = bpf_map__initial_value(skel->maps.iocost_2x, NULL);
> + if (!ASSERT_OK_PTR(ops_dev, "initial_value")) {
> + iocost_model__destroy(skel);
> + return;
> + }
> + *ops_dev = makedev(maj, min);
[Severity: Medium]
Will this 64-bit write cause an endianness issue on big-endian architectures?
Since the first member dev of struct iocost_model_ops is a 32-bit dev_t,
casting the pointer to __u64 * and writing a 64-bit value will place the
actual device ID into the trailing padding on big-endian systems, leaving the
dev field as 0. Could this cause the test to fail by attaching to the wrong
device or being rejected by the kernel?
[ ... ]
> + /* a second model on the same device fails with -EBUSY */
> + second = iocost_model__open();
> + if (ASSERT_OK_PTR(second, "second_open")) {
> + sdev = bpf_map__initial_value(
> + second->maps.iocost_2x, NULL);
> + if (!ASSERT_OK_PTR(sdev, "second_initial_value"))
> + goto out_destroy;
> + *sdev = makedev(maj, min);
[Severity: Medium]
Does this have the same 64-bit write endianness issue on big-endian systems
as the first model?
[ ... ]
> +void serial_test_iocost_model_streams(void)
> +{
> + struct iocost_ms *skel;
> + unsigned int maj, min;
> + __u64 *ops_dev;
> + int err;
> + char model[32], *dev;
[ ... ]
> + ops_dev = bpf_map__initial_value(skel->maps.iocost_ms, NULL);
> + if (!ASSERT_OK_PTR(ops_dev, "initial_value")) {
> + iocost_ms__destroy(skel);
> + return;
> + }
> + *ops_dev = makedev(maj, min);
[Severity: Medium]
Does this also share the same 64-bit write endianness issue for the 32-bit
dev field?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924054549.2271705-1-cui.tao@linux.dev?part=2
next prev parent reply other threads:[~2026-09-24 5:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 5:45 [RFC PATCH v7 0/4] blk-iocost: BPF struct_ops cost model Tao Cui
2026-09-24 5:45 ` [RFC PATCH v7 1/4] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-09-24 6:00 ` sashiko-bot
2026-09-24 6:30 ` bot+bpf-ci
2026-09-29 0:42 ` Tejun Heo
2026-09-29 13:42 ` Tao Cui
2026-09-29 16:27 ` Tejun Heo
2026-09-30 4:14 ` Tao Cui
2026-09-24 5:45 ` [RFC PATCH v7 2/4] selftests/bpf: add iocost cost model test Tao Cui
2026-09-24 5:57 ` sashiko-bot [this message]
2026-09-24 6:30 ` bot+bpf-ci
2026-09-24 5:45 ` [RFC PATCH v7 3/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-09-24 6:17 ` bot+bpf-ci
2026-09-29 0:42 ` Tejun Heo
2026-09-29 13:46 ` Tao Cui
2026-09-24 5:45 ` [RFC PATCH v7 4/4] docs: cgroup-v2: document the iocost BPF cost model attachment Tao Cui
2026-09-29 0:42 ` [RFC PATCH v7 0/4] blk-iocost: BPF struct_ops cost model Tejun Heo
2026-09-29 13:39 ` Tao Cui
2026-09-29 16:27 ` Tejun Heo
2026-09-30 4:09 ` 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=20260924055710.80FD61F00899@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.