linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: Fix wbt can not be enabled.
@ 2025-08-12 11:43 Julian Sun
  2025-08-12 14:02 ` Nilay Shroff
  0 siblings, 1 reply; 2+ messages in thread
From: Julian Sun @ 2025-08-12 11:43 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, nilay, ming.lei, Julian Sun

The commit 245618f8e45f ("block: protect wbt_lat_usec using q->elevator_lock")
protected wbt_enable_default() with q->elevator_lock; however, it
also placed wbt_enable_default() before blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);,
resulting in wbt failing to be enabled.

Moreover, the protection of wbt_enable_default() by q->elevator_lock was
removed in commit 78c271344b6f ("block: move wbt_enable_default() out of queue freezing from sched ->exit()"),
so we can directly fix this issue by placing wbt_enable_default()
after blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);.

Additionally, this issue also causes the inability to read the
wbt_lat_usec file, and the scenario is as follows:

root@q:/sys/block/sda/queue# cat wbt_lat_usec
cat: wbt_lat_usec: Invalid argument

root@q:/data00/sjc/linux# ls /sys/kernel/debug/block/sda/rqos
ls: cannot access '/sys/kernel/debug/block/sda/rqos': No such file or directory

root@q:/data00/sjc/linux# find /sys -name wbt
/sys/kernel/debug/tracing/events/wbt

After testing with this patch, wbt can be enabled normally.

Signed-off-by: Julian Sun <sunjunchao@bytedance.com>
---
 block/blk-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index c611444480b3..eaa56040ae0f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -877,9 +877,9 @@ int blk_register_queue(struct gendisk *disk)
 
 	if (queue_is_mq(q))
 		elevator_set_default(q);
-	wbt_enable_default(disk);
 
 	blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
+	wbt_enable_default(disk);
 
 	/* Now everything is ready and send out KOBJ_ADD uevent */
 	kobject_uevent(&disk->queue_kobj, KOBJ_ADD);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: Fix wbt can not be enabled.
  2025-08-12 11:43 [PATCH] block: Fix wbt can not be enabled Julian Sun
@ 2025-08-12 14:02 ` Nilay Shroff
  0 siblings, 0 replies; 2+ messages in thread
From: Nilay Shroff @ 2025-08-12 14:02 UTC (permalink / raw)
  To: Julian Sun, linux-block; +Cc: axboe, ming.lei, Julian Sun



On 8/12/25 5:13 PM, Julian Sun wrote:
> The commit 245618f8e45f ("block: protect wbt_lat_usec using q->elevator_lock")
> protected wbt_enable_default() with q->elevator_lock; however, it
> also placed wbt_enable_default() before blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);,
> resulting in wbt failing to be enabled.
> 
> Moreover, the protection of wbt_enable_default() by q->elevator_lock was
> removed in commit 78c271344b6f ("block: move wbt_enable_default() out of queue freezing from sched ->exit()"),
> so we can directly fix this issue by placing wbt_enable_default()
> after blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);.
> 
> Additionally, this issue also causes the inability to read the
> wbt_lat_usec file, and the scenario is as follows:
> 
> root@q:/sys/block/sda/queue# cat wbt_lat_usec
> cat: wbt_lat_usec: Invalid argument
> 
> root@q:/data00/sjc/linux# ls /sys/kernel/debug/block/sda/rqos
> ls: cannot access '/sys/kernel/debug/block/sda/rqos': No such file or directory
> 
> root@q:/data00/sjc/linux# find /sys -name wbt
> /sys/kernel/debug/tracing/events/wbt
> 
> After testing with this patch, wbt can be enabled normally.
> 
> Signed-off-by: Julian Sun <sunjunchao@bytedance.com>

I think you need to wrap the commit description so that it doesn't
cross over 72 lines. I see there are few overly long lines in the 
commit. Also you should consider adding fixes tag in the commit 
so that it could be backported to stable kernels. 

I'd also suggest to update the commit header as follows:
block: restore default wbt enablement

Otherwise changes look good to me.

Thanks,
--Nilay

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-12 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 11:43 [PATCH] block: Fix wbt can not be enabled Julian Sun
2025-08-12 14:02 ` Nilay Shroff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).