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

Hi all,

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

v1->v2:
  fix a error in patch 2.

Yufen Yu (4):
  block: invoke blk_mq_exit_sched no matter whether have .exit_sched
  block: use common interface blk_queue_registered()
  block: fix comment and add lockdep assert
  block: get rid of unnecessary local variable

 block/blk-iocost.c |  2 +-
 block/blk-sysfs.c  |  5 +----
 block/elevator.c   | 19 ++++++-------------
 3 files changed, 8 insertions(+), 18 deletions(-)

-- 
2.25.4


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

* [PATCH v2 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched
  2020-09-18  8:03 [PATCH v2 0/4] some improvements and clean-up for block Yufen Yu
@ 2020-09-18  8:03 ` Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 2/4] block: use common interface blk_queue_registered() Yufen Yu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yufen Yu @ 2020-09-18  8:03 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, andy.lavr, yuyufen

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 6e775bd4af66..b506895b34c7 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] 5+ messages in thread

* [PATCH v2 2/4] block: use common interface blk_queue_registered()
  2020-09-18  8:03 [PATCH v2 0/4] some improvements and clean-up for block Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
@ 2020-09-18  8:03 ` Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 3/4] block: fix comment and add lockdep assert Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 4/4] block: get rid of unnecessary local variable Yufen Yu
  3 siblings, 0 replies; 5+ messages in thread
From: Yufen Yu @ 2020-09-18  8:03 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, andy.lavr, yuyufen

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] 5+ messages in thread

* [PATCH v2 3/4] block: fix comment and add lockdep assert
  2020-09-18  8:03 [PATCH v2 0/4] some improvements and clean-up for block Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 2/4] block: use common interface blk_queue_registered() Yufen Yu
@ 2020-09-18  8:03 ` Yufen Yu
  2020-09-18  8:03 ` [PATCH v2 4/4] block: get rid of unnecessary local variable Yufen Yu
  3 siblings, 0 replies; 5+ messages in thread
From: Yufen Yu @ 2020-09-18  8:03 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, andy.lavr, yuyufen

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] 5+ messages in thread

* [PATCH v2 4/4] block: get rid of unnecessary local variable
  2020-09-18  8:03 [PATCH v2 0/4] some improvements and clean-up for block Yufen Yu
                   ` (2 preceding siblings ...)
  2020-09-18  8:03 ` [PATCH v2 3/4] block: fix comment and add lockdep assert Yufen Yu
@ 2020-09-18  8:03 ` Yufen Yu
  3 siblings, 0 replies; 5+ messages in thread
From: Yufen Yu @ 2020-09-18  8:03 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, andy.lavr, yuyufen

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] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18  8:03 [PATCH v2 0/4] some improvements and clean-up for block Yufen Yu
2020-09-18  8:03 ` [PATCH v2 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
2020-09-18  8:03 ` [PATCH v2 2/4] block: use common interface blk_queue_registered() Yufen Yu
2020-09-18  8:03 ` [PATCH v2 3/4] block: fix comment and add lockdep assert Yufen Yu
2020-09-18  8:03 ` [PATCH v2 4/4] block: get rid of unnecessary local variable Yufen Yu

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.