diff mbox series

[06/16] blk-mq: add 'type' attribute to the sysfs hctx directory

Message ID 20181030183252.17857-7-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series blk-mq: Add support for multiple queue maps | expand

Commit Message

Jens Axboe Oct. 30, 2018, 6:32 p.m. UTC
It can be useful for a user to verify what type a given hardware
queue is, expose this information in sysfs.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq-sysfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Sagi Grimberg Oct. 31, 2018, 12:53 a.m. UTC | #1
> It can be useful for a user to verify what type a given hardware
> queue is, expose this information in sysfs.

I assume the user is expected to understand the meaning of the
enumeration it sees in accessing this field correct?

Would be nice to output some meaningful string but I'm not
yet sure how to do that, but would be nice...

Other than that,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Jens Axboe Oct. 31, 2018, 2:21 p.m. UTC | #2
On 10/30/18 6:53 PM, Sagi Grimberg wrote:
> 
>> It can be useful for a user to verify what type a given hardware
>> queue is, expose this information in sysfs.
> 
> I assume the user is expected to understand the meaning of the
> enumeration it sees in accessing this field correct?
> 
> Would be nice to output some meaningful string but I'm not
> yet sure how to do that, but would be nice...

The type is driver private, there's no specific meaning associated
with the type. We could make it output a string provided that
the driver had a way to query it. For now I think the type is
enough, it'll allow you to see which ones are different.

> Other than that,
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

Thanks
Omar Sandoval Nov. 1, 2018, 9:59 p.m. UTC | #3
On Tue, Oct 30, 2018 at 12:32:42PM -0600, Jens Axboe wrote:
> It can be useful for a user to verify what type a given hardware
> queue is, expose this information in sysfs.
> 
> Reviewed-by: Hannes Reinecke <hare@suse.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  block/blk-mq-sysfs.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Out of curiousity, why sysfs instead of debugfs?
Jens Axboe Nov. 1, 2018, 10:50 p.m. UTC | #4
On 11/1/18 3:59 PM, Omar Sandoval wrote:
> On Tue, Oct 30, 2018 at 12:32:42PM -0600, Jens Axboe wrote:
>> It can be useful for a user to verify what type a given hardware
>> queue is, expose this information in sysfs.
>>
>> Reviewed-by: Hannes Reinecke <hare@suse.com>
>> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>> ---
>>  block/blk-mq-sysfs.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
> 
> Out of curiousity, why sysfs instead of debugfs?

I don't feel that strongly about it, but it is a property
like the mapped CPUs, for instance, so kind of makes sense to
put it there rather than in debugfs.
diff mbox series

Patch

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index aafb44224c89..2d737f9e7ba7 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -161,6 +161,11 @@  static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
 	return ret;
 }
 
+static ssize_t blk_mq_hw_sysfs_type_show(struct blk_mq_hw_ctx *hctx, char *page)
+{
+	return sprintf(page, "%u\n", hctx->type);
+}
+
 static struct attribute *default_ctx_attrs[] = {
 	NULL,
 };
@@ -177,11 +182,16 @@  static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = {
 	.attr = {.name = "cpu_list", .mode = 0444 },
 	.show = blk_mq_hw_sysfs_cpus_show,
 };
+static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_type = {
+	.attr = {.name = "type", .mode = 0444 },
+	.show = blk_mq_hw_sysfs_type_show,
+};
 
 static struct attribute *default_hw_ctx_attrs[] = {
 	&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_type.attr,
 	NULL,
 };