blk-mq: don't dump CPU -> hw queue map on driver load
authorJens Axboe <axboe@fb.com>
Thu, 20 Mar 2014 19:29:18 +0000 (13:29 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 20 Mar 2014 19:31:44 +0000 (13:31 -0600)
Now that we are out of initial debug/bringup mode, remove
the verbose dump of the mapping table.

Provide the mapping table in sysfs, under the hardware queue
directory, in the cpu_list file.

Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq-cpumap.c
block/blk-mq-sysfs.c
block/blk-mq.c
block/blk-mq.h

index f8721278601c1357c000de40b69c3a31d05a61e7..09792132961991e8168c2dee283a7b0cb0b967d0 100644 (file)
@@ -9,15 +9,6 @@
 #include "blk.h"
 #include "blk-mq.h"
 
-static void show_map(unsigned int *map, unsigned int nr)
-{
-       int i;
-
-       pr_info("blk-mq: CPU -> queue map\n");
-       for_each_online_cpu(i)
-               pr_info("  CPU%2u -> Queue %u\n", i, map[i]);
-}
-
 static int cpu_to_queue_index(unsigned int nr_cpus, unsigned int nr_queues,
                              const int cpu)
 {
@@ -85,7 +76,6 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues)
                        map[i] = map[first_sibling];
        }
 
-       show_map(map, nr_cpus);
        free_cpumask_var(cpus);
        return 0;
 }
index b91ce75bd35db9e00edb4c4af0a0e3036fd66df8..b0ba264b05225ca2432a9a86878cf9501efa2265 100644 (file)
@@ -244,6 +244,32 @@ static ssize_t blk_mq_hw_sysfs_tags_show(struct blk_mq_hw_ctx *hctx, char *page)
        return blk_mq_tag_sysfs_show(hctx->tags, page);
 }
 
+static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
+{
+       unsigned int i, queue_num, first = 1;
+       ssize_t ret = 0;
+
+       blk_mq_disable_hotplug();
+
+       for_each_online_cpu(i) {
+               queue_num = hctx->queue->mq_map[i];
+               if (queue_num != hctx->queue_num)
+                       continue;
+
+               if (first)
+                       ret += sprintf(ret + page, "%u", i);
+               else
+                       ret += sprintf(ret + page, ", %u", i);
+
+               first = 0;
+       }
+
+       blk_mq_enable_hotplug();
+
+       ret += sprintf(ret + page, "\n");
+       return ret;
+}
+
 static struct blk_mq_ctx_sysfs_entry blk_mq_sysfs_dispatched = {
        .attr = {.name = "dispatched", .mode = S_IRUGO },
        .show = blk_mq_sysfs_dispatched_show,
@@ -294,6 +320,10 @@ 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,
+};
 
 static struct attribute *default_hw_ctx_attrs[] = {
        &blk_mq_hw_sysfs_queued.attr,
@@ -302,6 +332,7 @@ static struct attribute *default_hw_ctx_attrs[] = {
        &blk_mq_hw_sysfs_pending.attr,
        &blk_mq_hw_sysfs_ipi.attr,
        &blk_mq_hw_sysfs_tags.attr,
+       &blk_mq_hw_sysfs_cpus.attr,
        NULL,
 };
 
index ed216f27e3b8ef79c7dd2c8728ccf043f7426ca8..3b1c425a935ee76c72d1edb7f8782774b941d2d0 100644 (file)
@@ -1532,6 +1532,16 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
        return NOTIFY_OK;
 }
 
+void blk_mq_disable_hotplug(void)
+{
+       mutex_lock(&all_q_mutex);
+}
+
+void blk_mq_enable_hotplug(void)
+{
+       mutex_unlock(&all_q_mutex);
+}
+
 static int __init blk_mq_init(void)
 {
        blk_mq_cpu_init();
index ed0035cd458ee8f78691a8f95415a8665707ca11..361f9343dab139d5cbbee252dfba9af4c73797c6 100644 (file)
@@ -40,6 +40,8 @@ void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
 void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_cpu_init(void);
+void blk_mq_enable_hotplug(void);
+void blk_mq_disable_hotplug(void);
 
 /*
  * CPU -> queue mappings