blk-cgroup: always display debug stats in io.stat
Subsystems (3)
PATCH v2 1/1 blk-cgroup: always display debug stats in io.stat
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
---
Changes in v2:
- Remove blkcg_debug_stats instead of creating a CONFIG_ to set it. (Michal)
- Link to v1: https://patch.msgid.link/[email protected]
--- 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(-)
block/blk-cgroup.c +1 -5
@@ -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" );
block/blk-cgroup.h +0 -1
@@ -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);
block/blk-iocost.c +4 -5
@@ -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,
block/blk-iolatency.c +0 -3
@@ -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,
Signature · 1 line
Breno Leitao <[email protected]>
Tejun Heo
maintainerHello,
Quoted 7 lines · Breno Leitao
Remove the
blkcg_debug_statstoggle and always display detailed statistics in the cgroup io.stat file. This includesuse_delayanddelay_nsecinformation, 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
The reason for gating is that these are more internal implementation details and might change in the future.
Quoted 4 lines
has not been modularized since commit
32e380aedc3de("blkcg: makeCONFIG_BLK_CGROUPbool"), making the module parameter a historical artifact. Readers of the nested-keys format should be able to handle additional fields.
I'm not sure what the above para means. Module param works just fine for built-in modules on both boot command line and through sysfs.
Quoted 5 lines
Before (without
blkcg_debug_statsenabled):
253:0 rbytes=6273024 wbytes=0 rios=20 wios=0 dbytes=0 dios=0 cost.usage=0After:
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
Given that they haven't changed for a long time, maybe it's okay to expose them by default, but why? This is something which can be toggled on easily at any time. What's the benefit of exposing these extra numbers which probably don't mean much for most people?
Thanks.
Signature · 1 line
tejun
Hello Tejun,
Quoted 11 lines · Tejun Heo
Quoted 5 lines · Breno Leitao
Before (without
blkcg_debug_statsenabled):
253:0 rbytes=6273024 wbytes=0 rios=20 wios=0 dbytes=0 dios=0 cost.usage=0After:
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=0Given that they haven't changed for a long time, maybe it's okay to expose them by default, but why? This is something which can be toggled on easily at any time.
My goal is to ship a kernel that exposes these detailed io stats by default, without requiring any runtime configuration. The stats should simply be available out of the box.
Quoted 2 lines
What's the benefit of exposing these extra numbers which probably don't mean much for most people?
My original plan was to introduce a Kconfig option for this. In v1 (about a month ago), Michal suggested removing the toggle entirely and always exposing the stats, which seemed reasonable to me and received no objections, so I went ahead with that approach.
To be clear: is your position that we should not support building a kernel that always exposes the detailed stats in io.stat?
Thanks for your review,
--breno
Tejun Heo
maintainerHello, Breno.
Quoted 7 lines · Breno Leitao
Quoted 3 lines
Given that they haven't changed for a long time, maybe it's okay to expose them by default, but why? This is something which can be toggled on easily at any time.
My goal is to ship a kernel that exposes these detailed io stats by default, without requiring any runtime configuration. The stats should simply be available out of the box.
This is a pretty trivial patch to carry, right? Or just do it as a part of boot system config?
Quoted 10 lines
Quoted 2 lines
What's the benefit of exposing these extra numbers which probably don't mean much for most people?
My original plan was to introduce a
Kconfigoption for this. In v1 (about a month ago), Michal suggested removing the toggle entirely and always exposing the stats, which seemed reasonable to me and received no objections, so I went ahead with that approach.To be clear: is your position that we should not support building a kernel that always exposes the detailed stats in io.stat?
As a debug option maybe but I'd prefer if vendors (including us) that want to permanently enable these debug stats carried the patch in their trees.
I think that these are a bit too tied to the specifics of the current implementation and it's not very difficult to imagine at least some of the keys changing or getting dropped in the future, so I'm reluctant to export them by default.
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · Tejun Heo
Hello, Breno.
Quoted 4 lines · Breno Leitao
Quoted 3 lines
Given that they haven't changed for a long time, maybe it's okay to expose them by default, but why? This is something which can be toggled on easily at any time.
Quoted 6 lines
Quoted 3 lines
My goal is to ship a kernel that exposes these detailed io stats by default, without requiring any runtime configuration. The stats should simply be available out of the box.
This is a pretty trivial patch to carry, right? Or just do it as a part of boot system config?
Yes, a very trivial one, but, which requires some work to be done at every rebase. Mainly when trying to use pristine stable trees.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
What's the benefit of exposing these extra numbers which probably don't mean much for most people?
My original plan was to introduce a
Kconfigoption for this. In v1 (about a month ago), Michal suggested removing the toggle entirely and always exposing the stats, which seemed reasonable to me and received no objections, so I went ahead with that approach.
Quoted 5 lines
Quoted 2 lines
To be clear: is your position that we should not support building a kernel that always exposes the detailed stats in io.stat?
As a debug option maybe but I'd prefer if vendors (including us) that want to permanently enable these debug stats carried the patch in their trees.
That is fair, thanks for the direction!
--breno
Michal Koutný
maintainerQuoted 7 lines · Tejun Heo
Quoted 4 lines
has not been modularized since commit
32e380aedc3de("blkcg: makeCONFIG_BLK_CGROUPbool"), making the module parameter a historical artifact. Readers of the nested-keys format should be able to handle additional fields.I'm not sure what the above para means. Module param works just fine for built-in modules on both boot command line and through sysfs.
Yeah, it works but BLK_CGROUP is not a module/built-in it's config option affecting builds. I find the module_param() in blk-cgroup.c to be a residual, I admit it's convenient way how to expose a tunable to userspace.
(Contemporary way of implementing the option could also be a cgroupfs mount option/feature or maybe sysctl for which tooling is available.)
Thus I was mainly motivated by bundling this change with cleanup of the module_param().
I may have misjudged importance/usefulness of the data (not using them myself).
Quoted 3 lines · Breno Leitao
My goal is to ship a kernel that exposes these detailed io stats by default, without requiring any runtime configuration. The stats should simply be available out of the box.
Does it mean the information is useful to you since early boot and adjusting the param with a userspace tool in boot sequence is too late?
Michal
Hello Michal,
Quoted 8 lines · Michal Koutný
Quoted 3 lines · Breno Leitao
My goal is to ship a kernel that exposes these detailed io stats by default, without requiring any runtime configuration. The stats should simply be available out of the box.
Does it mean the information is useful to you since early boot and adjusting the param with a userspace tool in boot sequence is too late?
Not exactly. The goal is to have a kernel binary that, regardless of where it is deployed and how it is configured, I know know it provides full io.stat details without requiring any tunable to be changed.
Tejun Heo
maintainerHello,
Quoted 9 lines · Michal Koutný
Quoted 7 lines · Tejun Heo
Quoted 4 lines
has not been modularized since commit
32e380aedc3de("blkcg: makeCONFIG_BLK_CGROUPbool"), making the module parameter a historical artifact. Readers of the nested-keys format should be able to handle additional fields.I'm not sure what the above para means. Module param works just fine for built-in modules on both boot command line and through sysfs.
Quoted 7 lines
Yeah, it works but
BLK_CGROUPis not a module/built-in it's config option affecting builds. I find themodule_param()inblk-cgroup.cto be a residual, I admit it's convenient way how to expose a tunable to userspace.(Contemporary way of implementing the option could also be a cgroupfs mount option/feature or maybe sysctl for which tooling is available.)
I don't konw whether I'm the only one doing it but I use moduleparams as an easy way to get non-API boot and runtime toggles whether the target code is actually module or not. It's easy to use and the params are in a pretty gray area in terms of API stability, so if you wanna throw in a debug option, it works.
Thanks.
Signature · 1 line
tejun