io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Race between io_wqe_worker() and io_wqe_wake_worker()
@ 2021-08-03  1:05 Nadav Amit
  2021-08-03 13:22 ` Jens Axboe
  0 siblings, 1 reply; 11+ messages in thread
From: Nadav Amit @ 2021-08-03  1:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring

Hello Jens,

I encountered an issue, which appears to be a race between io_wqe_worker() and io_wqe_wake_worker(). I am not sure how to address this issue and whether I am missing something, since this seems to occur in a common scenario. Your feedback (or fix ;-)) would be appreciated.

I run on 5.13 a workload that issues multiple async read operations that should run concurrently. Some read operations can not complete for unbounded time (e.g., read from a pipe that is never written to). The problem is that occasionally another read operation that should complete gets stuck. My understanding, based on debugging and the code is that the following race (or similar) occurs:


  cpu0					cpu1
  ----					----
					io_wqe_worker()
					 schedule_timeout()
					 // timed out
  io_wqe_enqueue()
   io_wqe_wake_worker()
    // work_flags & IO_WQ_WORK_CONCURRENT
    io_wqe_activate_free_worker()
					 io_worker_exit()


Basically, io_wqe_wake_worker() can find a worker, but this worker is about to exit and is not going to process further work. Once the worker exits, the concurrency level decreases and async work might be blocked by another work. I had a look at 5.14, but did not see anything that might address this issue.

Am I missing something?

If not, all my ideas for a solution are either complicated (track required concurrency-level) or relaxed (span another worker on io_worker_exit if work_list of unbounded work is not empty).

As said, feedback would be appreciated.

Thanks,
Nadav



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-08-03 21:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  1:05 Race between io_wqe_worker() and io_wqe_wake_worker() Nadav Amit
2021-08-03 13:22 ` Jens Axboe
2021-08-03 14:37   ` Jens Axboe
2021-08-03 17:25     ` Hao Xu
2021-08-03 18:04     ` Nadav Amit
2021-08-03 18:14       ` Jens Axboe
2021-08-03 19:20         ` Nadav Amit
2021-08-03 19:24           ` Jens Axboe
2021-08-03 19:53             ` Jens Axboe
2021-08-03 21:16               ` Nadav Amit
2021-08-03 21:25                 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).