* [PATCH] blk-cgroup: add CONFIG_BLK_CGROUP_DEBUG_STATS option
@ 2026-02-04 16:15 Breno Leitao
2026-02-12 10:26 ` Michal Koutný
0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2026-02-04 16:15 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo, Josef Bacik
Cc: linux-block, linux-kernel, cgroups, thevlad, kernel-team,
Breno Leitao
Add a Kconfig option to enable blkcg_debug_stats by default at compile
time. When CONFIG_BLK_CGROUP_DEBUG_STATS is enabled, additional debugging
information is shown in the cgroup io.stat file, including cost.wait,
cost.indebt, and cost.indelay for iocost, as well as latency statistics
for iolatency.
The runtime module parameter blkcg_debug_stats remains functional,
allowing the setting to be toggled regardless of the compile-time
default.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
This option is commonly enabled by some hyperscalers, either through the
command line or custom patches. Let's make it part of the kernel.
---
block/Kconfig | 15 +++++++++++++++
block/blk-cgroup.c | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/block/Kconfig b/block/Kconfig
index 15027963472d7..03fb95a24564c 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -170,6 +170,21 @@ config BLK_CGROUP_IOPRIO
scheduler and block devices process requests. Only some I/O schedulers
and some block devices support I/O priorities.
+config BLK_CGROUP_DEBUG_STATS
+ bool "Enable blkcg debug stats by default"
+ depends on BLK_CGROUP
+ default n
+ help
+ Enable blkcg debug stats by default. This provides additional
+ debugging information in the cgroup io.stat file, including
+ cost.wait, cost.indebt, cost.indelay for iocost and latency
+ statistics for iolatency.
+
+ This can also be enabled at runtime via the blkcg_debug_stats
+ module parameter.
+
+ If unsure, say N.
+
config BLK_DEBUG_FS
bool "Block layer debugging information in debugfs"
default y
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 3cffb68ba5d87..67687d02b3cbc 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -56,7 +56,7 @@ static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS];
static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */
-bool blkcg_debug_stats = false;
+bool blkcg_debug_stats = IS_ENABLED(CONFIG_BLK_CGROUP_DEBUG_STATS);
static DEFINE_RAW_SPINLOCK(blkg_stat_lock);
---
base-commit: 4c87cdd0328495759f6e9f9f4e1e53ef8032a76f
change-id: 20260204-blk_cgroup_debug_stats-e81b887f9c30
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-cgroup: add CONFIG_BLK_CGROUP_DEBUG_STATS option
2026-02-04 16:15 [PATCH] blk-cgroup: add CONFIG_BLK_CGROUP_DEBUG_STATS option Breno Leitao
@ 2026-02-12 10:26 ` Michal Koutný
2026-03-03 13:59 ` Breno Leitao
0 siblings, 1 reply; 3+ messages in thread
From: Michal Koutný @ 2026-02-12 10:26 UTC (permalink / raw)
To: Breno Leitao
Cc: Jens Axboe, Tejun Heo, Josef Bacik, linux-block, linux-kernel,
cgroups, thevlad, kernel-team
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
Hello Breno.
On Wed, Feb 04, 2026 at 08:15:12AM -0800, Breno Leitao <leitao@debian.org> wrote:
> Add a Kconfig option to enable blkcg_debug_stats by default at compile
> time. When CONFIG_BLK_CGROUP_DEBUG_STATS is enabled, additional debugging
> information is shown in the cgroup io.stat file, including cost.wait,
> cost.indebt, and cost.indelay for iocost, as well as latency statistics
> for iolatency.
This seems to be toggleable quite easily anytime at runtime (not sysctl
but modprobe config), not a boot cmdline where CONFIG_ default could
step in.
This only guards printing of already collected stats (sometimes even
without kernel consumers), not sure if it's that useful.
blk-cgroup isn't modularized since 32e380aedc3de ("blkcg: make
CONFIG_BLK_CGROUP bool") v3.5-rc1~42^2~92 exposing it like a module
parameter is historical artifact.
So I'd dare to propose removing it altogether and print those stats
everytime. Readers of the nested-keys format should survive that.
(I don't even see the param documented.)
And if there were eager readers that'd be affected performance-wise,
more conventional would be to make this only boot cmdline parameter that
could static-branch also the stat collection spots (for some more
benefit). And then would also a CONFIG_urable default make sense.
WDYT?
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] blk-cgroup: add CONFIG_BLK_CGROUP_DEBUG_STATS option
2026-02-12 10:26 ` Michal Koutný
@ 2026-03-03 13:59 ` Breno Leitao
0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2026-03-03 13:59 UTC (permalink / raw)
To: Michal Koutný
Cc: Jens Axboe, Tejun Heo, Josef Bacik, linux-block, linux-kernel,
cgroups, thevlad, kernel-team
hello Michal,
First of all, sorry for being late here, I had some days off.
On Thu, Feb 12, 2026 at 11:26:29AM +0100, Michal Koutný wrote:
> On Wed, Feb 04, 2026 at 08:15:12AM -0800, Breno Leitao <leitao@debian.org> wrote:
> > Add a Kconfig option to enable blkcg_debug_stats by default at compile
> > time. When CONFIG_BLK_CGROUP_DEBUG_STATS is enabled, additional debugging
> > information is shown in the cgroup io.stat file, including cost.wait,
> > cost.indebt, and cost.indelay for iocost, as well as latency statistics
> > for iolatency.
>
> This seems to be toggleable quite easily anytime at runtime (not sysctl
> but modprobe config), not a boot cmdline where CONFIG_ default could
> step in.
>
> This only guards printing of already collected stats (sometimes even
> without kernel consumers), not sure if it's that useful.
>
> blk-cgroup isn't modularized since 32e380aedc3de ("blkcg: make
> CONFIG_BLK_CGROUP bool") v3.5-rc1~42^2~92 exposing it like a module
> parameter is historical artifact.
>
> So I'd dare to propose removing it altogether and print those stats
> everytime. Readers of the nested-keys format should survive that.
> (I don't even see the param documented.)
>
> And if there were eager readers that'd be affected performance-wise,
> more conventional would be to make this only boot cmdline parameter that
> could static-branch also the stat collection spots (for some more
> benefit). And then would also a CONFIG_urable default make sense.
>
> WDYT?
That seems to make sense and it also simplify kernel management. I am sending a
V2 with it, let's see if there is any other concern.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-03 13:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04 16:15 [PATCH] blk-cgroup: add CONFIG_BLK_CGROUP_DEBUG_STATS option Breno Leitao
2026-02-12 10:26 ` Michal Koutný
2026-03-03 13:59 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox