Re: [PATCH 1/4] blk-iocost: charge flushes as pageless random writes

From: Christoph Hellwig

Date: Thu Sep 10 2026 - 01:44:16 EST


On Tue, Sep 08, 2026 at 10:21:32AM +0800, Tao Cui wrote:
> From: Tao Cui <cuitao@xxxxxxxxxx>
>
> Standalone flushes issued by blkdev_issue_flush() are represented as
> dataless REQ_OP_WRITE | REQ_PREFLUSH bios, which
> calc_vtime_cost_builtin() prices at zero. The flush component of
> flush-heavy workloads such as database commits, journal flushes, and
> metadata sync is thus neither charged nor throttled: a cgroup at 1% weight
> can issue ~510k flushes per 12s, monopolizing the device while iocost
> reports zero usage.
>
> Price them as pageless random writes (LCOEF_WRANDIO), which provides
> an approximation of the device time consumed by a flush. For
> profiles where WRANDIO clamps to zero (ssd_dfl / ssd_fast), use a
> one-page floor (LCOEF_WPAGE). After this patch, the same 1%-weight
> cgroup is limited to 24 flushes per 12s; on ext4, write+fsync
> workloads are correctly accounted through the journal layer (~2.2us
> per flush on the ssd_fast profile).

Flushes are actually a really interesting case. For devics with
a non-volatile write cache they are no-ops, but submit_bio should
ensure we never see them here. But devices with a volatile write
cache they are significantly more expensive than any kind of write.
If we touch this we should probably figure out a way to model that.
Note that this includes standalone flushes and PREFLUSH ones,
so this patch might be a good start, but still is missing a very
important part.