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

Hi all,

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

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

* [PATCH 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched
  2020-09-18  1:47 [PATCH 0/4] some improvements and clean-up for block Yufen Yu
@ 2020-09-18  1:47 ` Yufen Yu
  2020-09-18  1:47 ` [PATCH 2/4] block: use common interface blk_queue_registered() Yufen Yu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yufen Yu @ 2020-09-18  1:47 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, 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] 6+ messages in thread

* [PATCH 2/4] block: use common interface blk_queue_registered()
  2020-09-18  1:47 [PATCH 0/4] some improvements and clean-up for block Yufen Yu
  2020-09-18  1:47 ` [PATCH 1/4] block: invoke blk_mq_exit_sched no matter whether have .exit_sched Yufen Yu
@ 2020-09-18  1:47 ` Yufen Yu
  2020-09-18  1:47 ` [PATCH 3/4] block: fix comment and add lockdep assert Yufen Yu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yufen Yu @ 2020-09-18  1:47 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, 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..073624f54bc9 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 (test_bit(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] 6+ messages in thread

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

* [PATCH 4/4] block: get rid of unnecessary local variable
  2020-09-18  1:47 [PATCH 0/4] some improvements and clean-up for block Yufen Yu
                   ` (2 preceding siblings ...)
  2020-09-18  1:47 ` [PATCH 3/4] block: fix comment and add lockdep assert Yufen Yu
@ 2020-09-18  1:47 ` Yufen Yu
  2020-09-18  7:55 ` [PATCH 0/4] some improvements and clean-up for block Yufen Yu
  4 siblings, 0 replies; 6+ messages in thread
From: Yufen Yu @ 2020-09-18  1:47 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, 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] 6+ messages in thread

* Re: [PATCH 0/4] some improvements and clean-up for block
  2020-09-18  1:47 [PATCH 0/4] some improvements and clean-up for block Yufen Yu
                   ` (3 preceding siblings ...)
  2020-09-18  1:47 ` [PATCH 4/4] block: get rid of unnecessary local variable Yufen Yu
@ 2020-09-18  7:55 ` Yufen Yu
  4 siblings, 0 replies; 6+ messages in thread
From: Yufen Yu @ 2020-09-18  7:55 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, andy.lavr

Ignoring this patch set. There is a sloppy error in patch 2. I will resend the patch set.
Sorry for noise. Thanks for Andy Lavr to point the error.

On 2020/9/18 9:47, Yufen Yu wrote:
> Hi all,
> 
>    This series contains improvement for elevator exit, removing
>    wrong comments and clean-up code.
> 
> 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(-)
> 

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

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

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