All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v2 0/7] some improvements and cleanups for block
@ 2020-10-09  3:26 Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 1/7] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

Hi all,
  This series contains improvement for elevator exit, removing
  wrong comments and clean-up code.

Yufen Yu (7):
  block: invoke blk_mq_exit_sched no matter whether have .exit_sched
  block: remove redundant mq check
  block: use helper function to test queue register
  blk-mq: use helper function to test hw stopped
  block: fix comment and add lockdep assert
  block: get rid of unnecessary local variable
  blk-mq: get rid of the dead flush handle code path

 block/blk-iocost.c   |  2 +-
 block/blk-mq-sched.c |  6 ------
 block/blk-mq.c       |  2 +-
 block/blk-sysfs.c    |  5 +----
 block/elevator.c     | 23 ++++++++---------------
 5 files changed, 11 insertions(+), 27 deletions(-)

-- 
2.25.4


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

* [RESEND PATCH v2 1/7] block: invoke blk_mq_exit_sched no matter whether have .exit_sched
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 2/7] block: remove redundant mq check Yufen Yu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

We will register debugfs for scheduler no matter whether it have
defined callback funciton .exit_sched. So, blk_mq_exit_sched()
is always needed to unregister debugfs. Also, q->elevator should
be set as NULL after exiting scheduler.

For now, since all register scheduler have defined .exit_sched,
it will not cause any actual problem. But It will be more reasonable
to do this change.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-sysfs.c | 1 -
 block/elevator.c  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 7dda709f3ccb..ee2cd4d1054c 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -883,7 +883,6 @@ static void blk_exit_queue(struct request_queue *q)
 	if (q->elevator) {
 		ioc_clear_queue(q);
 		__elevator_exit(q, q->elevator);
-		q->elevator = NULL;
 	}
 
 	/*
diff --git a/block/elevator.c b/block/elevator.c
index 90ed7a28c21d..7d76b61e157a 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -191,8 +191,7 @@ static void elevator_release(struct kobject *kobj)
 void __elevator_exit(struct request_queue *q, struct elevator_queue *e)
 {
 	mutex_lock(&e->sysfs_lock);
-	if (e->type->ops.exit_sched)
-		blk_mq_exit_sched(q, e);
+	blk_mq_exit_sched(q, e);
 	mutex_unlock(&e->sysfs_lock);
 
 	kobject_put(&e->kobj);
-- 
2.25.4


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

* [RESEND PATCH v2 2/7] block: remove redundant mq check
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 1/7] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 3/7] block: use helper function to test queue register Yufen Yu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

elv_support_iosched() will check queue_is_mq() for us. So, remove
the redundant check to clean code.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/elevator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/elevator.c b/block/elevator.c
index 7d76b61e157a..b506895b34c7 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -615,7 +615,7 @@ int elevator_switch_mq(struct request_queue *q,
 
 static inline bool elv_support_iosched(struct request_queue *q)
 {
-	if (!q->mq_ops ||
+	if (!queue_is_mq(q) ||
 	    (q->tag_set && (q->tag_set->flags & BLK_MQ_F_NO_SCHED)))
 		return false;
 	return true;
@@ -763,7 +763,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
 {
 	int ret;
 
-	if (!queue_is_mq(q) || !elv_support_iosched(q))
+	if (!elv_support_iosched(q))
 		return count;
 
 	ret = __elevator_change(q, name);
-- 
2.25.4


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

* [RESEND PATCH v2 3/7] block: use helper function to test queue register
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 1/7] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 2/7] block: remove redundant mq check Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 4/7] blk-mq: use helper function to test hw stopped Yufen Yu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

We have defined common interface blk_queue_registered() to
test QUEUE_FLAG_REGISTERED. Just use it.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-iocost.c | 2 +-
 block/elevator.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index d37b55db2409..24a4dedae207 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -618,7 +618,7 @@ static struct ioc *q_to_ioc(struct request_queue *q)
 
 static const char *q_name(struct request_queue *q)
 {
-	if (test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags))
+	if (blk_queue_registered(q))
 		return kobject_name(q->kobj.parent);
 	else
 		return "<unknown>";
diff --git a/block/elevator.c b/block/elevator.c
index b506895b34c7..431a2a1c896e 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -672,7 +672,7 @@ void elevator_init_mq(struct request_queue *q)
 	if (!elv_support_iosched(q))
 		return;
 
-	WARN_ON_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags));
+	WARN_ON_ONCE(blk_queue_registered(q));
 
 	if (unlikely(q->elevator))
 		return;
-- 
2.25.4


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

* [RESEND PATCH v2 4/7] blk-mq: use helper function to test hw stopped
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
                   ` (2 preceding siblings ...)
  2020-10-09  3:26 ` [RESEND PATCH v2 3/7] block: use helper function to test queue register Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 5/7] block: fix comment and add lockdep assert Yufen Yu
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

We have introduced helper function blk_mq_hctx_stopped() to test
BLK_MQ_S_STOPPED.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 47e4d5ce6196..d96292e36a23 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1783,7 +1783,7 @@ static void blk_mq_run_work_fn(struct work_struct *work)
 	/*
 	 * If we are stopped, don't run the queue.
 	 */
-	if (test_bit(BLK_MQ_S_STOPPED, &hctx->state))
+	if (blk_mq_hctx_stopped(hctx))
 		return;
 
 	__blk_mq_run_hw_queue(hctx);
-- 
2.25.4


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

* [RESEND PATCH v2 5/7] block: fix comment and add lockdep assert
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
                   ` (3 preceding siblings ...)
  2020-10-09  3:26 ` [RESEND PATCH v2 4/7] blk-mq: use helper function to test hw stopped Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 6/7] block: get rid of unnecessary local variable Yufen Yu
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

After commit b89f625e28d4 ("block: don't release queue's sysfs
lock during switching elevator"), whole elevator register and
unregister function are covered by sysfs_lock. So, remove wrong
comment and add lockdep assert.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/elevator.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/block/elevator.c b/block/elevator.c
index 431a2a1c896e..293c5c81397a 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -479,16 +479,13 @@ static struct kobj_type elv_ktype = {
 	.release	= elevator_release,
 };
 
-/*
- * elv_register_queue is called from either blk_register_queue or
- * elevator_switch, elevator switch is prevented from being happen
- * in the two paths, so it is safe to not hold q->sysfs_lock.
- */
 int elv_register_queue(struct request_queue *q, bool uevent)
 {
 	struct elevator_queue *e = q->elevator;
 	int error;
 
+	lockdep_assert_held(&q->sysfs_lock);
+
 	error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched");
 	if (!error) {
 		struct elv_fs_entry *attr = e->type->elevator_attrs;
@@ -507,13 +504,10 @@ int elv_register_queue(struct request_queue *q, bool uevent)
 	return error;
 }
 
-/*
- * elv_unregister_queue is called from either blk_unregister_queue or
- * elevator_switch, elevator switch is prevented from being happen
- * in the two paths, so it is safe to not hold q->sysfs_lock.
- */
 void elv_unregister_queue(struct request_queue *q)
 {
+	lockdep_assert_held(&q->sysfs_lock);
+
 	if (q) {
 		struct elevator_queue *e = q->elevator;
 
-- 
2.25.4


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

* [RESEND PATCH v2 6/7] block: get rid of unnecessary local variable
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
                   ` (4 preceding siblings ...)
  2020-10-09  3:26 ` [RESEND PATCH v2 5/7] block: fix comment and add lockdep assert Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09  3:26 ` [RESEND PATCH v2 7/7] blk-mq: get rid of the dead flush handle code path Yufen Yu
  2020-10-09 18:45 ` [RESEND PATCH v2 0/7] some improvements and cleanups for block Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

Since whole elevator register is protectd by sysfs_lock, we
don't need extras 'has_elevator'. Just use q->elevator directly.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-sysfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index ee2cd4d1054c..d13a70ed39bf 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -976,7 +976,6 @@ int blk_register_queue(struct gendisk *disk)
 	int ret;
 	struct device *dev = disk_to_dev(disk);
 	struct request_queue *q = disk->queue;
-	bool has_elevator = false;
 
 	if (WARN_ON(!q))
 		return -ENXIO;
@@ -1040,7 +1039,6 @@ int blk_register_queue(struct gendisk *disk)
 			kobject_put(&dev->kobj);
 			return ret;
 		}
-		has_elevator = true;
 	}
 
 	blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
@@ -1049,7 +1047,7 @@ int blk_register_queue(struct gendisk *disk)
 
 	/* Now everything is ready and send out KOBJ_ADD uevent */
 	kobject_uevent(&q->kobj, KOBJ_ADD);
-	if (has_elevator)
+	if (q->elevator)
 		kobject_uevent(&q->elevator->kobj, KOBJ_ADD);
 	mutex_unlock(&q->sysfs_lock);
 
-- 
2.25.4


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

* [RESEND PATCH v2 7/7] blk-mq: get rid of the dead flush handle code path
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
                   ` (5 preceding siblings ...)
  2020-10-09  3:26 ` [RESEND PATCH v2 6/7] block: get rid of unnecessary local variable Yufen Yu
@ 2020-10-09  3:26 ` Yufen Yu
  2020-10-09 18:45 ` [RESEND PATCH v2 0/7] some improvements and cleanups for block Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Yufen Yu @ 2020-10-09  3:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch

After commit 923218f6166a ("blk-mq: don't allocate driver tag upfront
for flush rq"), blk_mq_submit_bio() will call blk_insert_flush()
directly to handle flush request rather than blk_mq_sched_insert_request()
in the case of elevator.

Then, all flush request either have set RQF_FLUSH_SEQ flag when call
blk_mq_sched_insert_request(), or have inserted into hctx->dispatch.
So, remove the dead code path.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-mq-sched.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index d2790e5b06d1..606298fff5db 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -525,12 +525,6 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
 	struct blk_mq_ctx *ctx = rq->mq_ctx;
 	struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
 
-	/* flush rq in flush machinery need to be dispatched directly */
-	if (!(rq->rq_flags & RQF_FLUSH_SEQ) && op_is_flush(rq->cmd_flags)) {
-		blk_insert_flush(rq);
-		goto run;
-	}
-
 	WARN_ON(e && (rq->tag != -1));
 
 	if (blk_mq_sched_bypass_insert(hctx, !!e, rq)) {
-- 
2.25.4


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

* Re: [RESEND PATCH v2 0/7] some improvements and cleanups for block
  2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
                   ` (6 preceding siblings ...)
  2020-10-09  3:26 ` [RESEND PATCH v2 7/7] blk-mq: get rid of the dead flush handle code path Yufen Yu
@ 2020-10-09 18:45 ` Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2020-10-09 18:45 UTC (permalink / raw)
  To: Yufen Yu; +Cc: linux-block, ming.lei, hch

On 10/8/20 9:26 PM, Yufen Yu wrote:
> Hi all,
>   This series contains improvement for elevator exit, removing
>   wrong comments and clean-up code.
> 
> Yufen Yu (7):
>   block: invoke blk_mq_exit_sched no matter whether have .exit_sched
>   block: remove redundant mq check
>   block: use helper function to test queue register
>   blk-mq: use helper function to test hw stopped
>   block: fix comment and add lockdep assert
>   block: get rid of unnecessary local variable
>   blk-mq: get rid of the dead flush handle code path
> 
>  block/blk-iocost.c   |  2 +-
>  block/blk-mq-sched.c |  6 ------
>  block/blk-mq.c       |  2 +-
>  block/blk-sysfs.c    |  5 +----
>  block/elevator.c     | 23 ++++++++---------------
>  5 files changed, 11 insertions(+), 27 deletions(-)

Applied, thanks.

-- 
Jens Axboe


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

end of thread, other threads:[~2020-10-09 18:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  3:26 [RESEND PATCH v2 0/7] some improvements and cleanups for block Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 1/7] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 2/7] block: remove redundant mq check Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 3/7] block: use helper function to test queue register Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 4/7] blk-mq: use helper function to test hw stopped Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 5/7] block: fix comment and add lockdep assert Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 6/7] block: get rid of unnecessary local variable Yufen Yu
2020-10-09  3:26 ` [RESEND PATCH v2 7/7] blk-mq: get rid of the dead flush handle code path Yufen Yu
2020-10-09 18:45 ` [RESEND PATCH v2 0/7] some improvements and cleanups for block Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.