BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: hannes@cmpxchg.org, tj@kernel.org, mkoutny@suse.com, bpf@vger.kernel.org
Subject: Re: [RFC PATCH 2/8] blk-iocost: define iocost_model_ops cost model interface
Date: Tue, 08 Sep 2026 10:13:46 +0000	[thread overview]
Message-ID: <20260908101346.B60E01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908100143.47598-3-cui.tao@linux.dev>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `iocost_model_ops` interface uses recycled cgroup IDs (`iocg_id`) without a lifecycle callback (e.g., `release`), making safe per-cgroup state management impossible.
- [Low] Incorrect header reference in BPF struct_ops documentation.
--

commit 64a8ffdba67eaf906639412faa34e6125d2960c1
Author: Tao Cui <cuitao@kylinos.cn>

blk-iocost: define iocost_model_ops cost model interface

This commit defines the interface for pluggable cost models via a struct_ops
with a single calc_cost callback. It passes iocg_id to allow models to keep
per-cgroup state. The model is called from the IO submission path under RCU.

> diff --git a/include/linux/blk-iocost.h b/include/linux/blk-iocost.h
> new file mode 100644
> index 0000000000000..7111b5c03dc36
> --- /dev/null
> +++ b/include/linux/blk-iocost.h
> @@ -0,0 +1,56 @@

[ ... ]

> +struct iocost_model_ops {
> +	/*
> +	 * @op:		REQ_OP_* value (uapi blk_opf.h)

[Severity: Low]
Is this the correct header reference?

The file blk_opf.h does not exist in uapi. Should this point to
include/linux/blk_types.h instead?

> +	 * @nbytes:	IO size in bytes
> +	 * @sector:	starting sector
> +	 * @cursor:	iocg cursor sector, 0 if none (sequentiality hint)
> +	 * @iocg_id:	css id of the issuing cgroup
> +	 * @flags:	IOCOST_COST_F_*
> +	 */
> +	u64 (*calc_cost)(u64 op, u64 nbytes, u64 sector, u64 cursor,
> +			 u64 iocg_id, u64 flags);
> +};

[Severity: High]
Does this struct_ops interface need a release or offline callback for cgroup
state cleanup?

When a cgroup is deleted and its CSS ID is recycled, the new cgroup inherits
the historical IO state of the deleted cgroup if the BPF model tracks it. 
There is no reliable way for the BPF program to garbage collect entries,
which can eventually exhaust map space.

Could unprivileged users with cgroup delegation create and destroy cgroups,
triggering map exhaustion and causing a denial of service for the cost model
(which falls back to failure or builtin behavior once max_entries is reached)?

The commit message notes that the need for a release(iocg_id) callback is
an open question. Since BPF struct_ops signatures are frozen once merged, 
is it safe to omit it from the initial interface? This appears to be
confirmed in a follow-up patch where map entries have no deletion logic
and will leak in a production environment.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908100143.47598-1-cui.tao@linux.dev?part=2

  reply	other threads:[~2026-09-08 10:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 10:01 [RFC PATCH 0/8] blk-iocost: BPF struct_ops cost model Tao Cui
2026-09-08 10:01 ` [RFC PATCH 1/8] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-09-08 10:01 ` [RFC PATCH 2/8] blk-iocost: define iocost_model_ops cost model interface Tao Cui
2026-09-08 10:13   ` sashiko-bot [this message]
2026-09-08 20:31   ` Tejun Heo
2026-09-08 10:01 ` [RFC PATCH 3/8] blk-iocost: implement BPF struct_ops registration Tao Cui
2026-09-08 20:31   ` Tejun Heo
2026-09-08 10:01 ` [RFC PATCH 4/8] blk-iocost: dispatch cost calculation to registered BPF model Tao Cui
2026-09-08 20:31   ` Tejun Heo
2026-09-08 10:01 ` [RFC PATCH 5/8] blk-iocost: add ctrl=bpf per-device opt-in Tao Cui
2026-09-08 10:01 ` [RFC PATCH 6/8] selftests/bpf: add iocost cost model test Tao Cui
2026-09-08 10:20   ` sashiko-bot
2026-09-08 20:31   ` Tejun Heo
2026-09-08 10:01 ` [RFC PATCH 7/8] selftests/bpf: add multi-stream sequentiality example model Tao Cui
2026-09-08 10:21   ` sashiko-bot
2026-09-08 20:31   ` Tejun Heo
2026-09-08 10:01 ` [RFC PATCH 8/8] docs: cgroup-v2: document io.cost ctrl=bpf option Tao Cui
2026-09-08 20:31 ` [RFC PATCH 0/8] blk-iocost: BPF struct_ops cost model Tejun Heo
2026-09-09 13:12   ` 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=20260908101346.B60E01F00A3A@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