Since commit 636620b66d5d ("blkcg: Track DISCARD statistics and output them in cgroup io.stat"), blkg_rwstat_add() routes discard IOs into BLKG_RWSTAT_DISCARD, but blkg_rwstat_total() still only sums READ and WRITE. This makes the total inconsistent with the per-type counters whenever discard IOs are present. On mixed read/write/discard workloads, the total undercounts the actual IO activity. If only discard requests are queued, the total returns 0 outright. In BFQ this causes avg_queue_size to be underestimated and the group to be incorrectly marked empty. The affected BFQ code paths are all gated by CONFIG_BFQ_CGROUP_DEBUG and used only for statistics display (bfq.sectors, bfq.avg_queue_size, bfq.empty_time). No scheduling decisions depend on these values. Signed-off-by: Tao Cui --- block/blk-cgroup-rwstat.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-cgroup-rwstat.h b/block/blk-cgroup-rwstat.h index 703a16fe1404..b7908d877e2b 100644 --- a/block/blk-cgroup-rwstat.h +++ b/block/blk-cgroup-rwstat.h @@ -110,7 +110,8 @@ static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat) struct blkg_rwstat_sample tmp = { }; blkg_rwstat_read(rwstat, &tmp); - return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE]; + return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE] + + tmp.cnt[BLKG_RWSTAT_DISCARD]; } /** -- 2.43.0