blk-mq: move debugging information from sysfs to debugfs
Subsystems (2)
cover blk-mq: move debugging information from sysfs to debugfs
From: Omar Sandoval <[email protected]>
This series ends our abuse of sysfs and puts all of the debugging information in debugfs instead. This has a few benefits:
1. Removes the possibility of userspace being stupid and relying on something in sysfs that we only exposed for debugging.
2. Lifts the limitations of sysfs, including the one-value-per-file convention and maximum of one page of output.
3. Allows us to add more debugging information that we often want but don't have when debugging a live system.
Thanks!
Omar
Omar Sandoval (10):
blk-mq: create debugfs directory tree
blk-mq: add hctx->{state,flags} to debugfs
blk-mq: move hctx->dispatch and ctx->rq_list from sysfs to debugfs
blk-mq: add extra request information to debugfs
sbitmap: add helpers for dumping to a seq_file
blk-mq: export software queue pending map to debugfs
blk-mq: move tags and sched_tags info from sysfs to debugfs
blk-mq: add tags and sched_tags bitmaps to debugfs
blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs
blk-mq: move hctx and ctx counters from sysfs to debugfs
block/Makefile | 1 + block/blk-mq-debugfs.c | 750 ++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 248 ++-------------- block/blk-mq-tag.c | 27 -- block/blk-mq-tag.h | 1 - block/blk-mq.c | 2 + block/blk-mq.h | 33 +++ include/linux/blkdev.h | 5 + include/linux/sbitmap.h | 34 +++ lib/sbitmap.c | 83 ++++++ 10 files changed, 929 insertions(+), 255 deletions(-) create mode 100644 block/blk-mq-debugfs.c
Signature · 1 line
2.11.0
PATCH 1/10 blk-mq: create debugfs directory tree
From: Omar Sandoval <[email protected]>
In preparation for putting blk-mq debugging information in debugfs, create a directory tree mirroring the one in sysfs:
# tree -d /sys/kernel/debug/block
/sys/kernel/debug/block
|-- nvme0n1
| `-- mq
| |-- 0
| | `-- cpu0
| |-- 1
| | `-- cpu1
| |-- 2
| | `-- cpu2
| `-- 3
| `-- cpu3
`-- vda
`-- mq
`-- 0
|-- cpu0
|-- cpu1
|-- cpu2
`-- cpu3Also add the scaffolding for the actual files that will go in here, either under the hardware queue or software queue directories.
--- block/Makefile | 1 + block/blk-mq-debugfs.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 8 +++ block/blk-mq.c | 2 + block/blk-mq.h | 33 +++++++++++ include/linux/blkdev.h | 5 ++ 6 files changed, 201 insertions(+) create mode 100644 block/blk-mq-debugfs.c
block/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o obj-$(CONFIG_BLK_WBT) += blk-wbt.o +obj-$(CONFIG_DEBUG_FS) += blk-mq-debugfs.o
block/blk-mq-debugfs.c new file +152 -0
152 lines not on this page · raw message
block/blk-mq-sysfs.c +8 -0
@@ -468,6 +468,8 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)kobject_put (&hctx->kobj); } +blk_mq_debugfs_unregister (q); +kobject_uevent (&q->mq_kobj,KOBJ_REMOVE );kobject_del (&q->mq_kobj);kobject_put (&q->mq_kobj);
@@ -517,6 +519,8 @@ int blk_mq_register_dev(struct device *dev, struct request_queue *q)kobject_uevent (&q->mq_kobj,KOBJ_ADD ); +blk_mq_debugfs_register (q,kobject_name (&dev->kobj)); +queue_for_each_hw_ctx (q, hctx, i) { ret =blk_mq_register_hctx (hctx);if (ret)
@@ -542,6 +546,8 @@ void blk_mq_sysfs_unregister(struct request_queue *q)if (!q->mq_sysfs_init_done)return ; +blk_mq_debugfs_unregister_hctxs (q); +queue_for_each_hw_ctx (q, hctx, i)blk_mq_unregister_hctx (hctx); }
@@ -554,6 +560,8 @@ int blk_mq_sysfs_register(struct request_queue *q)if (!q->mq_sysfs_init_done)return ret; +blk_mq_debugfs_register_hctxs (q); +queue_for_each_hw_ctx (q, hctx, i) { ret =blk_mq_register_hctx (hctx);if (ret)
block/blk-mq.c +2 -0
@@ -2796,6 +2796,8 @@ void blk_mq_enable_hotplug(void)static int __init blk_mq_init (void ) { +blk_mq_debugfs_init (); +cpuhp_setup_state_multi (CPUHP_BLK_MQ_DEAD ,"block/mq:dead" ,NULL , blk_mq_hctx_notify_dead);
block/blk-mq.h +33 -0
@@ -78,6 +78,39 @@ extern int blk_mq_sysfs_register(struct request_queue *q);extern void blk_mq_sysfs_unregister (struct request_queue *q);extern void blk_mq_hctx_kobj_init (struct blk_mq_hw_ctx *hctx); +/* +* debugfs helpers +*/ +#ifdef CONFIG_DEBUG_FS +void blk_mq_debugfs_init (void ); +int blk_mq_debugfs_register (struct request_queue *q,const char *name); +void blk_mq_debugfs_unregister (struct request_queue *q); +int blk_mq_debugfs_register_hctxs (struct request_queue *q); +void blk_mq_debugfs_unregister_hctxs (struct request_queue *q); +#else +static inline void blk_mq_debugfs_init (void ) +{ +} + +int blk_mq_debugfs_register (struct request_queue *q,const char *name); +{ +return 0 ; +} + +void blk_mq_debugfs_unregister (struct request_queue *q) +{ +} + +int blk_mq_debugfs_register_hctxs (struct request_queue *q) +{ +return 0 ; +} + +void blk_mq_debugfs_unregister_hctxs (struct request_queue *q) +{ +} +#endif +extern void blk_mq_rq_timed_out (struct request *req,bool reserved);void blk_mq_release (struct request_queue *q);
include/linux/blkdev.h +5 -0
@@ -571,6 +571,11 @@ struct request_queue {struct list_head tag_set_list;struct bio_set *bio_split; +#ifdef CONFIG_DEBUG_FS +struct dentry *debugfs_dir; +struct dentry *mq_debugfs_dir; +#endif +bool mq_sysfs_init_done; };
Signature · 1 line
2.11.0
PATCH 2/10 blk-mq: add hctx->{state,flags} to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
hctx->state could come in handy for bugs where the hardware queue gets stuck in the stopped state, and hctx->flags is just useful to know.
--- block/blk-mq-debugfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
block/blk-mq-debugfs.c +42 -0
@@ -29,7 +29,49 @@ struct blk_mq_debugfs_attr {static struct dentry *block_debugfs_root; +static int hctx_state_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"0x%lx\n" , hctx->state); +return 0 ; +} + +static int hctx_state_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_state_show, inode->i_private); +} + +static const struct file_operations hctx_state_fops = { + .open = hctx_state_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int hctx_flags_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"0x%lx\n" , hctx->flags); +return 0 ; +} + +static int hctx_flags_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_flags_show, inode->i_private); +} + +static const struct file_operations hctx_flags_fops = { + .open = hctx_flags_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { + {"state" ,0400 , &hctx_state_fops}, + {"flags" ,0400 , &hctx_flags_fops}, };static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
Signature · 1 line
2.11.0
PATCH 3/10 blk-mq: move hctx->dispatch and ctx->rq_list from sysfs to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
These lists are only useful for debugging; they definitely don't belong in sysfs. Putting them in debugfs also removes the limitation of a single page of output.
--- block/blk-mq-debugfs.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 57 -------------------------- 2 files changed, 106 insertions(+), 57 deletions(-)
block/blk-mq-debugfs.c +106 -0
@@ -29,6 +29,20 @@ struct blk_mq_debugfs_attr {static struct dentry *block_debugfs_root; +static int blk_mq_debugfs_seq_open (struct inode *inode,struct file *file, +const struct seq_operations *ops) +{ +struct seq_file *m; +int ret; + + ret =seq_open (file, ops); +if (!ret) { + m = file->private_data; + m->private = inode->i_private; + } +return ret; +} +static int hctx_state_show (struct seq_file *m,void *v) {struct blk_mq_hw_ctx *hctx = m->private;
@@ -69,12 +83,104 @@ static const struct file_operations hctx_flags_fops = { .release = single_release, }; +static int blk_mq_debugfs_rq_show (struct seq_file *m,void *v) +{ +struct request *rq =list_entry_rq (v); + +seq_printf (m,"%p\n" , rq); +return 0 ; +} + +static void *hctx_dispatch_start (struct seq_file *m,loff_t *pos) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +spin_lock (&hctx->lock); +return seq_list_start (&hctx->dispatch, *pos); +} + +static void *hctx_dispatch_next (struct seq_file *m,void *v,loff_t *pos) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +return seq_list_next (v, &hctx->dispatch, pos); +} + +static void hctx_dispatch_stop (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +spin_unlock (&hctx->lock); +} + +static const struct seq_operations hctx_dispatch_seq_ops = { + .start = hctx_dispatch_start, + .next = hctx_dispatch_next, + .stop = hctx_dispatch_stop, + .show = blk_mq_debugfs_rq_show, +}; + +static int hctx_dispatch_open (struct inode *inode,struct file *file) +{ +return blk_mq_debugfs_seq_open (inode, file, &hctx_dispatch_seq_ops); +} + +static const struct file_operations hctx_dispatch_fops = { + .open = hctx_dispatch_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) +{ +struct blk_mq_ctx *ctx = m->private; + +spin_lock (&ctx->lock); +return seq_list_start (&ctx->rq_list, *pos); +} + +static void *ctx_rq_list_next (struct seq_file *m,void *v,loff_t *pos) +{ +struct blk_mq_ctx *ctx = m->private; + +return seq_list_next (v, &ctx->rq_list, pos); +} + +static void ctx_rq_list_stop (struct seq_file *m,void *v) +{ +struct blk_mq_ctx *ctx = m->private; + +spin_unlock (&ctx->lock); +} + +static const struct seq_operations ctx_rq_list_seq_ops = { + .start = ctx_rq_list_start, + .next = ctx_rq_list_next, + .stop = ctx_rq_list_stop, + .show = blk_mq_debugfs_rq_show, +}; + +static int ctx_rq_list_open (struct inode *inode,struct file *file) +{ +return blk_mq_debugfs_seq_open (inode, file, &ctx_rq_list_seq_ops); +} + +static const struct file_operations ctx_rq_list_fops = { + .open = ctx_rq_list_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; +static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"state" ,0400 , &hctx_state_fops}, {"flags" ,0400 , &hctx_flags_fops}, + {"dispatch" ,0400 , &hctx_dispatch_fops}, };static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { + {"rq_list" ,0400 , &ctx_rq_list_fops}, };int blk_mq_debugfs_register (struct request_queue *q,const char *name)
block/blk-mq-sysfs.c +0 -57
92 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 4/10 blk-mq: add extra request information to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
The request pointers by themselves aren't super useful.
--- block/blk-mq-debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-mq-debugfs.c +3 -1
@@ -87,7 +87,9 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v) {struct request *rq =list_entry_rq (v); -seq_printf (m,"%p\n" , rq); +seq_printf (m,"%p {.cmd_type=%u, .cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n" , + rq, rq->cmd_type, rq->cmd_flags, (unsigned int )rq->rq_flags, + rq->tag, rq->internal_tag);return 0 ; }
Signature · 1 line
2.11.0
PATCH 5/10 sbitmap: add helpers for dumping to a seq_file
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
This is useful debugging information that will be used in the blk-mq debugfs directory.
--- include/linux/sbitmap.h | 34 ++++++++++++++++++++ lib/sbitmap.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+)
include/linux/sbitmap.h +34 -0
@@ -259,6 +259,29 @@ static inline int sbitmap_test_bit(struct sbitmap *sb, unsigned int bitnr)unsigned int sbitmap_weight (const struct sbitmap *sb);/** +* sbitmap_show() - Dump bitmap information to a struct seq_file. +* @m: struct seq_file to write to. +* @v: Bitmap to show. +* +* Return: Zero. +* +* This is intended for debugging. The format may change at any time. +*/ +int sbitmap_show (struct seq_file *m,void *v); + +/** +* sbitmap_bitmap_show() - Dump the raw bitmap to a struct seq_file. +* @m: struct seq_file to write to. +* @v: Bitmap to show. +* +* Return: Zero. +* +* This is intended for debugging. The output isn't guaranteed to be internally +* consistent. +*/ +int sbitmap_bitmap_show (struct seq_file *m,void *v); + +/** * sbitmap_queue_init_node() - Initialize a &struct sbitmap_queue on a specific * memory node. * @sbq: Bitmap queue to initialize.
@@ -370,4 +393,15 @@ static inline struct sbq_wait_state *sbq_wait_ptr(struct sbitmap_queue *sbq,*/ void sbitmap_queue_wake_all (struct sbitmap_queue *sbq); +/** +* sbitmap_queue_show() - Dump bitmap queue information to a struct seq_file. +* @m: struct seq_file to write to. +* @v: Bitmap queue to show. +* +* Return: Zero. +* +* This is intended for debugging. The format may change at any time. +*/ +int sbitmap_queue_show (struct seq_file *m,void *v); +#endif /* __LINUX_SCALE_BITMAP_H */
lib/sbitmap.c +83 -0
98 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 6/10 blk-mq: export software queue pending map to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
This is useful for debugging problems where we've gotten stuck with requests in the software queues.
--- block/blk-mq-debugfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
block/blk-mq-debugfs.c +15 -0
@@ -134,6 +134,20 @@ static const struct file_operations hctx_dispatch_fops = { .release = seq_release, }; +static int hctx_ctx_map_open (struct inode *inode,struct file *file) +{ +struct blk_mq_hw_ctx *hctx = inode->i_private; + +return single_open (file, sbitmap_bitmap_show, &hctx->ctx_map); +} + +static const struct file_operations hctx_ctx_map_fops = { + .open = hctx_ctx_map_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) {struct blk_mq_ctx *ctx = m->private;
@@ -179,6 +193,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"state", 0400, &hctx_state_fops}, {"flags", 0400, &hctx_flags_fops}, {"dispatch", 0400, &hctx_dispatch_fops}, + {"ctx_map", 0400, &hctx_ctx_map_fops}, }; static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
Signature · 1 line
2.11.0
PATCH 7/10 blk-mq: move tags and sched_tags info from sysfs to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
These are very tied to the blk-mq tag implementation, so exposing them to sysfs isn't a great idea. Move the debugging information to debugfs and add basic entries for the number of tags and the number of reserved tags to sysfs.
--- block/blk-mq-debugfs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 33 ++++++++++++------------ block/blk-mq-tag.c | 27 ------------------- block/blk-mq-tag.h | 1 - 4 files changed, 86 insertions(+), 45 deletions(-)
block/blk-mq-debugfs.c +70 -0
@@ -20,6 +20,7 @@#include <linux/blk-mq.h> #include "blk-mq.h" +#include "blk-mq-tag.h" struct blk_mq_debugfs_attr {const char *name;
@@ -148,6 +149,73 @@ static const struct file_operations hctx_ctx_map_fops = { .release = single_release, }; +static void blk_mq_debugfs_tags_show (struct seq_file *m, +struct blk_mq_tags *tags) +{ +seq_printf (m,"nr_tags=%u\n" , tags->nr_tags); +seq_printf (m,"nr_reserved_tags=%u\n" , tags->nr_reserved_tags); +seq_printf (m,"active_queues=%d\n" , +atomic_read (&tags->active_queues)); + +seq_puts (m,"\nbitmap_tags:\n" ); +sbitmap_queue_show (m, &tags->bitmap_tags); + +if (tags->nr_reserved_tags) { +seq_puts (m,"\nbreserved_tags:\n" ); +sbitmap_queue_show (m, &tags->breserved_tags); + } +} + +static int hctx_tags_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +struct request_queue *q = hctx->queue; + +mutex_lock (&q->sysfs_lock); +if (hctx->tags) +blk_mq_debugfs_tags_show (m, hctx->tags); +mutex_unlock (&q->sysfs_lock); + +return 0 ; +} + +static int hctx_tags_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_tags_show, inode->i_private); +} + +static const struct file_operations hctx_tags_fops = { + .open = hctx_tags_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int hctx_sched_tags_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +struct request_queue *q = hctx->queue; + +mutex_lock (&q->sysfs_lock); +if (hctx->sched_tags) +blk_mq_debugfs_tags_show (m, hctx->sched_tags); +mutex_unlock (&q->sysfs_lock); + +return 0 ; +} + +static int hctx_sched_tags_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_sched_tags_show, inode->i_private); +} + +static const struct file_operations hctx_sched_tags_fops = { + .open = hctx_sched_tags_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) {struct blk_mq_ctx *ctx = m->private;
@@ -194,6 +262,8 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"flags", 0400, &hctx_flags_fops}, {"dispatch", 0400, &hctx_dispatch_fops}, {"ctx_map", 0400, &hctx_ctx_map_fops}, + {"tags", 0400, &hctx_tags_fops}, + {"sched_tags", 0400, &hctx_sched_tags_fops}, }; static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
block/blk-mq-sysfs.c +16 -17
@@ -184,17 +184,16 @@ static ssize_t blk_mq_hw_sysfs_dispatched_show(struct blk_mq_hw_ctx *hctx,return page - start_page; } -static ssize_t blk_mq_hw_sysfs_sched_tags_show (struct blk_mq_hw_ctx *hctx,char *page) +static ssize_t blk_mq_hw_sysfs_nr_tags_show (struct blk_mq_hw_ctx *hctx, +char *page) { -if (hctx->sched_tags) -return blk_mq_tag_sysfs_show (hctx->sched_tags, page); - -return 0 ; +return sprintf (page,"%u\n" , hctx->tags->nr_tags); } -static ssize_t blk_mq_hw_sysfs_tags_show (struct blk_mq_hw_ctx *hctx,char *page) +static ssize_t blk_mq_hw_sysfs_nr_reserved_tags_show (struct blk_mq_hw_ctx *hctx, +char *page) { -return blk_mq_tag_sysfs_show (hctx->tags, page); +return sprintf (page,"%u\n" , hctx->tags->nr_reserved_tags); }static ssize_t blk_mq_hw_sysfs_active_show (struct blk_mq_hw_ctx *hctx,char *page)
@@ -293,18 +292,18 @@ static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_dispatched = { .attr = {.name = "dispatched", .mode = S_IRUGO }, .show = blk_mq_hw_sysfs_dispatched_show, }; +static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = { + .attr = {.name ="nr_tags" , .mode =S_IRUGO }, + .show = blk_mq_hw_sysfs_nr_tags_show, +}; +static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_reserved_tags = { + .attr = {.name ="nr_reserved_tags" , .mode =S_IRUGO }, + .show = blk_mq_hw_sysfs_nr_reserved_tags_show, +};static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_active = { .attr = {.name ="active" , .mode =S_IRUGO }, .show = blk_mq_hw_sysfs_active_show, }; -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_sched_tags = { - .attr = {.name ="sched_tags" , .mode =S_IRUGO }, - .show = blk_mq_hw_sysfs_sched_tags_show, -}; -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_tags = { - .attr = {.name ="tags" , .mode =S_IRUGO }, - .show = blk_mq_hw_sysfs_tags_show, -};static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = { .attr = {.name ="cpu_list" , .mode =S_IRUGO }, .show = blk_mq_hw_sysfs_cpus_show,
@@ -324,8 +323,8 @@ static struct attribute *default_hw_ctx_attrs[] = { &blk_mq_hw_sysfs_queued.attr, &blk_mq_hw_sysfs_run.attr, &blk_mq_hw_sysfs_dispatched.attr, - &blk_mq_hw_sysfs_tags.attr, - &blk_mq_hw_sysfs_sched_tags.attr, + &blk_mq_hw_sysfs_nr_tags.attr, + &blk_mq_hw_sysfs_nr_reserved_tags.attr, &blk_mq_hw_sysfs_cpus.attr, &blk_mq_hw_sysfs_active.attr, &blk_mq_hw_sysfs_poll.attr,
block/blk-mq-tag.c +0 -27
@@ -327,11 +327,6 @@ void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, } -static unsigned int bt_unused_tags (const struct sbitmap_queue *bt) -{ -return bt->sb.depth -sbitmap_weight (&bt->sb); -} -static int bt_alloc (struct sbitmap_queue *bt,unsigned int depth,bool round_robin,int node) {
@@ -467,25 +462,3 @@ u32 blk_mq_unique_tag(struct request *rq) (rq->tag &BLK_MQ_UNIQUE_TAG_MASK ); }EXPORT_SYMBOL (blk_mq_unique_tag); - -ssize_t blk_mq_tag_sysfs_show (struct blk_mq_tags *tags,char *page) -{ -char *orig_page = page; -unsigned int free, res; - -if (!tags) -return 0 ; - - page +=sprintf (page,"nr_tags=%u, reserved_tags=%u, " -"bits_per_word=%u\n" , - tags->nr_tags, tags->nr_reserved_tags, -1U << tags->bitmap_tags.sb.shift); - - free =bt_unused_tags (&tags->bitmap_tags); - res =bt_unused_tags (&tags->breserved_tags); - - page +=sprintf (page,"nr_free=%u, nr_reserved=%u\n" , free, res); - page +=sprintf (page,"active_queues=%u\n" ,atomic_read (&tags->active_queues)); - -return page - orig_page; -}
block/blk-mq-tag.h +0 -1
@@ -28,7 +28,6 @@ extern unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data);extern void blk_mq_put_tag (struct blk_mq_hw_ctx *hctx,struct blk_mq_tags *tags,struct blk_mq_ctx *ctx,unsigned int tag);extern bool blk_mq_has_free_tags (struct blk_mq_tags *tags); -extern ssize_t blk_mq_tag_sysfs_show (struct blk_mq_tags *tags,char *page);extern int blk_mq_tag_update_depth (struct blk_mq_hw_ctx *hctx,struct blk_mq_tags **tags,unsigned int depth,bool can_grow);
Signature · 1 line
2.11.0
PATCH 8/10 blk-mq: add tags and sched_tags bitmaps to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
These can be used to debug issues like tag leaks and stuck requests.
--- block/blk-mq-debugfs.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
block/blk-mq-debugfs.c +50 -0
@@ -191,6 +191,30 @@ static const struct file_operations hctx_tags_fops = { .release = single_release, }; +static int hctx_tags_bitmap_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +struct request_queue *q = hctx->queue; + +mutex_lock (&q->sysfs_lock); +if (hctx->tags) +sbitmap_bitmap_show (m, &hctx->tags->bitmap_tags.sb); +mutex_unlock (&q->sysfs_lock); +return 0 ; +} + +static int hctx_tags_bitmap_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_tags_bitmap_show, inode->i_private); +} + +static const struct file_operations hctx_tags_bitmap_fops = { + .open = hctx_tags_bitmap_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static int hctx_sched_tags_show (struct seq_file *m,void *v) {struct blk_mq_hw_ctx *hctx = m->private;
@@ -216,6 +240,30 @@ static const struct file_operations hctx_sched_tags_fops = { .release = single_release, }; +static int hctx_sched_tags_bitmap_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +struct request_queue *q = hctx->queue; + +mutex_lock (&q->sysfs_lock); +if (hctx->sched_tags) +sbitmap_bitmap_show (m, &hctx->sched_tags->bitmap_tags.sb); +mutex_unlock (&q->sysfs_lock); +return 0 ; +} + +static int hctx_sched_tags_bitmap_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_sched_tags_bitmap_show, inode->i_private); +} + +static const struct file_operations hctx_sched_tags_bitmap_fops = { + .open = hctx_sched_tags_bitmap_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) {struct blk_mq_ctx *ctx = m->private;
@@ -263,7 +311,9 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"dispatch", 0400, &hctx_dispatch_fops}, {"ctx_map", 0400, &hctx_ctx_map_fops}, {"tags", 0400, &hctx_tags_fops}, + {"tags_bitmap", 0400, &hctx_tags_bitmap_fops}, {"sched_tags", 0400, &hctx_sched_tags_fops}, + {"sched_tags_bitmap", 0400, &hctx_sched_tags_bitmap_fops}, }; static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
Signature · 1 line
2.11.0
PATCH 9/10 blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
These statistics _might_ be useful to userspace, but it's better not to commit to an ABI for these yet. Also, the dispatched file in sysfs couldn't be cleared, so make it clearable like the others in debugfs.
--- block/blk-mq-debugfs.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 92 ---------------------------------- 2 files changed, 132 insertions(+), 92 deletions(-)
block/blk-mq-debugfs.c +132 -0
@@ -264,6 +264,135 @@ static const struct file_operations hctx_sched_tags_bitmap_fops = { .release = single_release, }; +static int hctx_io_poll_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"considered=%lu\n" , hctx->poll_considered); +seq_printf (m,"invoked=%lu\n" , hctx->poll_invoked); +seq_printf (m,"success=%lu\n" , hctx->poll_success); +return 0 ; +} + +static int hctx_io_poll_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_io_poll_show, inode->i_private); +} + +static ssize_t hctx_io_poll_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_hw_ctx *hctx = m->private; + + hctx->poll_considered = hctx->poll_invoked = hctx->poll_success =0 ; +return count; +} + +static const struct file_operations hctx_io_poll_fops = { + .open = hctx_io_poll_open, + .read = seq_read, + .write = hctx_io_poll_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static void print_stat (struct seq_file *m,struct blk_rq_stat *stat) +{ +seq_printf (m,"samples=%d, mean=%lld, min=%llu, max=%llu" , + stat->nr_samples, stat->mean, stat->min, stat->max); +} + +static int hctx_stats_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +struct blk_rq_stat stat[2 ]; + +blk_stat_init (&stat[BLK_STAT_READ ]); +blk_stat_init (&stat[BLK_STAT_WRITE ]); + +blk_hctx_stat_get (hctx, stat); + +seq_puts (m,"read: " ); +print_stat (m, &stat[BLK_STAT_READ ]); +seq_puts (m,"\n" ); + +seq_puts (m,"write: " ); +print_stat (m, &stat[BLK_STAT_WRITE ]); +seq_puts (m,"\n" ); +return 0 ; +} + +static int hctx_stats_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_stats_show, inode->i_private); +} + +static ssize_t hctx_stats_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_hw_ctx *hctx = m->private; +struct blk_mq_ctx *ctx; +int i; + +hctx_for_each_ctx (hctx, ctx, i) { +blk_stat_init (&ctx->stat[BLK_STAT_READ ]); +blk_stat_init (&ctx->stat[BLK_STAT_WRITE ]); + } +return count; +} + +static const struct file_operations hctx_stats_fops = { + .open = hctx_stats_open, + .read = seq_read, + .write = hctx_stats_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static int hctx_dispatched_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; +int i; + +seq_printf (m,"%8u\t%lu\n" ,0U , hctx->dispatched[0 ]); + +for (i =1 ; i <BLK_MQ_MAX_DISPATCH_ORDER -1 ; i++) { +unsigned int d =1U << (i -1 ); + +seq_printf (m,"%8u\t%lu\n" , d, hctx->dispatched[i]); + } + +seq_printf (m,"%8u+\t%lu\n" ,1U << (i -1 ), hctx->dispatched[i]); +return 0 ; +} + +static int hctx_dispatched_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_dispatched_show, inode->i_private); +} + +static ssize_t hctx_dispatched_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_hw_ctx *hctx = m->private; +int i; + +for (i =0 ; i <BLK_MQ_MAX_DISPATCH_ORDER ; i++) + hctx->dispatched[i] =0 ; +return count; +} + +static const struct file_operations hctx_dispatched_fops = { + .open = hctx_dispatched_open, + .read = seq_read, + .write = hctx_dispatched_write, + .llseek = seq_lseek, + .release = single_release, +}; +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) {struct blk_mq_ctx *ctx = m->private;
@@ -314,6 +443,9 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"tags_bitmap", 0400, &hctx_tags_bitmap_fops}, {"sched_tags", 0400, &hctx_sched_tags_fops}, {"sched_tags_bitmap", 0400, &hctx_sched_tags_bitmap_fops}, + {"io_poll", 0600, &hctx_io_poll_fops}, + {"stats", 0600, &hctx_stats_fops}, + {"dispatched", 0600, &hctx_dispatched_fops}, }; static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
block/blk-mq-sysfs.c +0 -92
130 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 10/10 blk-mq: move hctx and ctx counters from sysfs to debugfs
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
These counters aren't as out-of-place in sysfs as the other stuff, but debugfs is a slightly better home for them.
--- block/blk-mq-debugfs.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 64 ----------------- 2 files changed, 181 insertions(+), 64 deletions(-)
block/blk-mq-debugfs.c +181 -0
@@ -393,6 +393,88 @@ static const struct file_operations hctx_dispatched_fops = { .release = single_release, }; +static int hctx_queued_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"%lu\n" , hctx->queued); +return 0 ; +} + +static int hctx_queued_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_queued_show, inode->i_private); +} + +static ssize_t hctx_queued_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_hw_ctx *hctx = m->private; + + hctx->queued =0 ; +return count; +} + +static const struct file_operations hctx_queued_fops = { + .open = hctx_queued_open, + .read = seq_read, + .write = hctx_queued_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static int hctx_run_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"%lu\n" , hctx->run); +return 0 ; +} + +static int hctx_run_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_run_show, inode->i_private); +} + +static ssize_t hctx_run_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_hw_ctx *hctx = m->private; + + hctx->run =0 ; +return count; +} + +static const struct file_operations hctx_run_fops = { + .open = hctx_run_open, + .read = seq_read, + .write = hctx_run_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static int hctx_active_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"%d\n" ,atomic_read (&hctx->nr_active)); +return 0 ; +} + +static int hctx_active_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_active_show, inode->i_private); +} + +static const struct file_operations hctx_active_fops = { + .open = hctx_active_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static void *ctx_rq_list_start (struct seq_file *m,loff_t *pos) {struct blk_mq_ctx *ctx = m->private;
@@ -434,6 +516,99 @@ static const struct file_operations ctx_rq_list_fops = { .release = seq_release, }; +static int ctx_dispatched_show (struct seq_file *m,void *v) +{ +struct blk_mq_ctx *ctx = m->private; + +seq_printf (m,"%lu %lu\n" , ctx->rq_dispatched[1 ], ctx->rq_dispatched[0 ]); +return 0 ; +} + +static int ctx_dispatched_open (struct inode *inode,struct file *file) +{ +return single_open (file, ctx_dispatched_show, inode->i_private); +} + +static ssize_t ctx_dispatched_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_ctx *ctx = m->private; + + ctx->rq_dispatched[0 ] = ctx->rq_dispatched[1 ] =0 ; +return count; +} + +static const struct file_operations ctx_dispatched_fops = { + .open = ctx_dispatched_open, + .read = seq_read, + .write = ctx_dispatched_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static int ctx_merged_show (struct seq_file *m,void *v) +{ +struct blk_mq_ctx *ctx = m->private; + +seq_printf (m,"%lu\n" , ctx->rq_merged); +return 0 ; +} + +static int ctx_merged_open (struct inode *inode,struct file *file) +{ +return single_open (file, ctx_merged_show, inode->i_private); +} + +static ssize_t ctx_merged_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_ctx *ctx = m->private; + + ctx->rq_merged =0 ; +return count; +} + +static const struct file_operations ctx_merged_fops = { + .open = ctx_merged_open, + .read = seq_read, + .write = ctx_merged_write, + .llseek = seq_lseek, + .release = single_release, +}; + +static int ctx_completed_show (struct seq_file *m,void *v) +{ +struct blk_mq_ctx *ctx = m->private; + +seq_printf (m,"%lu %lu\n" , ctx->rq_completed[1 ], ctx->rq_completed[0 ]); +return 0 ; +} + +static int ctx_completed_open (struct inode *inode,struct file *file) +{ +return single_open (file, ctx_completed_show, inode->i_private); +} + +static ssize_t ctx_completed_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct seq_file *m = file->private_data; +struct blk_mq_ctx *ctx = m->private; + + ctx->rq_completed[0 ] = ctx->rq_completed[1 ] =0 ; +return count; +} + +static const struct file_operations ctx_completed_fops = { + .open = ctx_completed_open, + .read = seq_read, + .write = ctx_completed_write, + .llseek = seq_lseek, + .release = single_release, +}; +static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"state" ,0400 , &hctx_state_fops}, {"flags" ,0400 , &hctx_flags_fops},
@@ -446,10 +621,16 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"io_poll", 0600, &hctx_io_poll_fops}, {"stats", 0600, &hctx_stats_fops}, {"dispatched", 0600, &hctx_dispatched_fops}, + {"queued", 0600, &hctx_queued_fops}, + {"run", 0600, &hctx_run_fops}, + {"active", 0400, &hctx_active_fops}, };static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { {"rq_list" ,0400 , &ctx_rq_list_fops}, + {"dispatched" ,0600 , &ctx_dispatched_fops}, + {"merged" ,0600 , &ctx_merged_fops}, + {"completed" ,0600 , &ctx_completed_fops}, };int blk_mq_debugfs_register (struct request_queue *q,const char *name)
block/blk-mq-sysfs.c +0 -64
101 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 01/10] blk-mq: create debugfs directory tree
In reply to Omar SandovalQuoted 29 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
In preparation for putting blk-mq debugging information in debugfs, create a directory tree mirroring the one in sysfs:
# tree -d /sys/kernel/debug/block /sys/kernel/debug/block |-- nvme0n1 | `-- mq | |-- 0 | | `-- cpu0 | |-- 1 | | `-- cpu1 | |-- 2 | | `-- cpu2 | `-- 3 | `-- cpu3 `-- vda `-- mq `-- 0 |-- cpu0 |-- cpu1 |-- cpu2 `-- cpu3Also add the scaffolding for the actual files that will go in here, either under the hardware queue or software queue directories.
Signed-off-by Omar Sandoval <[email protected]>
Quoted 10 lines
--- block/Makefile | 1 + block/blk-mq-debugfs.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 8 +++ block/blk-mq.c | 2 + block/blk-mq.h | 33 +++++++++++ include/linux/blkdev.h | 5 ++ 6 files changed, 201 insertions(+) create mode 100644 block/blk-mq-debugfs.c
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 02/10] blk-mq: add hctx->{state,flags} to debugfs
In reply to Omar SandovalQuoted 10 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
hctx->statecould come in handy for bugs where the hardware queue gets stuck in the stopped state, andhctx->flagsis just useful to know.Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
Hehe. I've found myself adding exactly the same attributes when debugging mq-deadline :-)
Quoted 6 lines
block/blk-mq-debugfs.c +0
-0@@ -29,7 +29,49 @@ struct blk_mq_debugfs_attr {
block/blk-mq-debugfs.c struct blk_mq_debugfs_attr { · line 39
Quoted 10 lines
block/blk-mq-debugfs.c +8
-0static struct dentry *block_debugfs_root; +static int hctx_state_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"0x%lx\n" , hctx->state); +return 0 ; +} +
What about decoding it?
Would make life so much easier, and one doesn't have to have a kernel source tree available when looking things up...
Quoted 10 lines
block/blk-mq-debugfs.c +10
-0+static int hctx_state_open (struct inode *inode,struct file *file) +{ +return single_open (file, hctx_state_show, inode->i_private); +} + +static const struct file_operations hctx_state_fops = { + .open = hctx_state_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release,
block/blk-mq-debugfs.c struct blk_mq_debugfs_attr { · line 59
Quoted 10 lines
block/blk-mq-debugfs.c +10
-0+}; + +static int hctx_flags_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"0x%lx\n" , hctx->flags); +return 0 ; +} +
Same argument here.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 03/10] blk-mq: move hctx->dispatch and ctx->rq_list from sysfs to debugfs
In reply to Omar SandovalQuoted 6 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These lists are only useful for debugging; they definitely don't belong in sysfs. Putting them in debugfs also removes the limitation of a single page of output.
Quoted 6 lines
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 57 -------------------------- 2 files changed, 106 insertions(+), 57 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 04/10] blk-mq: add extra request information to debugfs
In reply to Omar SandovalQuoted 15 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
The request pointers by themselves aren't super useful.
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)block/blk-mq-debugfs.c +0
-0
block/blk-mq-debugfs.c static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v) · line 95
Quoted 10 lines
block/blk-mq-debugfs.c +3
-1@@ -87,7 +87,9 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v) {struct request *rq =list_entry_rq (v); -seq_printf (m,"%p\n" , rq); +seq_printf (m,"%p {.cmd_type=%u, .cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n" , + rq, rq->cmd_type, rq->cmd_flags, (unsigned int )rq->rq_flags, + rq->tag, rq->internal_tag);return 0 ; }
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 05/10] sbitmap: add helpers for dumping to a seq_file
In reply to Omar SandovalQuoted 11 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
This is useful debugging information that will be used in the blk-mq debugfs directory.
Signed-off-by Omar Sandoval <[email protected]>--- include/linux/sbitmap.h | 34 ++++++++++++++++++++ lib/sbitmap.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 06/10] blk-mq: export software queue pending map to debugfs
In reply to Omar SandovalQuoted 10 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
This is useful for debugging problems where we've gotten stuck with requests in the software queues.
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 07/10] blk-mq: move tags and sched_tags info from sysfs to debugfs
In reply to Omar SandovalQuoted 7 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These are very tied to the blk-mq tag implementation, so exposing them to sysfs isn't a great idea. Move the debugging information to debugfs and add basic entries for the number of tags and the number of reserved tags to sysfs.
Quoted 8 lines
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 33 ++++++++++++------------ block/blk-mq-tag.c | 27 ------------------- block/blk-mq-tag.h | 1 - 4 files changed, 86 insertions(+), 45 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 08/10] blk-mq: add tags and sched_tags bitmaps to debugfs
In reply to Omar SandovalQuoted 9 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These can be used to debug issues like tag leaks and stuck requests.
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 09/10] blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs
In reply to Omar SandovalQuoted 6 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These statistics _might_ be useful to userspace, but it's better not to commit to an ABI for these yet. Also, the dispatched file in sysfs couldn't be cleared, so make it clearable like the others in debugfs.
Quoted 6 lines
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 92 ---------------------------------- 2 files changed, 132 insertions(+), 92 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 10/10] blk-mq: move hctx and ctx counters from sysfs to debugfs
In reply to Omar SandovalQuoted 11 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These counters aren't as out-of-place in sysfs as the other stuff, but debugfs is a slightly better home for them.
Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-mq-sysfs.c | 64 ----------------- 2 files changed, 181 insertions(+), 64 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N�rnberg)
Re: [PATCH 02/10] blk-mq: add hctx->{state,flags} to debugfs
In reply to Hannes ReineckeQuoted 22 lines · Hannes Reinecke
Quoted 10 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
hctx->statecould come in handy for bugs where the hardware queue gets stuck in the stopped state, andhctx->flagsis just useful to know.Signed-off-by Omar Sandoval <[email protected]>--- block/blk-mq-debugfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)Hehe. I've found myself adding exactly the same attributes when debugging mq-deadline :-)
Quoted 8 lines
block/blk-mq-debugfs.c +0
-0@@ -29,7 +29,49 @@ struct blk_mq_debugfs_attr {static struct dentry *block_debugfs_root;
Quoted 11 lines
block/blk-mq-debugfs.c struct blk_mq_debugfs_attr { · line 39
Quoted 8 lines
block/blk-mq-debugfs.c +8
-0+static int hctx_state_show (struct seq_file *m,void *v) +{ +struct blk_mq_hw_ctx *hctx = m->private; + +seq_printf (m,"0x%lx\n" , hctx->state); +return 0 ; +} +What about decoding it?
Would make life so much easier, and one doesn't have to have a kernel source tree available when looking things up...
I thought of this, too, but doing that would require setting up a mapping from flag values to strings and keeping those in sync with the actual flags, which I don't think is worth the trouble, since I imagine that most of the time you're going to be consulting the source to debug this kind of issue, anyways.
Thanks for the review!