[PATCH 3/3] block: Polling completion performance optimization

Keith Busch
2017-12-21T20:46:36Z

When a request completion is polled, the completion task wakes itself
up. This is unnecessary, as the task can just set itself back to
running.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
fs/block_dev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 4a181fcb5175..ce67ffe73430 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -181,7 +181,10 @@ static void blkdev_bio_end_io_simple(struct bio *bio)
struct task_struct *waiter = bio->bi_private;

WRITE_ONCE(bio->bi_private, NULL);
- wake_up_process(waiter);
+ if (current != waiter)
+ wake_up_process(waiter);
+ else
+ __set_current_state(TASK_RUNNING);
}

static ssize_t
--
2.13.6