Commit 41adf531 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

blk-mq: don't run might_sleep() if the operation needn't blocking

The operation protected via blk_mq_run_dispatch_ops() in blk_mq_run_hw_queue
won't sleep, so don't run might_sleep() for it.
Reported-and-tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4cafe86c
...@@ -2048,7 +2048,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) ...@@ -2048,7 +2048,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
* And queue will be rerun in blk_mq_unquiesce_queue() if it is * And queue will be rerun in blk_mq_unquiesce_queue() if it is
* quiesced. * quiesced.
*/ */
blk_mq_run_dispatch_ops(hctx->queue, __blk_mq_run_dispatch_ops(hctx->queue, false,
need_run = !blk_queue_quiesced(hctx->queue) && need_run = !blk_queue_quiesced(hctx->queue) &&
blk_mq_hctx_has_pending(hctx)); blk_mq_hctx_has_pending(hctx));
......
...@@ -375,7 +375,7 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx, ...@@ -375,7 +375,7 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,
} }
/* run the code block in @dispatch_ops with rcu/srcu read lock held */ /* run the code block in @dispatch_ops with rcu/srcu read lock held */
#define blk_mq_run_dispatch_ops(q, dispatch_ops) \ #define __blk_mq_run_dispatch_ops(q, check_sleep, dispatch_ops) \
do { \ do { \
if (!blk_queue_has_srcu(q)) { \ if (!blk_queue_has_srcu(q)) { \
rcu_read_lock(); \ rcu_read_lock(); \
...@@ -384,11 +384,14 @@ do { \ ...@@ -384,11 +384,14 @@ do { \
} else { \ } else { \
int srcu_idx; \ int srcu_idx; \
\ \
might_sleep(); \ might_sleep_if(check_sleep); \
srcu_idx = srcu_read_lock((q)->srcu); \ srcu_idx = srcu_read_lock((q)->srcu); \
(dispatch_ops); \ (dispatch_ops); \
srcu_read_unlock((q)->srcu, srcu_idx); \ srcu_read_unlock((q)->srcu, srcu_idx); \
} \ } \
} while (0) } while (0)
#define blk_mq_run_dispatch_ops(q, dispatch_ops) \
__blk_mq_run_dispatch_ops(q, true, dispatch_ops) \
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment