linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Four patches for the blk-mq debugfs code
@ 2017-02-01 18:20 Bart Van Assche
  2017-02-01 18:20 ` [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations Bart Van Assche
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Bart Van Assche @ 2017-02-01 18:20 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche

Hello Jens,

Please consider the four patches in this series for kernel v4.11.

Thanks,

Bart.

Bart Van Assche (4):
  blk-mq-debugfs: Add missing __acquires() / __releases() annotations
  blk-mq-debug: Avoid that sparse complains about req_flags_t usage
  blk-mq-debug: Make show() operations interruptible
  blk-mq-debug: Introduce debugfs_create_files()

 block/blk-mq-debugfs.c | 75 +++++++++++++++++++++++++++++++++-----------------
 block/elevator.c       |  2 +-
 2 files changed, 50 insertions(+), 27 deletions(-)

-- 
2.11.0

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

* [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations
  2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
@ 2017-02-01 18:20 ` Bart Van Assche
  2017-02-01 19:07   ` Omar Sandoval
  2017-02-01 18:20 ` [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage Bart Van Assche
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2017-02-01 18:20 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval

This patch avoids that sparse complains about lock imbalances.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
---
 block/blk-mq-debugfs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 5cd2b435a9f5..7bcd4b6edf83 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -95,6 +95,7 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
 }
 
 static void *hctx_dispatch_start(struct seq_file *m, loff_t *pos)
+	__acquires(&hctx->lock)
 {
 	struct blk_mq_hw_ctx *hctx = m->private;
 
@@ -110,6 +111,7 @@ static void *hctx_dispatch_next(struct seq_file *m, void *v, loff_t *pos)
 }
 
 static void hctx_dispatch_stop(struct seq_file *m, void *v)
+	__releases(&hctx->lock)
 {
 	struct blk_mq_hw_ctx *hctx = m->private;
 
@@ -482,6 +484,7 @@ static const struct file_operations hctx_active_fops = {
 };
 
 static void *ctx_rq_list_start(struct seq_file *m, loff_t *pos)
+	__acquires(&ctx->lock)
 {
 	struct blk_mq_ctx *ctx = m->private;
 
@@ -497,6 +500,7 @@ static void *ctx_rq_list_next(struct seq_file *m, void *v, loff_t *pos)
 }
 
 static void ctx_rq_list_stop(struct seq_file *m, void *v)
+	__releases(&ctx->lock)
 {
 	struct blk_mq_ctx *ctx = m->private;
 
-- 
2.11.0

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

* [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage
  2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
  2017-02-01 18:20 ` [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations Bart Van Assche
@ 2017-02-01 18:20 ` Bart Van Assche
  2017-02-01 19:08   ` Omar Sandoval
  2017-02-01 18:20 ` [PATCH 3/4] blk-mq-debug: Make show() operations interruptible Bart Van Assche
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2017-02-01 18:20 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval

Avoid that sparse reports the following complaints:

block/elevator.c:541:29: warning: incorrect type in assignment (different base types)
block/elevator.c:541:29:    expected bool [unsigned] [usertype] next_sorted
block/elevator.c:541:29:    got restricted req_flags_t

block/blk-mq-debugfs.c:92:54: warning: cast from restricted req_flags_t

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
---
 block/blk-mq-debugfs.c | 3 ++-
 block/elevator.c       | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 7bcd4b6edf83..aece9116b4f6 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -89,7 +89,8 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
 	struct request *rq = list_entry_rq(v);
 
 	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, rq->cmd_type, rq->cmd_flags,
+		   (__force unsigned int)rq->rq_flags,
 		   rq->tag, rq->internal_tag);
 	return 0;
 }
diff --git a/block/elevator.c b/block/elevator.c
index ef7f59469acc..9138efeee0c8 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -538,7 +538,7 @@ void elv_merge_requests(struct request_queue *q, struct request *rq,
 	if (e->uses_mq && e->type->ops.mq.requests_merged)
 		e->type->ops.mq.requests_merged(q, rq, next);
 	else if (e->type->ops.sq.elevator_merge_req_fn) {
-		next_sorted = next->rq_flags & RQF_SORTED;
+		next_sorted = (__force bool)(next->rq_flags & RQF_SORTED);
 		if (next_sorted)
 			e->type->ops.sq.elevator_merge_req_fn(q, rq, next);
 	}
-- 
2.11.0

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

* [PATCH 3/4] blk-mq-debug: Make show() operations interruptible
  2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
  2017-02-01 18:20 ` [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations Bart Van Assche
  2017-02-01 18:20 ` [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage Bart Van Assche
@ 2017-02-01 18:20 ` Bart Van Assche
  2017-02-01 19:08   ` Omar Sandoval
  2017-02-01 18:20 ` [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files() Bart Van Assche
  2017-02-01 19:23 ` [PATCH 0/4] Four patches for the blk-mq debugfs code Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2017-02-01 18:20 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval

Allow users to interrupt show operations instead of making a user
space process unkillable if ownership of q->sysfs_lock cannot be
obtained.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
---
 block/blk-mq-debugfs.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index aece9116b4f6..846943728939 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -179,13 +179,17 @@ 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;
+	int res;
 
-	mutex_lock(&q->sysfs_lock);
+	res = mutex_lock_interruptible(&q->sysfs_lock);
+	if (res)
+		goto out;
 	if (hctx->tags)
 		blk_mq_debugfs_tags_show(m, hctx->tags);
 	mutex_unlock(&q->sysfs_lock);
 
-	return 0;
+out:
+	return res;
 }
 
 static int hctx_tags_open(struct inode *inode, struct file *file)
@@ -204,12 +208,17 @@ 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;
+	int res;
 
-	mutex_lock(&q->sysfs_lock);
+	res = mutex_lock_interruptible(&q->sysfs_lock);
+	if (res)
+		goto out;
 	if (hctx->tags)
 		sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m);
 	mutex_unlock(&q->sysfs_lock);
-	return 0;
+
+out:
+	return res;
 }
 
 static int hctx_tags_bitmap_open(struct inode *inode, struct file *file)
@@ -228,13 +237,17 @@ 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;
+	int res;
 
-	mutex_lock(&q->sysfs_lock);
+	res = mutex_lock_interruptible(&q->sysfs_lock);
+	if (res)
+		goto out;
 	if (hctx->sched_tags)
 		blk_mq_debugfs_tags_show(m, hctx->sched_tags);
 	mutex_unlock(&q->sysfs_lock);
 
-	return 0;
+out:
+	return res;
 }
 
 static int hctx_sched_tags_open(struct inode *inode, struct file *file)
@@ -253,12 +266,17 @@ 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;
+	int res;
 
-	mutex_lock(&q->sysfs_lock);
+	res = mutex_lock_interruptible(&q->sysfs_lock);
+	if (res)
+		goto out;
 	if (hctx->sched_tags)
 		sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m);
 	mutex_unlock(&q->sysfs_lock);
-	return 0;
+
+out:
+	return res;
 }
 
 static int hctx_sched_tags_bitmap_open(struct inode *inode, struct file *file)
-- 
2.11.0

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

* [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files()
  2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
                   ` (2 preceding siblings ...)
  2017-02-01 18:20 ` [PATCH 3/4] blk-mq-debug: Make show() operations interruptible Bart Van Assche
@ 2017-02-01 18:20 ` Bart Van Assche
  2017-02-01 19:08   ` Omar Sandoval
  2017-02-01 19:23 ` [PATCH 0/4] Four patches for the blk-mq debugfs code Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2017-02-01 18:20 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval

Replace the two debugfs_create_file() loops by a call to the new
debugfs_create_files() function. Add an empty element at the end
of the two attribute arrays such that the array size does not have
to be passed to debugfs_create_files().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
---
 block/blk-mq-debugfs.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 846943728939..b3bc9f02a5f5 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -653,6 +653,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = {
 	{"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[] = {
@@ -660,6 +661,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
 	{"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)
@@ -688,27 +690,31 @@ void blk_mq_debugfs_unregister(struct request_queue *q)
 	q->debugfs_dir = NULL;
 }
 
+static bool debugfs_create_files(struct dentry *parent, void *data,
+				const struct blk_mq_debugfs_attr *attr)
+{
+	for (; attr->name; attr++) {
+		if (!debugfs_create_file(attr->name, attr->mode, parent,
+					 data, attr->fops))
+			return false;
+	}
+	return true;
+}
+
 static int blk_mq_debugfs_register_ctx(struct request_queue *q,
 				       struct blk_mq_ctx *ctx,
 				       struct dentry *hctx_dir)
 {
 	struct dentry *ctx_dir;
 	char name[20];
-	int i;
 
 	snprintf(name, sizeof(name), "cpu%u", ctx->cpu);
 	ctx_dir = debugfs_create_dir(name, hctx_dir);
 	if (!ctx_dir)
 		return -ENOMEM;
 
-	for (i = 0; i < ARRAY_SIZE(blk_mq_debugfs_ctx_attrs); i++) {
-		const struct blk_mq_debugfs_attr *attr;
-
-		attr = &blk_mq_debugfs_ctx_attrs[i];
-		if (!debugfs_create_file(attr->name, attr->mode, ctx_dir, ctx,
-					 attr->fops))
-			return -ENOMEM;
-	}
+	if (!debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs))
+		return -ENOMEM;
 
 	return 0;
 }
@@ -726,14 +732,8 @@ static int blk_mq_debugfs_register_hctx(struct request_queue *q,
 	if (!hctx_dir)
 		return -ENOMEM;
 
-	for (i = 0; i < ARRAY_SIZE(blk_mq_debugfs_hctx_attrs); i++) {
-		const struct blk_mq_debugfs_attr *attr;
-
-		attr = &blk_mq_debugfs_hctx_attrs[i];
-		if (!debugfs_create_file(attr->name, attr->mode, hctx_dir, hctx,
-					 attr->fops))
-			return -ENOMEM;
-	}
+	if (!debugfs_create_files(hctx_dir, hctx, blk_mq_debugfs_hctx_attrs))
+		return -ENOMEM;
 
 	hctx_for_each_ctx(hctx, ctx, i) {
 		if (blk_mq_debugfs_register_ctx(q, ctx, hctx_dir))
-- 
2.11.0

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

* Re: [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations
  2017-02-01 18:20 ` [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations Bart Van Assche
@ 2017-02-01 19:07   ` Omar Sandoval
  0 siblings, 0 replies; 10+ messages in thread
From: Omar Sandoval @ 2017-02-01 19:07 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval

On Wed, Feb 01, 2017 at 10:20:56AM -0800, Bart Van Assche wrote:
> This patch avoids that sparse complains about lock imbalances.

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> ---
>  block/blk-mq-debugfs.c | 4 ++++
>  1 file changed, 4 insertions(+)

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

* Re: [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage
  2017-02-01 18:20 ` [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage Bart Van Assche
@ 2017-02-01 19:08   ` Omar Sandoval
  0 siblings, 0 replies; 10+ messages in thread
From: Omar Sandoval @ 2017-02-01 19:08 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval

On Wed, Feb 01, 2017 at 10:20:57AM -0800, Bart Van Assche wrote:
> Avoid that sparse reports the following complaints:
> 
> block/elevator.c:541:29: warning: incorrect type in assignment (different base types)
> block/elevator.c:541:29:    expected bool [unsigned] [usertype] next_sorted
> block/elevator.c:541:29:    got restricted req_flags_t
> 
> block/blk-mq-debugfs.c:92:54: warning: cast from restricted req_flags_t

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> ---
>  block/blk-mq-debugfs.c | 3 ++-
>  block/elevator.c       | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)

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

* Re: [PATCH 3/4] blk-mq-debug: Make show() operations interruptible
  2017-02-01 18:20 ` [PATCH 3/4] blk-mq-debug: Make show() operations interruptible Bart Van Assche
@ 2017-02-01 19:08   ` Omar Sandoval
  0 siblings, 0 replies; 10+ messages in thread
From: Omar Sandoval @ 2017-02-01 19:08 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval

On Wed, Feb 01, 2017 at 10:20:58AM -0800, Bart Van Assche wrote:
> Allow users to interrupt show operations instead of making a user
> space process unkillable if ownership of q->sysfs_lock cannot be
> obtained.

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> ---
>  block/blk-mq-debugfs.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)

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

* Re: [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files()
  2017-02-01 18:20 ` [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files() Bart Van Assche
@ 2017-02-01 19:08   ` Omar Sandoval
  0 siblings, 0 replies; 10+ messages in thread
From: Omar Sandoval @ 2017-02-01 19:08 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval

On Wed, Feb 01, 2017 at 10:20:59AM -0800, Bart Van Assche wrote:
> Replace the two debugfs_create_file() loops by a call to the new
> debugfs_create_files() function. Add an empty element at the end
> of the two attribute arrays such that the array size does not have
> to be passed to debugfs_create_files().

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> ---
>  block/blk-mq-debugfs.c | 34 +++++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 17 deletions(-)

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

* Re: [PATCH 0/4] Four patches for the blk-mq debugfs code
  2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
                   ` (3 preceding siblings ...)
  2017-02-01 18:20 ` [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files() Bart Van Assche
@ 2017-02-01 19:23 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2017-02-01 19:23 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-block

On 02/01/2017 10:20 AM, Bart Van Assche wrote:
> Hello Jens,
> 
> Please consider the four patches in this series for kernel v4.11.

Added, thanks Bart.

-- 
Jens Axboe

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

end of thread, other threads:[~2017-02-01 19:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-01 18:20 [PATCH 0/4] Four patches for the blk-mq debugfs code Bart Van Assche
2017-02-01 18:20 ` [PATCH 1/4] blk-mq-debugfs: Add missing __acquires() / __releases() annotations Bart Van Assche
2017-02-01 19:07   ` Omar Sandoval
2017-02-01 18:20 ` [PATCH 2/4] blk-mq-debug: Avoid that sparse complains about req_flags_t usage Bart Van Assche
2017-02-01 19:08   ` Omar Sandoval
2017-02-01 18:20 ` [PATCH 3/4] blk-mq-debug: Make show() operations interruptible Bart Van Assche
2017-02-01 19:08   ` Omar Sandoval
2017-02-01 18:20 ` [PATCH 4/4] blk-mq-debug: Introduce debugfs_create_files() Bart Van Assche
2017-02-01 19:08   ` Omar Sandoval
2017-02-01 19:23 ` [PATCH 0/4] Four patches for the blk-mq debugfs code Jens Axboe

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).