io_uring-20190301
-----BEGIN PGP SIGNATURE-----

iQJEBAABCAAuFiEEwPw5LcreJtl1+l5K99NY+ylx4KYFAlx63QAQHGF4Ym9lQGtl
cm5lbC5kawAKCRD301j7KXHgpqxjD/oDhiIXZNwdh2VDm8piUY23WaOlHlf4WcJk
Op684uj4g18uGl6+d7agbMMQOo5x+8qkhvMhms0R2bBhRPeezro5x6tGOCgW0qIg
5XVc4C9LHQJLi22gYaSqJsdPslnbsa5gDck0ikMwFWPAQccZ+SQfI2JpWzzYji7m
22teyv/aXsJLZwAo2J8HVittrRFnR6sQUmpDgGHb4FhnyLLCVBSipEdgXEcY/+OO
lGQ552tnL2J/UEHQKJ505pq+8gXcCcV4+rv82cNWLc+krQ0CWTZu2LCC86ij9Ey7
Nky0bJMkdutotGCzSAosGOMw2YLMBUNINoBHLw8eM7h1NQbDML2SFm36DFTyWOmb
YwlKojdazoCrnTjYV8tabUda78C2A5DVb7yjZ8FtA6x572tJSUWncXZwWC1wAdOO
sWcAgg+hsc7dNXyW+olejivFgA1q5e65I/CS8L+H8yeGp/7WHhn+05TBqDIZaEi2
jAQD127DSNcGw7JNEhorEqBPWvMxbodGgXZ1C+wCtrzk0SPWygzcD9WqhLlIDdKu
58y3v/nHuqqyUK1pEaZjPYLa2bSZ4/UKGWfM3Sg95FFgd5E7rtdaNPXvtAo2IzRA
wtIKSUWyY4YGdbgm/Duxr+fYuNsQZLqlfuCg2j1P8Iblr/6jDIwQgJJhnXJrJt8k
3r9uJ/CpbA==
=sY04
-----END PGP SIGNATURE-----
io_uring: allow workqueue item to handle multiple buffered requests

Right now we punt any buffered request that ends up triggering an
-EAGAIN to an async workqueue. This works fine in terms of providing
async execution of them, but it also can create quite a lot of work
queue items. For sequentially buffered IO, it's advantageous to
serialize the issue of them. For reads, the first one will trigger a
read-ahead, and subsequent request merely end up waiting on later pages
to complete. For writes, devices usually respond better to streamed
sequential writes.

Add state to track the last buffered request we punted to a work queue,
and if the next one is sequential to the previous, attempt to get the
previous work item to handle it. We limit the number of sequential
add-ons to the a multiple (8) of the max read-ahead size of the file.
This should be a good number for both reads and wries, as it defines the
max IO size the device can do directly.

This drastically cuts down on the number of context switches we need to
handle buffered sequential IO, and a basic test case of copying a big
file with io_uring sees a 5x speedup.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 file changed