]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
blk-mq: move tags and sched_tags info from sysfs to debugfs
authorOmar Sandoval <osandov@fb.com>
Wed, 25 Jan 2017 16:06:46 +0000 (08:06 -0800)
committerJens Axboe <axboe@fb.com>
Fri, 27 Jan 2017 15:17:44 +0000 (08:17 -0700)
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.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq-debugfs.c
block/blk-mq-sysfs.c
block/blk-mq-tag.c
block/blk-mq-tag.h

index 857bdadc6b1f367e36e4634c0709dae18392d1ba..9f811007cf4f6d678d593f5bd6f566231a934419 100644 (file)
@@ -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;
@@ -154,6 +155,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(&tags->bitmap_tags, m);
+
+       if (tags->nr_reserved_tags) {
+               seq_puts(m, "\nbreserved_tags:\n");
+               sbitmap_queue_show(&tags->breserved_tags, m);
+       }
+}
+
+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;
@@ -200,6 +268,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[] = {
index ee3694d8c4ee2d21f4bf81f93a04c3e7e0e440d9..a0ae1f536ed078b9049f9ea1556a97f12b3b3610 100644 (file)
@@ -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,
index 1b156ca79af62f2f66d77f4611b4de23a619b89b..f8de2dbbb29fcba85bc0fc26b8bad85624f86114 100644 (file)
@@ -329,11 +329,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)
 {
@@ -469,25 +464,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;
-}
index ac22878462e7a8516b81c03b5ca0ad10e3d21d5c..63497423c5cd32fb50542cf626590693c5f929e7 100644 (file)
@@ -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);