2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-04 11:08:58 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-06-13 07:07:23 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2022-07-12 21:52:46 +01:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-04 20:29:48 -06:00
|
|
|
|
2023-03-20 11:13:49 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-06-14 12:30:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 12:30:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2022-09-08 13:20:33 +01:00
|
|
|
|
2022-07-25 10:52:06 +01:00
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
2022-09-08 13:20:33 +01:00
|
|
|
|
2022-09-21 12:17:51 +01:00
|
|
|
|
2023-01-22 10:02:55 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
2023-06-12 13:51:36 -06:00
|
|
|
|
2022-09-21 12:17:51 +01:00
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-26 12:17:48 -06:00
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
|
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
|
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2025-06-26 12:17:48 -06:00
|
|
|
|
|
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 23:10:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-27 05:52:25 -08:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-27 05:52:25 -08:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
|
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
2025-03-07 16:00:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-22 08:19:56 -06:00
|
|
|
|
|
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
|
|
|
|
|
2024-03-18 10:07:37 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
|
|
|
|
|
2022-09-26 14:35:09 +01:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2025-01-22 20:00:57 -07:00
|
|
|
|
2024-12-16 15:46:12 -05:00
|
|
|
|
|
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2024-12-16 15:46:12 -05:00
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
2024-12-16 15:46:12 -05:00
|
|
|
|
|
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
|
|
|
|
|
2024-02-25 12:52:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2024-02-25 12:52:39 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 23:10:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:18 +00:00
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2025-02-26 11:41:19 +00:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2025-02-26 11:41:16 +00:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:34 +00:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:17 +00:00
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-10-22 15:43:15 +01:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-10-22 15:43:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2025-02-26 11:41:18 +00:00
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:15 +01:00
|
|
|
|
2025-02-26 11:41:21 +00:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2025-03-07 16:00:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-02-26 16:43:01 -07:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2025-02-26 11:41:19 +00:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2025-02-26 11:41:17 +00:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
2025-01-28 20:56:13 +00:00
|
|
|
|
2025-02-26 11:41:19 +00:00
|
|
|
|
2025-01-28 20:56:13 +00:00
|
|
|
|
2025-02-26 11:41:19 +00:00
|
|
|
|
2025-02-26 11:41:17 +00:00
|
|
|
|
2025-02-26 11:41:19 +00:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:34 +00:00
|
|
|
|
2024-02-19 14:16:47 -07:00
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
2022-08-24 13:07:43 +01:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
|
|
|
|
|
2022-08-24 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2025-03-31 17:18:00 +01:00
|
|
|
|
|
|
|
|
|
2025-03-31 17:17:58 +01:00
|
|
|
|
io_uring/net: add provided buffer support for IORING_OP_SEND
It's pretty trivial to wire up provided buffer support for the send
side, just like how it's done the receive side. This enables setting up
a buffer ring that an application can use to push pending sends to,
and then have a send pick a buffer from that ring.
One of the challenges with async IO and networking sends is that you
can get into reordering conditions if you have more than one inflight
at the same time. Consider the following scenario where everything is
fine:
1) App queues sendA for socket1
2) App queues sendB for socket1
3) App does io_uring_submit()
4) sendA is issued, completes successfully, posts CQE
5) sendB is issued, completes successfully, posts CQE
All is fine. Requests are always issued in-order, and both complete
inline as most sends do.
However, if we're flooding socket1 with sends, the following could
also result from the same sequence:
1) App queues sendA for socket1
2) App queues sendB for socket1
3) App does io_uring_submit()
4) sendA is issued, socket1 is full, poll is armed for retry
5) Space frees up in socket1, this triggers sendA retry via task_work
6) sendB is issued, completes successfully, posts CQE
7) sendA is retried, completes successfully, posts CQE
Now we've sent sendB before sendA, which can make things unhappy. If
both sendA and sendB had been using provided buffers, then it would look
as follows instead:
1) App queues dataA for sendA, queues sendA for socket1
2) App queues dataB for sendB queues sendB for socket1
3) App does io_uring_submit()
4) sendA is issued, socket1 is full, poll is armed for retry
5) Space frees up in socket1, this triggers sendA retry via task_work
6) sendB is issued, picks first buffer (dataA), completes successfully,
posts CQE (which says "I sent dataA")
7) sendA is retried, picks first buffer (dataB), completes successfully,
posts CQE (which says "I sent dataB")
Now we've sent the data in order, and everybody is happy.
It's worth noting that this also opens the door for supporting multishot
sends, as provided buffers would be a prerequisite for that. Those can
trigger either when new buffers are added to the outgoing ring, or (if
stalled due to lack of space) when space frees up in the socket.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-02-19 10:46:44 -07:00
|
|
|
|
2025-03-31 17:17:59 +01:00
|
|
|
|
|
|
|
|
|
2025-07-28 20:59:53 -10:00
|
|
|
|
|
|
|
|
|
2025-10-21 22:59:30 +05:30
|
|
|
|
2025-07-28 20:59:53 -10:00
|
|
|
|
2025-03-31 17:17:59 +01:00
|
|
|
|
2022-08-24 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
2024-10-22 15:43:12 +01:00
|
|
|
|
2025-03-28 23:10:54 +00:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
2025-03-28 23:10:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
2025-03-28 23:10:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 23:10:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2025-07-28 20:59:53 -10:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-07 12:43:22 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-31 17:18:01 +01:00
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-27 09:57:27 +00:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2024-10-22 15:43:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:13 +01:00
|
|
|
|
2025-03-28 23:10:58 +00:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:14 +01:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-06 07:57:57 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:33 -06:00
|
|
|
|
2025-08-12 08:30:11 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:33 -06:00
|
|
|
|
2025-08-12 08:30:11 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-12 12:39:54 -06:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2023-06-19 09:35:34 -06:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-08-20 20:03:31 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-09-08 13:20:29 +01:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-18 13:52:42 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-31 17:18:02 +01:00
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2025-01-28 20:56:14 +00:00
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2023-05-22 13:11:10 +01:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-09-21 12:17:51 +01:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-09-08 13:20:29 +01:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 13:10:04 -07:00
|
|
|
|
|
|
|
|
|
2024-03-18 13:52:42 -06:00
|
|
|
|
2025-08-20 20:03:38 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
2024-03-01 19:43:48 +05:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-01 18:29:39 +03:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
2024-03-01 18:29:39 +03:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:56 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:33 +00:00
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-27 11:09:20 -07:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-15 16:36:23 -06:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-18 10:07:37 -06:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
2022-09-08 13:20:30 +01:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-02 16:32:51 -07:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-31 17:17:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
|
|
|
|
|
2025-02-26 11:41:15 +00:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-07 12:43:22 -07:00
|
|
|
|
|
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2023-02-24 16:01:24 +01:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2023-01-22 10:02:55 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
io_uring/net: improve recv bundles
Current recv bundles are only supported for multishot receives, and
additionally they also always post at least 2 CQEs if more data is
available than what a buffer will hold. This happens because the initial
bundle recv will do a single buffer, and then do the rest of what is in
the socket as a followup receive. As shown in a test program, if 1k
buffers are available and 32k is available to receive in the socket,
you'd get the following completions:
bundle=1, mshot=0
cqe res 1024
cqe res 1024
[...]
cqe res 1024
bundle=1, mshot=1
cqe res 1024
cqe res 31744
where bundle=1 && mshot=0 will post 32 1k completions, and bundle=1 &&
mshot=1 will post a 1k completion and then a 31k completion.
To support bundle recv without multishot, it's possible to simply retry
the recv immediately and post a single completion, rather than split it
into two completions. With the below patch, the same test looks as
follows:
bundle=1, mshot=0
cqe res 32768
bundle=1, mshot=1
cqe res 32768
where mshot=0 works fine for bundles, and both of them post just a
single 32k completion rather than split it into separate completions.
Posting fewer completions is always a nice win, and not needing
multishot for proper bundle efficiency is nice for cases that can't
necessarily use multishot.
Reported-by: Norman Maurer <norman_maurer@apple.com>
Link: https://lore.kernel.org/r/184f9f92-a682-4205-a15d-89e18f664502@kernel.dk
Fixes: 2f9c9515bdfd ("io_uring/net: support bundles for recv")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-02-08 10:50:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2024-07-02 09:16:46 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2023-05-17 12:20:44 -06:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-02 09:16:46 -06:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2025-05-21 18:51:49 -06:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
io_uring/net: improve recv bundles
Current recv bundles are only supported for multishot receives, and
additionally they also always post at least 2 CQEs if more data is
available than what a buffer will hold. This happens because the initial
bundle recv will do a single buffer, and then do the rest of what is in
the socket as a followup receive. As shown in a test program, if 1k
buffers are available and 32k is available to receive in the socket,
you'd get the following completions:
bundle=1, mshot=0
cqe res 1024
cqe res 1024
[...]
cqe res 1024
bundle=1, mshot=1
cqe res 1024
cqe res 31744
where bundle=1 && mshot=0 will post 32 1k completions, and bundle=1 &&
mshot=1 will post a 1k completion and then a 31k completion.
To support bundle recv without multishot, it's possible to simply retry
the recv immediately and post a single completion, rather than split it
into two completions. With the below patch, the same test looks as
follows:
bundle=1, mshot=0
cqe res 32768
bundle=1, mshot=1
cqe res 32768
where mshot=0 works fine for bundles, and both of them post just a
single 32k completion rather than split it into separate completions.
Posting fewer completions is always a nice win, and not needing
multishot for proper bundle efficiency is nice for cases that can't
necessarily use multishot.
Reported-by: Norman Maurer <norman_maurer@apple.com>
Link: https://lore.kernel.org/r/184f9f92-a682-4205-a15d-89e18f664502@kernel.dk
Fixes: 2f9c9515bdfd ("io_uring/net: support bundles for recv")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-02-08 10:50:34 -07:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2024-07-02 09:16:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-21 18:51:49 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
|
|
|
|
|
2025-05-21 18:51:49 -06:00
|
|
|
|
io_uring/net: improve recv bundles
Current recv bundles are only supported for multishot receives, and
additionally they also always post at least 2 CQEs if more data is
available than what a buffer will hold. This happens because the initial
bundle recv will do a single buffer, and then do the rest of what is in
the socket as a followup receive. As shown in a test program, if 1k
buffers are available and 32k is available to receive in the socket,
you'd get the following completions:
bundle=1, mshot=0
cqe res 1024
cqe res 1024
[...]
cqe res 1024
bundle=1, mshot=1
cqe res 1024
cqe res 31744
where bundle=1 && mshot=0 will post 32 1k completions, and bundle=1 &&
mshot=1 will post a 1k completion and then a 31k completion.
To support bundle recv without multishot, it's possible to simply retry
the recv immediately and post a single completion, rather than split it
into two completions. With the below patch, the same test looks as
follows:
bundle=1, mshot=0
cqe res 32768
bundle=1, mshot=1
cqe res 32768
where mshot=0 works fine for bundles, and both of them post just a
single 32k completion rather than split it into separate completions.
Posting fewer completions is always a nice win, and not needing
multishot for proper bundle efficiency is nice for cases that can't
necessarily use multishot.
Reported-by: Norman Maurer <norman_maurer@apple.com>
Link: https://lore.kernel.org/r/184f9f92-a682-4205-a15d-89e18f664502@kernel.dk
Fixes: 2f9c9515bdfd ("io_uring/net: support bundles for recv")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-02-08 10:50:34 -07:00
|
|
|
|
|
|
|
|
|
2025-05-21 18:51:49 -06:00
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
io_uring/net: improve recv bundles
Current recv bundles are only supported for multishot receives, and
additionally they also always post at least 2 CQEs if more data is
available than what a buffer will hold. This happens because the initial
bundle recv will do a single buffer, and then do the rest of what is in
the socket as a followup receive. As shown in a test program, if 1k
buffers are available and 32k is available to receive in the socket,
you'd get the following completions:
bundle=1, mshot=0
cqe res 1024
cqe res 1024
[...]
cqe res 1024
bundle=1, mshot=1
cqe res 1024
cqe res 31744
where bundle=1 && mshot=0 will post 32 1k completions, and bundle=1 &&
mshot=1 will post a 1k completion and then a 31k completion.
To support bundle recv without multishot, it's possible to simply retry
the recv immediately and post a single completion, rather than split it
into two completions. With the below patch, the same test looks as
follows:
bundle=1, mshot=0
cqe res 32768
bundle=1, mshot=1
cqe res 32768
where mshot=0 works fine for bundles, and both of them post just a
single 32k completion rather than split it into separate completions.
Posting fewer completions is always a nice win, and not needing
multishot for proper bundle efficiency is nice for cases that can't
necessarily use multishot.
Reported-by: Norman Maurer <norman_maurer@apple.com>
Link: https://lore.kernel.org/r/184f9f92-a682-4205-a15d-89e18f664502@kernel.dk
Fixes: 2f9c9515bdfd ("io_uring/net: support bundles for recv")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-02-08 10:50:34 -07:00
|
|
|
|
|
|
|
|
|
2024-07-02 09:16:46 -06:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2024-07-02 09:16:46 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2024-01-29 11:54:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-08 13:55:58 +00:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
|
|
|
|
|
2024-02-25 12:52:39 -07:00
|
|
|
|
2024-01-29 11:54:18 -07:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
|
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
|
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2024-01-29 12:00:58 -07:00
|
|
|
|
2024-01-29 11:54:18 -07:00
|
|
|
|
|
|
|
|
|
2024-03-08 13:55:58 +00:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
|
|
|
|
|
2024-03-18 13:52:42 -06:00
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-05 04:54:50 -07:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-05 04:54:50 -07:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-02-25 12:59:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-07 03:53:31 +00:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-08-20 20:03:34 -06:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:34 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:34 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 12:05:01 -06:00
|
|
|
|
2023-06-19 09:41:05 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
2023-06-19 09:41:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
2023-06-19 09:41:05 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-09-08 13:20:29 +01:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
|
|
|
|
|
2022-07-14 04:02:58 -07:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-31 17:18:02 +01:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
|
|
|
|
|
2025-07-07 19:38:45 -06:00
|
|
|
|
2025-09-02 05:19:42 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-07-15 16:02:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-25 10:17:06 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-26 12:17:48 -06:00
|
|
|
|
2025-07-07 16:54:12 -06:00
|
|
|
|
2025-06-25 10:17:06 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
|
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2024-03-18 07:36:03 -06:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 07:08:10 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-25 12:59:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-08-20 20:03:36 -06:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:32 -06:00
|
|
|
|
2024-07-02 09:37:30 -06:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2024-07-02 09:37:30 -06:00
|
|
|
|
2024-03-05 16:22:04 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-07-02 09:37:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-09-08 13:20:29 +01:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-03-05 15:39:16 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 07:08:10 -06:00
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
io_uring/kbuf: switch to storing struct io_buffer_list locally
Currently the buffer list is stored in struct io_kiocb. The buffer list
can be of two types:
1) Classic/legacy buffer list. These don't need to get referenced after
a buffer pick, and hence storing them in struct io_kiocb is perfectly
fine.
2) Ring provided buffer lists. These DO need to be referenced after the
initial buffer pick, as they need to get consumed later on. This can
be either just incrementing the head of the ring, or it can be
consuming parts of a buffer if incremental buffer consumptions has
been configured.
For case 2, io_uring needs to be careful not to access the buffer list
after the initial pick-and-execute context. The core does recycling of
these, but it's easy to make a mistake, because it's stored in the
io_kiocb which does persist across multiple execution contexts. Either
because it's a multishot request, or simply because it needed some kind
of async trigger (eg poll) for retry purposes.
Add a struct io_buffer_list to struct io_br_sel, which is always on
stack for the various users of it. This prevents the buffer list from
leaking outside of that execution context, and additionally it enables
kbuf to not even pass back the struct io_buffer_list if the given
context isn't appropriately locked already.
This doesn't fix any bugs, it's simply a defensive measure to prevent
any issues with reuse of a buffer list.
Link: https://lore.kernel.org/r/20250821020750.598432-12-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-08-20 20:03:39 -06:00
|
|
|
|
2022-06-30 02:12:23 -07:00
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
|
|
|
|
|
2022-06-30 02:12:29 -07:00
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:37 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-20 10:31:17 +01:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-20 10:31:20 +01:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
2025-04-20 10:31:20 +01:00
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-08 17:19:33 +00:00
|
|
|
|
2025-02-23 20:13:18 -08:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-14 16:09:43 -08:00
|
|
|
|
|
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-08 17:19:33 +00:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:52 +01:00
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
2022-09-08 13:20:34 +01:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
|
|
|
|
|
2022-09-23 16:23:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
|
|
|
|
|
2022-11-04 10:59:45 +00:00
|
|
|
|
2025-07-28 20:59:53 -10:00
|
|
|
|
|
|
|
|
|
2022-11-04 10:59:45 +00:00
|
|
|
|
2022-09-21 12:17:52 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2022-09-08 13:20:34 +01:00
|
|
|
|
2022-07-12 21:52:46 +01:00
|
|
|
|
2025-03-28 23:10:59 +00:00
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
2025-03-27 15:02:20 +00:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2024-03-07 12:43:22 -07:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2022-09-16 23:22:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 23:10:56 +00:00
|
|
|
|
2022-11-04 10:59:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-08 00:54:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-11-04 10:59:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2024-04-08 00:54:57 +01:00
|
|
|
|
2025-02-24 13:31:08 -08:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:45 +01:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2025-02-24 12:42:24 +00:00
|
|
|
|
2025-03-28 23:10:59 +00:00
|
|
|
|
|
|
|
|
|
2024-10-22 15:43:12 +01:00
|
|
|
|
2025-03-28 23:10:59 +00:00
|
|
|
|
2025-03-25 08:39:42 -06:00
|
|
|
|
2025-03-28 23:11:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-25 08:39:42 -06:00
|
|
|
|
2025-03-27 15:02:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 23:11:00 +00:00
|
|
|
|
|
|
|
|
|
2025-03-27 15:02:20 +00:00
|
|
|
|
2025-03-28 23:11:00 +00:00
|
|
|
|
|
|
|
|
|
2025-03-27 15:02:20 +00:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2024-06-27 13:59:44 +01:00
|
|
|
|
2022-09-08 13:20:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-27 13:59:44 +01:00
|
|
|
|
2022-09-08 13:20:32 +01:00
|
|
|
|
|
|
|
|
|
2024-06-27 13:59:44 +01:00
|
|
|
|
2022-07-12 21:52:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-08 13:20:32 +01:00
|
|
|
|
2022-07-12 21:52:50 +01:00
|
|
|
|
2022-09-08 13:20:32 +01:00
|
|
|
|
2024-06-27 13:59:44 +01:00
|
|
|
|
2022-07-12 21:52:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-26 17:15:47 +01:00
|
|
|
|
2022-07-12 21:52:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-16 07:39:31 -06:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
2024-10-16 07:39:31 -06:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2025-03-28 23:11:00 +00:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2025-03-28 23:11:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:52 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2022-09-08 13:20:34 +01:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-21 11:16:40 +01:00
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-08 14:01:10 +01:00
|
|
|
|
2025-03-25 08:39:42 -06:00
|
|
|
|
|
|
|
|
|
2024-10-16 07:39:31 -06:00
|
|
|
|
2022-07-12 21:52:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2024-04-08 00:54:57 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2023-05-22 13:11:10 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-08-24 13:07:43 +01:00
|
|
|
|
2024-03-05 09:34:21 -07:00
|
|
|
|
2022-08-04 15:15:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:31 -06:00
|
|
|
|
2022-08-04 15:15:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-24 13:07:39 +01:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2022-08-04 15:15:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-01 11:54:04 +01:00
|
|
|
|
2022-09-29 22:23:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-22 11:47:27 +00:00
|
|
|
|
2024-03-18 13:52:42 -06:00
|
|
|
|
2022-09-29 22:23:19 +01:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-07-12 21:52:43 +01:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 08:09:47 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
2025-03-07 16:00:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-08 18:21:16 +00:00
|
|
|
|
2025-03-07 16:00:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-21 11:16:41 +01:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
2024-04-08 00:54:57 +01:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-12 12:39:54 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io_uring/net: always setup an io_async_msghdr
Rather than use an on-stack one and then need to allocate and copy if
async execution is required, always grab one upfront. This should be
very cheap, and potentially even have cache hotness benefits for
back-to-back send/recv requests.
For any recv type of request, this is probably a good choice in general,
as it's expected that no data is available initially. For send this is
not necessarily the case, as space in the socket buffer is expected to
be available. However, getting a cached io_async_msghdr is very cheap,
and as it should be cache hot, probably the difference here is neglible,
if any.
A nice side benefit is that io_setup_async_msg can get killed
completely, which has some nasty iovec manipulation code.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-03-16 17:26:09 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 20:03:31 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-29 22:23:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-22 11:47:27 +00:00
|
|
|
|
2024-03-18 13:52:42 -06:00
|
|
|
|
2022-09-29 22:23:19 +01:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-09-21 12:17:54 +01:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-07 12:43:22 -07:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:53 +01:00
|
|
|
|
2022-09-28 00:51:49 +01:00
|
|
|
|
|
|
|
|
|
2022-09-21 12:17:49 +01:00
|
|
|
|
|
|
|
|
|
2024-05-08 08:17:50 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
2024-05-08 08:17:50 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-05-09 09:31:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-05-08 08:17:50 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
|
|
|
|
|
2024-05-09 09:31:05 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 14:06:15 -06:00
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-23 17:22:30 +00:00
|
|
|
|
|
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
|
|
|
|
|
2025-03-08 17:19:32 +00:00
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
2022-06-30 02:12:28 -07:00
|
|
|
|
2024-05-09 09:41:10 -06:00
|
|
|
|
2025-02-23 17:22:30 +00:00
|
|
|
|
|
|
|
|
|
2025-03-08 17:19:33 +00:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2024-03-18 20:37:22 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-20 11:13:49 -06:00
|
|
|
|
2024-03-18 20:37:22 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-11 09:11:15 +02:00
|
|
|
|
2024-03-18 20:37:22 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-16 17:20:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-30 08:40:29 -07:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
2024-03-18 20:37:22 -06:00
|
|
|
|
|
|
|
|
|
2023-03-20 11:13:49 -06:00
|
|
|
|
|
|
|
|
|
2022-10-04 20:29:48 -06:00
|
|
|
|
|
|
|
|
|
io_uring/net: ensure socket is marked connected on connect retry
io_uring does non-blocking connection attempts, which can yield some
unexpected results if a connect request is re-attempted by an an
application. This is equivalent to the following sync syscall sequence:
sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
connect(sock, &addr, sizeof(addr);
ret == -1 and errno == EINPROGRESS expected here. Now poll for POLLOUT
on sock, and when that returns, we expect the socket to be connected.
But if we follow that procedure with:
connect(sock, &addr, sizeof(addr));
you'd expect ret == -1 and errno == EISCONN here, but you actually get
ret == 0. If we attempt the connection one more time, then we get EISCON
as expected.
io_uring used to do this, but turns out that bluetooth fails with EBADFD
if you attempt to re-connect. Also looks like EISCONN _could_ occur with
this sequence.
Retain the ->in_progress logic, but work-around a potential EISCONN or
EBADFD error and only in those cases look at the sock_error(). This
should work in general and avoid the odd sequence of a repeated connect
request returning success when the socket is already connected.
This is all a side effect of the socket state being in a CONNECTING
state when we get EINPROGRESS, and only a re-connect or other related
operation will turn that into CONNECTED.
Cc: stable@vger.kernel.org
Fixes: 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
Link: https://github.com/axboe/liburing/issues/980
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-11-03 10:35:40 -06:00
|
|
|
|
2023-03-20 11:13:49 -06:00
|
|
|
|
2022-10-04 20:29:48 -06:00
|
|
|
|
2023-03-20 11:13:49 -06:00
|
|
|
|
|
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
io_uring/net: ensure socket is marked connected on connect retry
io_uring does non-blocking connection attempts, which can yield some
unexpected results if a connect request is re-attempted by an an
application. This is equivalent to the following sync syscall sequence:
sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
connect(sock, &addr, sizeof(addr);
ret == -1 and errno == EINPROGRESS expected here. Now poll for POLLOUT
on sock, and when that returns, we expect the socket to be connected.
But if we follow that procedure with:
connect(sock, &addr, sizeof(addr));
you'd expect ret == -1 and errno == EISCONN here, but you actually get
ret == 0. If we attempt the connection one more time, then we get EISCON
as expected.
io_uring used to do this, but turns out that bluetooth fails with EBADFD
if you attempt to re-connect. Also looks like EISCONN _could_ occur with
this sequence.
Retain the ->in_progress logic, but work-around a potential EISCONN or
EBADFD error and only in those cases look at the sock_error(). This
should work in general and avoid the odd sequence of a repeated connect
request returning success when the socket is already connected.
This is all a side effect of the socket state being in a CONNECTING
state when we get EINPROGRESS, and only a re-connect or other related
operation will turn that into CONNECTED.
Cc: stable@vger.kernel.org
Fixes: 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
Link: https://github.com/axboe/liburing/issues/980
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-11-03 10:35:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-16 17:20:17 +01:00
|
|
|
|
|
|
|
|
|
io_uring/net: ensure socket is marked connected on connect retry
io_uring does non-blocking connection attempts, which can yield some
unexpected results if a connect request is re-attempted by an an
application. This is equivalent to the following sync syscall sequence:
sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
connect(sock, &addr, sizeof(addr);
ret == -1 and errno == EINPROGRESS expected here. Now poll for POLLOUT
on sock, and when that returns, we expect the socket to be connected.
But if we follow that procedure with:
connect(sock, &addr, sizeof(addr));
you'd expect ret == -1 and errno == EISCONN here, but you actually get
ret == 0. If we attempt the connection one more time, then we get EISCON
as expected.
io_uring used to do this, but turns out that bluetooth fails with EBADFD
if you attempt to re-connect. Also looks like EISCONN _could_ occur with
this sequence.
Retain the ->in_progress logic, but work-around a potential EISCONN or
EBADFD error and only in those cases look at the sock_error(). This
should work in general and avoid the odd sequence of a repeated connect
request returning success when the socket is already connected.
This is all a side effect of the socket state being in a CONNECTING
state when we get EINPROGRESS, and only a re-connect or other related
operation will turn that into CONNECTED.
Cc: stable@vger.kernel.org
Fixes: 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
Link: https://github.com/axboe/liburing/issues/980
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-11-03 10:35:40 -06:00
|
|
|
|
2025-07-16 17:20:17 +01:00
|
|
|
|
io_uring/net: ensure socket is marked connected on connect retry
io_uring does non-blocking connection attempts, which can yield some
unexpected results if a connect request is re-attempted by an an
application. This is equivalent to the following sync syscall sequence:
sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
connect(sock, &addr, sizeof(addr);
ret == -1 and errno == EINPROGRESS expected here. Now poll for POLLOUT
on sock, and when that returns, we expect the socket to be connected.
But if we follow that procedure with:
connect(sock, &addr, sizeof(addr));
you'd expect ret == -1 and errno == EISCONN here, but you actually get
ret == 0. If we attempt the connection one more time, then we get EISCON
as expected.
io_uring used to do this, but turns out that bluetooth fails with EBADFD
if you attempt to re-connect. Also looks like EISCONN _could_ occur with
this sequence.
Retain the ->in_progress logic, but work-around a potential EISCONN or
EBADFD error and only in those cases look at the sock_error(). This
should work in general and avoid the odd sequence of a repeated connect
request returning success when the socket is already connected.
This is all a side effect of the socket state being in a CONNECTING
state when we get EINPROGRESS, and only a re-connect or other related
operation will turn that into CONNECTED.
Cc: stable@vger.kernel.org
Fixes: 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
Link: https://github.com/axboe/liburing/issues/980
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-11-03 10:35:40 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 20:37:22 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2025-05-08 14:48:33 -06:00
|
|
|
|
2022-05-25 06:25:13 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2024-06-14 12:30:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-13 19:05:02 +09:00
|
|
|
|
2024-06-14 12:30:46 -04:00
|
|
|
|
|
|
|
|
|
2024-07-13 19:05:02 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 12:30:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 12:30:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-13 19:05:02 +09:00
|
|
|
|
2024-06-14 12:30:47 -04:00
|
|
|
|
|
|
|
|
|
2024-07-13 19:05:02 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 12:30:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-20 15:19:44 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|
2024-03-20 15:19:44 -06:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2025-03-07 16:00:35 +00:00
|
|
|
|
2024-03-16 15:33:53 -06:00
|
|
|
|
2022-07-07 14:30:09 -06:00
|
|
|
|