diff mbox series

[v4,2/4] blk-mq: Add blk_mq_delay_run_hw_queues() API call

Message ID 20200408080255.v4.2.I4c665d70212a5b33e103fec4d5019a59b4c05577@changeid (mailing list archive)
State New, archived
Headers show
Series blk-mq: Fix two causes of IO stalls found in reboot testing | expand

Commit Message

Doug Anderson April 8, 2020, 3:04 p.m. UTC
We have:
* blk_mq_run_hw_queue()
* blk_mq_delay_run_hw_queue()
* blk_mq_run_hw_queues()

...but not blk_mq_delay_run_hw_queues(), presumably because nobody
needed it before now.  Since we need it for a later patch in this
series, add it.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

Changes in v4: None
Changes in v3:
- ("blk-mq: Add blk_mq_delay_run_hw_queues() API call") new for v3

Changes in v2: None

 block/blk-mq.c         | 19 +++++++++++++++++++
 include/linux/blk-mq.h |  1 +
 2 files changed, 20 insertions(+)

Comments

Ming Lei April 9, 2020, 1:13 a.m. UTC | #1
On Wed, Apr 08, 2020 at 08:04:00AM -0700, Douglas Anderson wrote:
> We have:
> * blk_mq_run_hw_queue()
> * blk_mq_delay_run_hw_queue()
> * blk_mq_run_hw_queues()
> 
> ...but not blk_mq_delay_run_hw_queues(), presumably because nobody
> needed it before now.  Since we need it for a later patch in this
> series, add it.
> 
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> 
> Changes in v4: None
> Changes in v3:
> - ("blk-mq: Add blk_mq_delay_run_hw_queues() API call") new for v3
> 
> Changes in v2: None
> 
>  block/blk-mq.c         | 19 +++++++++++++++++++
>  include/linux/blk-mq.h |  1 +
>  2 files changed, 20 insertions(+)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 2cd8d2b49ff4..ea0cd970a3ff 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1537,6 +1537,25 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async)
>  }
>  EXPORT_SYMBOL(blk_mq_run_hw_queues);
>  
> +/**
> + * blk_mq_delay_run_hw_queues - Run all hardware queues asynchronously.
> + * @q: Pointer to the request queue to run.
> + * @msecs: Microseconds of delay to wait before running the queues.
> + */
> +void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs)
> +{
> +	struct blk_mq_hw_ctx *hctx;
> +	int i;
> +
> +	queue_for_each_hw_ctx(q, hctx, i) {
> +		if (blk_mq_hctx_stopped(hctx))
> +			continue;
> +
> +		blk_mq_delay_run_hw_queue(hctx, msecs);
> +	}
> +}
> +EXPORT_SYMBOL(blk_mq_delay_run_hw_queues);
> +
>  /**
>   * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped
>   * @q: request queue.
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index 11cfd6470b1a..405f8c196517 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -503,6 +503,7 @@ void blk_mq_unquiesce_queue(struct request_queue *q);
>  void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
>  void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
>  void blk_mq_run_hw_queues(struct request_queue *q, bool async);
> +void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs);
>  void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
>  		busy_tag_iter_fn *fn, void *priv);
>  void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset);
> -- 
> 2.26.0.292.g33ef6b2f38-goog
> 

Reviewed-by: Ming Lei <ming.lei@redhat.com>
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 2cd8d2b49ff4..ea0cd970a3ff 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1537,6 +1537,25 @@  void blk_mq_run_hw_queues(struct request_queue *q, bool async)
 }
 EXPORT_SYMBOL(blk_mq_run_hw_queues);
 
+/**
+ * blk_mq_delay_run_hw_queues - Run all hardware queues asynchronously.
+ * @q: Pointer to the request queue to run.
+ * @msecs: Microseconds of delay to wait before running the queues.
+ */
+void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs)
+{
+	struct blk_mq_hw_ctx *hctx;
+	int i;
+
+	queue_for_each_hw_ctx(q, hctx, i) {
+		if (blk_mq_hctx_stopped(hctx))
+			continue;
+
+		blk_mq_delay_run_hw_queue(hctx, msecs);
+	}
+}
+EXPORT_SYMBOL(blk_mq_delay_run_hw_queues);
+
 /**
  * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped
  * @q: request queue.
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 11cfd6470b1a..405f8c196517 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -503,6 +503,7 @@  void blk_mq_unquiesce_queue(struct request_queue *q);
 void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
 void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
 void blk_mq_run_hw_queues(struct request_queue *q, bool async);
+void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs);
 void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
 		busy_tag_iter_fn *fn, void *priv);
 void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset);