diff mbox series

[v3] blk-mq: skip hybrid polling if iopoll doesn't spin

Message ID d5c7dbf6f10efa44271dcb36a178f9566fe76c19.1607263384.git.asml.silence@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v3] blk-mq: skip hybrid polling if iopoll doesn't spin | expand

Commit Message

Pavel Begunkov Dec. 6, 2020, 2:04 p.m. UTC
If blk_poll() is not going to spin (i.e. @spin=false), it also must not
sleep in hybrid polling, otherwise it might be pretty suprising for
users trying to do a quick check and expecting no-wait behaviour.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---

v2: inverse invalid spin check
v3: add comments, reword and resend

 block/blk-mq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jens Axboe Dec. 7, 2020, 11:49 p.m. UTC | #1
On 12/6/20 7:04 AM, Pavel Begunkov wrote:
> If blk_poll() is not going to spin (i.e. @spin=false), it also must not
> sleep in hybrid polling, otherwise it might be pretty suprising for
> users trying to do a quick check and expecting no-wait behaviour.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index e9799fed98c7..8d81fe0d8fbc 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3865,9 +3865,10 @@  int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
 	 * the state. Like for the other success return cases, the
 	 * caller is responsible for checking if the IO completed. If
 	 * the IO isn't complete, we'll get called again and will go
-	 * straight to the busy poll loop.
+	 * straight to the busy poll loop. If specified not to spin,
+	 * we also should not sleep.
 	 */
-	if (blk_mq_poll_hybrid(q, hctx, cookie))
+	if (spin && blk_mq_poll_hybrid(q, hctx, cookie))
 		return 1;
 
 	hctx->poll_considered++;