Message ID | 20190823001528.5673-4-damien.lemoal@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Elevator cleanups and improvements | expand |
On 23/08/2019 02:15, Damien Le Moal wrote: > Since elevator_init_rq() is called before the device queue is registered elevator_init_mq() ~^ (and in Subject) Otherwise: Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
On 8/22/19 5:15 PM, Damien Le Moal wrote: > Since elevator_init_rq() is called before the device queue is registered > in sysfs, there is no possible conflict with elevator_switch(). Remove > the unnecessary locking of q->sysfs_lock mutex. > > Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> > --- > block/elevator.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/block/elevator.c b/block/elevator.c > index 7fff06751633..6208ddc334ef 100644 > --- a/block/elevator.c > +++ b/block/elevator.c > @@ -617,17 +617,12 @@ void elevator_init_mq(struct request_queue *q) > if (q->nr_hw_queues != 1) > return; > > - /* > - * q->sysfs_lock must be held to provide mutual exclusion between > - * elevator_switch() and here. > - */ > - mutex_lock(&q->sysfs_lock); > if (unlikely(q->elevator)) > - goto out_unlock; > + return; > > e = elevator_get(q, "mq-deadline", false); > if (!e) > - goto out_unlock; > + return; > > err = blk_mq_init_sched(q, e); > if (err) { > @@ -635,9 +630,6 @@ void elevator_init_mq(struct request_queue *q) > "falling back to \"none\"\n", e->elevator_name); > elevator_put(e); > } > - > -out_unlock: > - mutex_unlock(&q->sysfs_lock); > } Please consider to add a WARN_ON_ONCE() statement that triggers a warning if this function is called for a request queue that has already been registered. Thanks, Bart.
diff --git a/block/elevator.c b/block/elevator.c index 7fff06751633..6208ddc334ef 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -617,17 +617,12 @@ void elevator_init_mq(struct request_queue *q) if (q->nr_hw_queues != 1) return; - /* - * q->sysfs_lock must be held to provide mutual exclusion between - * elevator_switch() and here. - */ - mutex_lock(&q->sysfs_lock); if (unlikely(q->elevator)) - goto out_unlock; + return; e = elevator_get(q, "mq-deadline", false); if (!e) - goto out_unlock; + return; err = blk_mq_init_sched(q, e); if (err) { @@ -635,9 +630,6 @@ void elevator_init_mq(struct request_queue *q) "falling back to \"none\"\n", e->elevator_name); elevator_put(e); } - -out_unlock: - mutex_unlock(&q->sysfs_lock); }
Since elevator_init_rq() is called before the device queue is registered in sysfs, there is no possible conflict with elevator_switch(). Remove the unnecessary locking of q->sysfs_lock mutex. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- block/elevator.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)