Commit 849a3700 authored by Jens Axboe's avatar Jens Axboe

block: avoid ordered task state change for polled IO

For the core poll helper, the task state setting don't need to imply any
atomics, as it's the current task itself that is being modified and
we're not going to sleep.

For IRQ driven, the wakeup path have the necessary barriers to not need
us using the heavy handed version of the task state setting.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a4668d9b
...@@ -3331,12 +3331,12 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq) ...@@ -3331,12 +3331,12 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
ret = q->mq_ops->poll(hctx, rq->tag); ret = q->mq_ops->poll(hctx, rq->tag);
if (ret > 0) { if (ret > 0) {
hctx->poll_success++; hctx->poll_success++;
set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
return true; return true;
} }
if (signal_pending_state(state, current)) if (signal_pending_state(state, current))
set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
if (current->state == TASK_RUNNING) if (current->state == TASK_RUNNING)
return true; return true;
......
...@@ -237,9 +237,11 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ...@@ -237,9 +237,11 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
qc = submit_bio(&bio); qc = submit_bio(&bio);
for (;;) { for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
if (!READ_ONCE(bio.bi_private)) if (!READ_ONCE(bio.bi_private))
break; break;
if (!(iocb->ki_flags & IOCB_HIPRI) || if (!(iocb->ki_flags & IOCB_HIPRI) ||
!blk_poll(bdev_get_queue(bdev), qc)) !blk_poll(bdev_get_queue(bdev), qc))
io_schedule(); io_schedule();
...@@ -415,7 +417,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) ...@@ -415,7 +417,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
return -EIOCBQUEUED; return -EIOCBQUEUED;
for (;;) { for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
if (!READ_ONCE(dio->waiter)) if (!READ_ONCE(dio->waiter))
break; break;
......
...@@ -1888,7 +1888,8 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, ...@@ -1888,7 +1888,8 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
return -EIOCBQUEUED; return -EIOCBQUEUED;
for (;;) { for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
if (!READ_ONCE(dio->submit.waiter)) if (!READ_ONCE(dio->submit.waiter))
break; break;
......
...@@ -405,7 +405,8 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -405,7 +405,8 @@ int swap_readpage(struct page *page, bool synchronous)
bio_get(bio); bio_get(bio);
qc = submit_bio(bio); qc = submit_bio(bio);
while (synchronous) { while (synchronous) {
set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
if (!READ_ONCE(bio->bi_private)) if (!READ_ONCE(bio->bi_private))
break; break;
......
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