From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: tj@kernel.org, bpf@vger.kernel.org, hannes@cmpxchg.org, mkoutny@suse.com
Subject: Re: [RFC PATCH v3 3/5] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary
Date: Mon, 14 Sep 2026 08:11:21 +0000 [thread overview]
Message-ID: <20260914081121.7EB301F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914073356.791518-4-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The tracepoint `iocost_ioc_tick` uses `div_u64()` with a 64-bit divisor (`tick_dur`), which implicitly truncates the divisor to 32 bits and can cause a divide-by-zero kernel panic.
--
commit 1f0b986a96c58d14982b08bd292007816d7d5b50
Author: Tao Cui <cuitao@kylinos.cn>
blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary
This commit adds a new iocost_ioc_tick tracepoint to the blk-iocost
controller. It emits the overall controller state once per period from the
tail of ioc_timer_fn(). This allows observability of steady-state and
dormancy conditions without needing drgn to read kernel memory.
[ ... ]
> diff --git a/include/trace/events/iocost.h b/include/trace/events/iocost.h
> index e772b1bc60d60..ec5d9c453d55a 100644
> --- a/include/trace/events/iocost.h
> +++ b/include/trace/events/iocost.h
> @@ -178,6 +178,52 @@ TRACE_EVENT(iocost_ioc_vrate_adj,
[ ... ]
> + TP_fast_assign(
> + __assign_str(devname);
> + __entry->cur_period = cur_period;
> + __entry->period_us = tick_period_us;
> + __entry->vrate = tick_vrate;
> + __entry->busy_level = tick_busy;
> + __entry->nr_active = nr_active;
> + __entry->usage_pct = tick_dur ?
> + div_u64(usage_us_sum * 100, tick_dur) : 0;
[Severity: High]
Could this lead to a division by zero kernel panic?
The div_u64() function expects a u32 divisor, but tick_dur is passed in as a
u64 representing a time delta in microseconds. If the system experiences a
long delay (such as a ~4294 second pause from a VM suspend/resume or a
debugger session), tick_dur can be a multiple of 2^32.
In that scenario, the full 64-bit value is non-zero, allowing it to pass
the tick_dur ? safety check. However, the implicit cast to u32 inside
div_u64() truncates the lower 32 bits to exactly 0, which would result in a
divide by zero panic when the tracepoint is evaluated.
Would it be better to use div64_u64() here to safely handle the 64-bit
divisor?
> + __entry->running = tick_running;
> + ),
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914073356.791518-1-cui.tao@linux.dev?part=3
next prev parent reply other threads:[~2026-09-14 8:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 7:33 [RFC PATCH v3 0/5] blk-iocost: BPF struct_ops cost model Tao Cui
2026-09-14 7:33 ` [RFC PATCH v3 1/5] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-09-14 7:49 ` sashiko-bot
2026-09-14 23:02 ` Amery Hung
2026-09-15 2:47 ` Tao Cui
2026-09-14 7:33 ` [RFC PATCH v3 2/5] selftests/bpf: add iocost cost model test Tao Cui
2026-09-14 8:04 ` sashiko-bot
2026-09-14 7:33 ` [RFC PATCH v3 3/5] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-09-14 8:11 ` sashiko-bot [this message]
2026-09-14 7:33 ` [RFC PATCH v3 4/5] selftests/bpf: add multi-stream sequentiality example model Tao Cui
2026-09-14 7:33 ` [RFC PATCH v3 5/5] docs: cgroup-v2: document io.cost model=<name> binding 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=20260914081121.7EB301F000FF@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.