[PATCH v2] blk-cgroup: always display debug stats in io.stat
From: Breno Leitao
Date: Tue Mar 03 2026 - 09:17:18 EST
Remove the blkcg_debug_stats toggle and always display detailed
statistics in the cgroup io.stat file. This includes use_delay and
delay_nsec information, cost.wait/cost.indebt/cost.indelay for iocost,
and latency statistics for iolatency.
The stats are already being collected regardless of the toggle, so
gating their display provides no real benefit. Additionally, blk-cgroup
has not been modularized since commit 32e380aedc3de ("blkcg: make
CONFIG_BLK_CGROUP bool"), making the module parameter a historical
artifact. Readers of the nested-keys format should be able to handle
additional fields.
Before (without blkcg_debug_stats enabled):
253:0 rbytes=6273024 wbytes=0 rios=20 wios=0 dbytes=0 dios=0 cost.usage=0
After:
253:0 rbytes=6273024 wbytes=0 rios=20 wios=0 dbytes=0 dios=0 cost.usage=0 cost.wait=0 cost.indebt=0 cost.indelay=0
Suggested-by: Michal Koutný <mkoutny@xxxxxxxx>
Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
Changes in v2:
- Remove blkcg_debug_stats instead of creating a CONFIG_ to set it. (Michal)
- Link to v1: https://patch.msgid.link/20260204-blk_cgroup_debug_stats-v1-1-09c0754b4242@xxxxxxxxxx
---
block/blk-cgroup.c | 6 +-----
block/blk-cgroup.h | 1 -
block/blk-iocost.c | 9 ++++-----
block/blk-iolatency.c | 3 ---
4 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index b70096497d389..8b89a1ce6927a 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -56,8 +56,6 @@ static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS];
static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */
-bool blkcg_debug_stats = false;
-
static DEFINE_RAW_SPINLOCK(blkg_stat_lock);
#define BLKG_DESTROY_BATCH_SIZE 64
@@ -1209,7 +1207,7 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
dbytes, dios);
}
- if (blkcg_debug_stats && atomic_read(&blkg->use_delay)) {
+ if (atomic_read(&blkg->use_delay)) {
seq_printf(s, " use_delay=%d delay_nsec=%llu",
atomic_read(&blkg->use_delay),
atomic64_read(&blkg->delay_nsec));
@@ -2246,5 +2244,3 @@ bool blk_cgroup_congested(void)
return ret;
}
-module_param(blkcg_debug_stats, bool, 0644);
-MODULE_PARM_DESC(blkcg_debug_stats, "True if you want debug stats, false if not");
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 1cce3294634d1..ac38bc3e2486b 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -189,7 +189,6 @@ struct blkcg_policy {
};
extern struct blkcg blkcg_root;
-extern bool blkcg_debug_stats;
void blkg_init_queue(struct request_queue *q);
int blkcg_init_disk(struct gendisk *disk);
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index d145db61e5c31..a913e67d0f695 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -3060,11 +3060,10 @@ static void ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
seq_printf(s, " cost.usage=%llu", iocg->last_stat.usage_us);
- if (blkcg_debug_stats)
- seq_printf(s, " cost.wait=%llu cost.indebt=%llu cost.indelay=%llu",
- iocg->last_stat.wait_us,
- iocg->last_stat.indebt_us,
- iocg->last_stat.indelay_us);
+ seq_printf(s, " cost.wait=%llu cost.indebt=%llu cost.indelay=%llu",
+ iocg->last_stat.wait_us,
+ iocg->last_stat.indebt_us,
+ iocg->last_stat.indelay_us);
}
static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index 53e8dd2dfa8ad..e99abc97050a0 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -946,9 +946,6 @@ static void iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
unsigned long long avg_lat;
unsigned long long cur_win;
- if (!blkcg_debug_stats)
- return;
-
if (iolat->ssd)
return iolatency_ssd_stat(iolat, s);
---
base-commit: d517cb8cea012f43b069617fc8179b45404f8018
change-id: 20260204-blk_cgroup_debug_stats-e81b887f9c30
Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>