liburing: unexpected high count of io_worker threads by using the IOSQE_ASYNC flag

I am not sure if this is expected or not but I do have pretty much as many io worker threads as I have IORING_OP_READ requests on different TCP sockets.

$ uname -a
Linux tau 5.12.3-arch1-1 #1 SMP PREEMPT Wed, 12 May 2021 17:54:18 +0000 x86_64 GNU/Linux

$ ps -L --pid 10334
    PID     LWP TTY          TIME CMD
  10334   10334 pts/0    00:00:00 test
  10334   10336 pts/0    00:00:00 Logging
  10334   10338 pts/0    00:00:00 Housekeeping
  10334   10339 pts/0    00:00:00 iou-mgr-10334
  10334   10341 pts/0    00:00:00 MariaDB 
  10334   10342 pts/0    00:00:00 Account 
  10334   10343 pts/0    00:00:00 Execution SVC
  10334   10344 pts/0    00:00:00 iou-mgr-10343
  10334   10345 pts/0    00:00:00 iou-wrk-10343
  10334   10346 pts/0    00:00:00 iou-wrk-10343
  10334   10347 pts/0    00:00:00 iou-wrk-10334
  10334   10348 pts/0    00:00:00 iou-wrk-10334
  10334   10349 pts/0    00:00:00 iou-wrk-10334
  10334   10350 pts/0    00:00:00 iou-wrk-10334
  10334   10351 pts/0    00:00:00 iou-wrk-10334
  10334   10352 pts/0    00:00:00 iou-wrk-10334
  10334   10353 pts/0    00:00:00 iou-wrk-10334
  10334   10354 pts/0    00:00:00 iou-wrk-10334
  10334   10355 pts/0    00:00:00 iou-wrk-10334
  10334   10356 pts/0    00:00:00 iou-wrk-10334
  10334   10357 pts/0    00:00:00 iou-wrk-10334
  10334   10358 pts/0    00:00:00 iou-wrk-10334
  10334   10359 pts/0    00:00:00 iou-wrk-10334
  10334   10360 pts/0    00:00:00 iou-wrk-10334
  10334   10361 pts/0    00:00:00 iou-wrk-10334
  10334   10362 pts/0    00:00:00 iou-wrk-10334
  10334   10363 pts/0    00:00:00 iou-wrk-10334
  10334   10364 pts/0    00:00:00 iou-wrk-10334
  10334   10365 pts/0    00:00:00 iou-wrk-10334
  10334   10366 pts/0    00:00:00 iou-wrk-10334
  10334   10367 pts/0    00:00:00 iou-wrk-10334
  10334   10368 pts/0    00:00:00 iou-wrk-10334
  10334   10369 pts/0    00:00:00 iou-wrk-10334
  10334   10370 pts/0    00:00:00 iou-wrk-10334
  10334   10371 pts/0    00:00:00 iou-wrk-10334
  10334   10372 pts/0    00:00:00 iou-wrk-10334
  10334   10373 pts/0    00:00:00 iou-wrk-10334
  10334   10374 pts/0    00:00:00 iou-wrk-10334
  10334   10375 pts/0    00:00:00 iou-wrk-10334
  10334   10376 pts/0    00:00:00 iou-wrk-10334
  10334   10377 pts/0    00:00:00 iou-wrk-10334
  10334   10378 pts/0    00:00:00 iou-wrk-10334
  10334   10379 pts/0    00:00:00 iou-wrk-10334
  10334   10380 pts/0    00:00:00 iou-wrk-10334
  10334   10381 pts/0    00:00:00 iou-wrk-10334
  10334   10382 pts/0    00:00:00 iou-wrk-10334
  10334   10383 pts/0    00:00:00 iou-wrk-10334
  10334   10384 pts/0    00:00:00 iou-wrk-10334
  10334   10385 pts/0    00:00:00 iou-wrk-10334
  10334   10386 pts/0    00:00:00 iou-wrk-10334
  10334   10387 pts/0    00:00:00 iou-wrk-10334
  10334   10388 pts/0    00:00:00 iou-wrk-10334
  10334   10389 pts/0    00:00:00 iou-wrk-10334
  10334   10390 pts/0    00:00:00 iou-wrk-10334
  10334   10391 pts/0    00:00:00 iou-wrk-10334
  10334   10392 pts/0    00:00:00 iou-wrk-10334
  10334   10393 pts/0    00:00:00 iou-wrk-10334
  10334   10394 pts/0    00:00:00 iou-wrk-10334
  10334   10395 pts/0    00:00:00 iou-wrk-10334
  10334   10396 pts/0    00:00:00 iou-wrk-10334
  10334   10397 pts/0    00:00:00 iou-wrk-10334
  10334   10398 pts/0    00:00:00 iou-wrk-10334
  10334   10399 pts/0    00:00:00 iou-wrk-10334
  10334   10400 pts/0    00:00:00 iou-wrk-10334
  10334   10401 pts/0    00:00:00 iou-wrk-10334
  10334   10402 pts/0    00:00:00 iou-wrk-10334
  10334   10403 pts/0    00:00:00 iou-wrk-10334
  10334   10404 pts/0    00:00:00 iou-wrk-10334
  10334   10405 pts/0    00:00:00 iou-wrk-10334
  10334   10406 pts/0    00:00:00 iou-wrk-10334
  10334   10407 pts/0    00:00:00 iou-wrk-10334
  10334   10408 pts/0    00:00:00 iou-wrk-10334
  10334   10409 pts/0    00:00:00 iou-wrk-10334
  10334   10410 pts/0    00:00:00 iou-wrk-10334
  10334   10411 pts/0    00:00:00 iou-wrk-10334
  10334   10412 pts/0    00:00:00 iou-wrk-10334
  10334   10413 pts/0    00:00:00 iou-wrk-10334
  10334   10414 pts/0    00:00:00 iou-wrk-10334
  10334   10415 pts/0    00:00:00 iou-wrk-10334
  10334   10416 pts/0    00:00:00 iou-wrk-10334
  10334   10417 pts/0    00:00:00 iou-wrk-10334
  10334   10418 pts/0    00:00:00 iou-wrk-10334
  10334   10419 pts/0    00:00:00 iou-wrk-10334
  10334   10420 pts/0    00:00:00 iou-wrk-10334
  10334   10421 pts/0    00:00:00 iou-wrk-10334
  10334   10422 pts/0    00:00:00 iou-wrk-10334
  10334   10423 pts/0    00:00:00 iou-wrk-10334
  10334   10424 pts/0    00:00:00 iou-wrk-10334
  10334   10425 pts/0    00:00:00 iou-wrk-10334
  10334   10426 pts/0    00:00:00 iou-wrk-10334
  10334   10427 pts/0    00:00:00 iou-wrk-10334
  10334   10428 pts/0    00:00:00 iou-wrk-10334
  10334   10429 pts/0    00:00:00 iou-wrk-10334
  10334   10430 pts/0    00:00:00 iou-wrk-10334
  10334   10431 pts/0    00:00:00 iou-wrk-10334
  10334   10432 pts/0    00:00:00 iou-wrk-10334

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17

Most upvoted comments

oh, and I have another question… Since it is kinda related to this one, I am going slip it here instead of creating a new issue.

I am starting to consider playing with more than 2 io_uring instances and I have noticed the IORING_SETUP_ATTACH_WQ setup option.

That sounds like a very good idea! What could be the reasons for NOT using this feature? What is the best way to measure the load of the io workers to figure out that there is too much contention from the various io_uring instances to justify letting some instances using a private thread pool?

Does the constraint of not being allowed to mix and match polled and non-polled I/O from using IORING_SETUP_IOPOLL is propagated to the second io_uring when it attaches itself with IORING_SETUP_ATTACH_WQ?

No, can be intermixed

ie: Could the first io_uring be a IORING_SETUP_IOPOLL instance and the second attached io_uring using IORING_SETUP_ATTACH_WQ is not?

Yes

ok, based on what I have understood from my fs/io_uring.c digging, asynchronous worker thread backend = SQPOLL thread.

Wrong

Why?

The only places where wq_fd is accessed are: io_attach_sq_data() and io_sq_offload_create()

io_attach_sq_data() appears to be only called from io_get_sq_data() which is called from io_sq_offload_create()…

So in the end only when SQPOLL is created that wq_fd is accessed. Therefore my conclusion that it is only useful for it…

Exactly, since 5.12 it’s effectively used only for SQPOLL, but that doesn’t mean that worker thread backend is SQPOLL. Legacy reasons… just think that it’s IORING_SETUP_ATTACH and attach_fd and nothing with wq in naming.