]> www.infradead.org Git - users/dwmw2/linux.git/commit
io_uring: fix potential hang with polled IO
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Aug 2019 18:15:59 +0000 (12:15 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2019 06:30:27 +0000 (08:30 +0200)
commit2b2c2647a19ce1a6a67a9765dfef9f7f3d11d71e
tree7e9f737ebbf2b04780478523d8c36c2cabcea79a
parent2a50be6e0551b38eb2ff17e8ad3061b46b1d47d1
io_uring: fix potential hang with polled IO

[ Upstream commit 500f9fbadef86466a435726192f4ca4df7d94236 ]

If a request issue ends up being punted to async context to avoid
blocking, we can get into a situation where the original application
enters the poll loop for that very request before it has been issued.
This should not be an issue, except that the polling will hold the
io_uring uring_ctx mutex for the duration of the poll. When the async
worker has actually issued the request, it needs to acquire this mutex
to add the request to the poll issued list. Since the application
polling is already holding this mutex, the workqueue sleeps on the
mutex forever, and the application thus never gets a chance to poll for
the very request it was interested in.

Fix this by ensuring that the polling drops the uring_ctx occasionally
if it's not making any progress.

Reported-by: Jeffrey M. Birnbaum <jmbnyc@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/io_uring.c