mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Tao Cui <cui.tao@linux.dev>
Cc: josef@toxicopanda.com, axboe@kernel.dk, 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>,
	ameryhung@gmail.com, alexei.starovoitov@gmail.com
Subject: Re: [RFC PATCH v7 1/4] blk-iocost: add BPF struct_ops cost model support
Date: Mon, 28 Sep 2026 14:42:22 -1000	[thread overview]
Message-ID: <4412563645504aa9a87d3cafd544c97c@kernel.org> (raw)
In-Reply-To: <20260924054549.2271705-2-cui.tao@linux.dev>

Hello, Tao.

On Thu, 24 Sep 2026 13:45:46 +0800, Tao Cui wrote:

> -	/* if user is overriding anything, maintain what was there */
> -	if (ioc->user_qos_params || ioc->user_cost_model)
> +	/* if user is overriding anything, maintain what was there; the
> +	 * same while a BPF model is attached: the builtin coefficients
> +	 * are inert then, so stepping the profile is pointless
> +	 */
> +	if (ioc->user_qos_params || ioc->user_cost_model
> +#ifdef CONFIG_BLK_CGROUP_IOCOST_BPF
> +	    || rcu_dereference_protected(ioc->model,
> +					 lockdep_is_held(&ioc->lock))
> +#endif
> +	   )

Can you add a helper which returns the model in use with a stub returning
NULL for !CONFIG_BLK_CGROUP_IOCOST_BPF? That'd remove most of the #ifdefs
including the one in this condition and the duplicated seq_printf() in
ioc_cost_model_prfill().

> +		/* sub-page IO: nothing to transfer-price */
> +		if (!pages)
> +			return 0;
> +		/* zero transfer cost is a legal model; guard the division */
> +		if (!coeff)
> +			return 0;
> +		/* pages * coeff can wrap and dodge the clamp below */
> +		if (coeff > VTIME_PER_SEC || pages > VTIME_PER_SEC / coeff)
> +			return VTIME_PER_SEC;
> +		return min(pages * coeff, VTIME_PER_SEC);

This can just be pages * coeff like the builtin. An overflow only skews
the met/missed accounting, same as a user-set linear coefficient, and it
also gets rid of the 64-bit division.

> +	bdevf = bdev_file_open_by_dev(new_decode_dev(ops->dev),
> +				      BLK_OPEN_READ, NULL, NULL);

When the disk goes away, the model should be ejected completely.
ioc_rqos_exit() unbinds it but the open bdev file keeps the dead disk and
the driver module pinned until the link is destroyed. Can you drop all
device references on removal like hid_bpf_destroy_device() does and look
up the device like blkg_conf_open_bdev() does, with blkdev_get_no_open()
and disk_live() checked under rq_qos_mutex? The two attach issues bpf-ci
reported, the missing re-attach check in .reg and the missing disk_live()
check, are real.

Thanks.

--
tejun

  parent reply	other threads:[~2026-09-29  0:42 UTC|newest]

Thread overview: 14+ 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:30   ` bot+bpf-ci
2026-09-29  0:42   ` Tejun Heo [this message]
2026-09-29 13:42     ` Tao Cui
2026-09-24  5:45 ` [RFC PATCH v7 2/4] selftests/bpf: add iocost cost model test Tao Cui
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

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=4412563645504aa9a87d3cafd544c97c@kernel.org \
    --to=tj@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --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®