mbox series

[v3,0/2] io_uring/zcrx: recvzc read limit

Message ID 20250224041319.2389785-1-dw@davidwei.uk (mailing list archive)
Headers show
Series io_uring/zcrx: recvzc read limit | expand

Message

David Wei Feb. 24, 2025, 4:13 a.m. UTC
Currently multishot recvzc requests have no read limit and will remain
active so as long as the socket remains open. But, there are sometimes a
need to do a fixed length read e.g. peeking at some data in the socket.

Add a length limit to recvzc requests `len`. A value of 0 means no limit
which is the previous behaviour. A positive value N specifies how many
bytes to read from the socket.

Also add a new selftest case.

Changes in v3:
--------------
* Remove all references to 'singleshot'
* Use 0 to mean no limit
* Remove unused var `limit`
* Complete recvzc req early when len == 0
* Revert return codes in io_zcrx_tcp_recvmsg()
* Check explicitly that ret > 0

Changes in v2:
--------------
* Consistently use u32/unsigned int for len
* Remove nowait semantics, request will not complete until requested len
  has been received
* Always set REQ_F_APOLL_MULTISHOT
* Fix return codes from io_recvzc request
* Fix changing len if set to UINT_MAX in io_zcrx_recv_skb()
* Use read_desc->count

David Wei (2):
  io_uring/zcrx: add a read limit to recvzc requests
  io_uring/zcrx: add selftest case for recvzc with read limit

 io_uring/net.c                                | 16 +++++--
 io_uring/zcrx.c                               | 13 ++++--
 io_uring/zcrx.h                               |  2 +-
 .../selftests/drivers/net/hw/iou-zcrx.c       | 43 ++++++++++++++++---
 .../selftests/drivers/net/hw/iou-zcrx.py      | 27 +++++++++++-
 5 files changed, 85 insertions(+), 16 deletions(-)

Comments

Jens Axboe Feb. 24, 2025, 2:35 p.m. UTC | #1
On Sun, 23 Feb 2025 20:13:17 -0800, David Wei wrote:
> Currently multishot recvzc requests have no read limit and will remain
> active so as long as the socket remains open. But, there are sometimes a
> need to do a fixed length read e.g. peeking at some data in the socket.
> 
> Add a length limit to recvzc requests `len`. A value of 0 means no limit
> which is the previous behaviour. A positive value N specifies how many
> bytes to read from the socket.
> 
> [...]

Applied, thanks!

[1/2] io_uring/zcrx: add a read limit to recvzc requests
      commit: 9a53ea6aa5c87fe4c49297158e7982dbe4f96227
[2/2] io_uring/zcrx: add selftest case for recvzc with read limit
      commit: f4b4948fb824a9fbaff906d96f6d575305842efc

Best regards,
Jens Axboe Feb. 24, 2025, 7:56 p.m. UTC | #2
On 2/24/25 7:35 AM, Jens Axboe wrote:
> 
> On Sun, 23 Feb 2025 20:13:17 -0800, David Wei wrote:
>> Currently multishot recvzc requests have no read limit and will remain
>> active so as long as the socket remains open. But, there are sometimes a
>> need to do a fixed length read e.g. peeking at some data in the socket.
>>
>> Add a length limit to recvzc requests `len`. A value of 0 means no limit
>> which is the previous behaviour. A positive value N specifies how many
>> bytes to read from the socket.
>>
>> [...]
> 
> Applied, thanks!
> 
> [1/2] io_uring/zcrx: add a read limit to recvzc requests
>       commit: 9a53ea6aa5c87fe4c49297158e7982dbe4f96227
> [2/2] io_uring/zcrx: add selftest case for recvzc with read limit
>       commit: f4b4948fb824a9fbaff906d96f6d575305842efc

Fixed up 1/2 for !CONFIG_NET, fwiw.
David Wei Feb. 24, 2025, 8:33 p.m. UTC | #3
On 2025-02-24 11:56, Jens Axboe wrote:
> On 2/24/25 7:35 AM, Jens Axboe wrote:
>>
>> On Sun, 23 Feb 2025 20:13:17 -0800, David Wei wrote:
>>> Currently multishot recvzc requests have no read limit and will remain
>>> active so as long as the socket remains open. But, there are sometimes a
>>> need to do a fixed length read e.g. peeking at some data in the socket.
>>>
>>> Add a length limit to recvzc requests `len`. A value of 0 means no limit
>>> which is the previous behaviour. A positive value N specifies how many
>>> bytes to read from the socket.
>>>
>>> [...]
>>
>> Applied, thanks!
>>
>> [1/2] io_uring/zcrx: add a read limit to recvzc requests
>>       commit: 9a53ea6aa5c87fe4c49297158e7982dbe4f96227
>> [2/2] io_uring/zcrx: add selftest case for recvzc with read limit
>>       commit: f4b4948fb824a9fbaff906d96f6d575305842efc
> 
> Fixed up 1/2 for !CONFIG_NET, fwiw.
> 

Thanks, and sorry for the noise. I'll be sure to compile check
!CONFIG_NET next time.
Jens Axboe Feb. 24, 2025, 10:38 p.m. UTC | #4
On 2/24/25 1:33 PM, David Wei wrote:
> On 2025-02-24 11:56, Jens Axboe wrote:
>> On 2/24/25 7:35 AM, Jens Axboe wrote:
>>>
>>> On Sun, 23 Feb 2025 20:13:17 -0800, David Wei wrote:
>>>> Currently multishot recvzc requests have no read limit and will remain
>>>> active so as long as the socket remains open. But, there are sometimes a
>>>> need to do a fixed length read e.g. peeking at some data in the socket.
>>>>
>>>> Add a length limit to recvzc requests `len`. A value of 0 means no limit
>>>> which is the previous behaviour. A positive value N specifies how many
>>>> bytes to read from the socket.
>>>>
>>>> [...]
>>>
>>> Applied, thanks!
>>>
>>> [1/2] io_uring/zcrx: add a read limit to recvzc requests
>>>       commit: 9a53ea6aa5c87fe4c49297158e7982dbe4f96227
>>> [2/2] io_uring/zcrx: add selftest case for recvzc with read limit
>>>       commit: f4b4948fb824a9fbaff906d96f6d575305842efc
>>
>> Fixed up 1/2 for !CONFIG_NET, fwiw.
>>
> 
> Thanks, and sorry for the noise. I'll be sure to compile check
> !CONFIG_NET next time.

Easy to miss, and the kernel test bot always finds them. So not a huge
deal.