Skip to contentSkip to conversation

blk-mq: Make it safe to call blk_mq_quiesce_queue_nowait() from an interrupt handler

PATCH In review Bart Van Assche 3 participants 5 messages Jun 20, 2017 – Jun 21, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: Make it safe to call blk_mq_quiesce_queue_nowait() from an interrupt handler

Since blk_mq_quiesce_queue_nowait() can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.

Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 block/blk-mq.c         | 14 ++++++++++++++
 include/linux/blk-mq.h | 10 +---------
 2 files changed, 15 insertions(+), 9 deletions(-)
block/blk-mq.c +14 -0
index 1c4f1f4978c6..92faf340dc92 100644
@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
 
+/*
+ * FIXME: replace the scsi_internal_device_*block_nowait() calls in the
+ * mpt3sas driver such that this function can be removed.
+ */
+void blk_mq_quiesce_queue_nowait(struct request_queue *q)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+}
+EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
+
 /**
  * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
  * @q: request queue.
include/linux/blk-mq.h +1 -9
index 366b83cee955..23d32ff0b462 100644
@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 int blk_mq_map_queues(struct blk_mq_tag_set *set);
 void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
 
-/*
- * FIXME: this helper is just for working around mpt3sas.
- */
-static inline void blk_mq_quiesce_queue_nowait(struct request_queue *q)
-{
-	spin_lock_irq(q->queue_lock);
-	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
-	spin_unlock_irq(q->queue_lock);
-}
+void blk_mq_quiesce_queue_nowait(struct request_queue *q);
 
 /*
  * Driver command data is immediately after the request. So subtract request
Signature · 1 line
2.13.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 63 lines · Bart Van Assche

Since blk_mq_quiesce_queue_nowait() can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.

Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 block/blk-mq.c         | 14 ++++++++++++++
 include/linux/blk-mq.h | 10 +---------
 2 files changed, 15 insertions(+), 9 deletions(-)
block/blk-mq.c +14 -0
index 1c4f1f4978c6..92faf340dc92 100644
@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
 
+/*
+ * FIXME: replace the scsi_internal_device_*block_nowait() calls in the
+ * mpt3sas driver such that this function can be removed.
+ */
+void blk_mq_quiesce_queue_nowait(struct request_queue *q)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+}
+EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
+
 /**
  * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
  * @q: request queue.
include/linux/blk-mq.h +1 -9
index 366b83cee955..23d32ff0b462 100644
@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 int blk_mq_map_queues(struct blk_mq_tag_set *set);
 void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
 
-/*
- * FIXME: this helper is just for working around mpt3sas.
- */
-static inline void blk_mq_quiesce_queue_nowait(struct request_queue *q)
-{
-	spin_lock_irq(q->queue_lock);
-	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
-	spin_unlock_irq(q->queue_lock);
-}
+void blk_mq_quiesce_queue_nowait(struct request_queue *q);
 
 /*
  * Driver command data is immediately after the request. So subtract request
Signature · 1 line
2.13.1

Looks fine,

Thanks,
Ming

#2 lore raw
Quoted 67 lines · Ming Lei
Quoted 63 lines · Bart Van Assche

Since blk_mq_quiesce_queue_nowait() can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.

Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 block/blk-mq.c         | 14 ++++++++++++++
 include/linux/blk-mq.h | 10 +---------
 2 files changed, 15 insertions(+), 9 deletions(-)
block/blk-mq.c +14 -0
index 1c4f1f4978c6..92faf340dc92 100644
@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
 
+/*
+ * FIXME: replace the scsi_internal_device_*block_nowait() calls in the
+ * mpt3sas driver such that this function can be removed.
+ */
+void blk_mq_quiesce_queue_nowait(struct request_queue *q)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+}
+EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
+
 /**
  * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
  * @q: request queue.
include/linux/blk-mq.h +1 -9
index 366b83cee955..23d32ff0b462 100644
@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 int blk_mq_map_queues(struct blk_mq_tag_set *set);
 void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
 
-/*
- * FIXME: this helper is just for working around mpt3sas.
- */
-static inline void blk_mq_quiesce_queue_nowait(struct request_queue *q)
-{
-	spin_lock_irq(q->queue_lock);
-	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
-	spin_unlock_irq(q->queue_lock);
-}
+void blk_mq_quiesce_queue_nowait(struct request_queue *q);
 
 /*
  * Driver command data is immediately after the request. So subtract request
Signature · 1 line
2.13.1

Looks fine,

Quoted 1 line

Also we should save/restore irq flags in blk_mq_unquiesce_queue() since scsi_start_queue() does that too, could you fix the two in this patch?

Thanks,
Ming

maintainer
#3 lore raw
Quoted 68 lines · Ming Lei
Quoted 67 lines · Ming Lei
Quoted 63 lines · Bart Van Assche

Since blk_mq_quiesce_queue_nowait() can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.

Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 block/blk-mq.c         | 14 ++++++++++++++
 include/linux/blk-mq.h | 10 +---------
 2 files changed, 15 insertions(+), 9 deletions(-)
block/blk-mq.c +14 -0
index 1c4f1f4978c6..92faf340dc92 100644
@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
 
+/*
+ * FIXME: replace the scsi_internal_device_*block_nowait() calls in the
+ * mpt3sas driver such that this function can be removed.
+ */
+void blk_mq_quiesce_queue_nowait(struct request_queue *q)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+}
+EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
+
 /**
  * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
  * @q: request queue.
include/linux/blk-mq.h +1 -9
index 366b83cee955..23d32ff0b462 100644
@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 int blk_mq_map_queues(struct blk_mq_tag_set *set);
 void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
 
-/*
- * FIXME: this helper is just for working around mpt3sas.
- */
-static inline void blk_mq_quiesce_queue_nowait(struct request_queue *q)
-{
-	spin_lock_irq(q->queue_lock);
-	queue_flag_set(QUEUE_FLAG_QUIESCED, q);
-	spin_unlock_irq(q->queue_lock);
-}
+void blk_mq_quiesce_queue_nowait(struct request_queue *q);
 
 /*
  * Driver command data is immediately after the request. So subtract request
Signature · 1 line
2.13.1

Looks fine,

Quoted 5 lines
Quoted 1 line

Also we should save/restore irq flags in blk_mq_unquiesce_queue() since scsi_start_queue() does that too, could you fix the two in this patch?

Good catch. Bart, will you spin a v2?

Signature · 1 line
Jens Axboe
#4 lore raw

T24gVHVlLCAyMDE3LTA2LTIwIGF0IDE5OjQ4IC0wNjAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBH b29kIGNhdGNoLiBCYXJ0LCB3aWxsIHlvdSBzcGluIGEgdjI/DQoNCkhlbGxvIEplbnMsDQoNClRo YXQncyB0aGUgZmlyc3QgdGFzayBJIHdpbGwgd29yayBvbiB0b21vcnJvdyBtb3JuaW5nLg0KDQpC YXJ0Lg==