diff mbox series

[RFC,v5,14/17] docs: net: description of MSG_ZEROCOPY for AF_VSOCK

Message ID 20230701063947.3422088-15-AVKrasnov@sberdevices.ru (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series vsock: MSG_ZEROCOPY flag support | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches (and no cover letter)
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 2 maintainers not CCed: corbet@lwn.net linux-doc@vger.kernel.org
netdev/build_clang fail Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 45 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Arseniy Krasnov July 1, 2023, 6:39 a.m. UTC
This adds description of MSG_ZEROCOPY flag support for AF_VSOCK type of
socket.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 Documentation/networking/msg_zerocopy.rst | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Stefano Garzarella July 6, 2023, 5:06 p.m. UTC | #1
On Sat, Jul 01, 2023 at 09:39:44AM +0300, Arseniy Krasnov wrote:
>This adds description of MSG_ZEROCOPY flag support for AF_VSOCK type of
>socket.
>
>Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>---
> Documentation/networking/msg_zerocopy.rst | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/Documentation/networking/msg_zerocopy.rst b/Documentation/networking/msg_zerocopy.rst
>index b3ea96af9b49..34bc7ff411ce 100644
>--- a/Documentation/networking/msg_zerocopy.rst
>+++ b/Documentation/networking/msg_zerocopy.rst
>@@ -7,7 +7,8 @@ Intro
> =====
>
> The MSG_ZEROCOPY flag enables copy avoidance for socket send calls.
>-The feature is currently implemented for TCP and UDP sockets.
>+The feature is currently implemented for TCP, UDP and VSOCK (with
>+virtio transport) sockets.
>
>
> Opportunity and Caveats
>@@ -174,7 +175,7 @@ read_notification() call in the previous snippet. A notification
> is encoded in the standard error format, sock_extended_err.
>
> The level and type fields in the control data are protocol family
>-specific, IP_RECVERR or IPV6_RECVERR.
>+specific, IP_RECVERR or IPV6_RECVERR (for TCP or UDP socket).
>
> Error origin is the new type SO_EE_ORIGIN_ZEROCOPY. ee_errno is zero,
> as explained before, to avoid blocking read and write system calls on
>@@ -201,6 +202,7 @@ undefined, bar for ee_code, as discussed below.
>
>       printf("completed: %u..%u\n", serr->ee_info, serr->ee_data);
>
>+For VSOCK socket, cmsg_level will be SOL_VSOCK and cmsg_type will be 0.

Maybe better to move up, just under the previous change.

By the way, should we define a valid type value for vsock
(e.g. VSOCK_RECVERR)?

>
> Deferred copies
> ~~~~~~~~~~~~~~~
>@@ -235,12 +237,15 @@ Implementation
> Loopback
> --------
>
>+For TCP and UDP:
> Data sent to local sockets can be queued indefinitely if the receive
> process does not read its socket. Unbound notification latency is not
> acceptable. For this reason all packets generated with MSG_ZEROCOPY
> that are looped to a local socket will incur a deferred copy. This
> includes looping onto packet sockets (e.g., tcpdump) and tun devices.
>
>+For VSOCK:
>+Data path sent to local sockets is the same as for non-local sockets.
>
> Testing
> =======
>@@ -254,3 +259,6 @@ instance when run with msg_zerocopy.sh between a veth pair across
> namespaces, the test will not show any improvement. For testing, the
> loopback restriction can be temporarily relaxed by making
> skb_orphan_frags_rx identical to skb_orphan_frags.
>+
>+For VSOCK type of socket example can be found in  tools/testing/vsock/
>+vsock_test_zerocopy.c.

For VSOCK socket, example can be found in
tools/testing/vsock/vsock_test_zerocopy.c

(we should leave the entire path on the same line)

>--
>2.25.1
>
Arseniy Krasnov July 7, 2023, 4:45 a.m. UTC | #2
On 06.07.2023 20:06, Stefano Garzarella wrote:
> On Sat, Jul 01, 2023 at 09:39:44AM +0300, Arseniy Krasnov wrote:
>> This adds description of MSG_ZEROCOPY flag support for AF_VSOCK type of
>> socket.
>>
>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>> ---
>> Documentation/networking/msg_zerocopy.rst | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/networking/msg_zerocopy.rst b/Documentation/networking/msg_zerocopy.rst
>> index b3ea96af9b49..34bc7ff411ce 100644
>> --- a/Documentation/networking/msg_zerocopy.rst
>> +++ b/Documentation/networking/msg_zerocopy.rst
>> @@ -7,7 +7,8 @@ Intro
>> =====
>>
>> The MSG_ZEROCOPY flag enables copy avoidance for socket send calls.
>> -The feature is currently implemented for TCP and UDP sockets.
>> +The feature is currently implemented for TCP, UDP and VSOCK (with
>> +virtio transport) sockets.
>>
>>
>> Opportunity and Caveats
>> @@ -174,7 +175,7 @@ read_notification() call in the previous snippet. A notification
>> is encoded in the standard error format, sock_extended_err.
>>
>> The level and type fields in the control data are protocol family
>> -specific, IP_RECVERR or IPV6_RECVERR.
>> +specific, IP_RECVERR or IPV6_RECVERR (for TCP or UDP socket).
>>
>> Error origin is the new type SO_EE_ORIGIN_ZEROCOPY. ee_errno is zero,
>> as explained before, to avoid blocking read and write system calls on
>> @@ -201,6 +202,7 @@ undefined, bar for ee_code, as discussed below.
>>
>>       printf("completed: %u..%u\n", serr->ee_info, serr->ee_data);
>>
>> +For VSOCK socket, cmsg_level will be SOL_VSOCK and cmsg_type will be 0.
> 
> Maybe better to move up, just under the previous change.
> 
> By the way, should we define a valid type value for vsock
> (e.g. VSOCK_RECVERR)?

Yes I think, I'll add it in the same patch which adds SOL_VSOCK.

Thanks, Arseniy

> 
>>
>> Deferred copies
>> ~~~~~~~~~~~~~~~
>> @@ -235,12 +237,15 @@ Implementation
>> Loopback
>> --------
>>
>> +For TCP and UDP:
>> Data sent to local sockets can be queued indefinitely if the receive
>> process does not read its socket. Unbound notification latency is not
>> acceptable. For this reason all packets generated with MSG_ZEROCOPY
>> that are looped to a local socket will incur a deferred copy. This
>> includes looping onto packet sockets (e.g., tcpdump) and tun devices.
>>
>> +For VSOCK:
>> +Data path sent to local sockets is the same as for non-local sockets.
>>
>> Testing
>> =======
>> @@ -254,3 +259,6 @@ instance when run with msg_zerocopy.sh between a veth pair across
>> namespaces, the test will not show any improvement. For testing, the
>> loopback restriction can be temporarily relaxed by making
>> skb_orphan_frags_rx identical to skb_orphan_frags.
>> +
>> +For VSOCK type of socket example can be found in  tools/testing/vsock/
>> +vsock_test_zerocopy.c.
> 
> For VSOCK socket, example can be found in
> tools/testing/vsock/vsock_test_zerocopy.c
> 
> (we should leave the entire path on the same line)
> 
>> --
>> 2.25.1
>>
>
diff mbox series

Patch

diff --git a/Documentation/networking/msg_zerocopy.rst b/Documentation/networking/msg_zerocopy.rst
index b3ea96af9b49..34bc7ff411ce 100644
--- a/Documentation/networking/msg_zerocopy.rst
+++ b/Documentation/networking/msg_zerocopy.rst
@@ -7,7 +7,8 @@  Intro
 =====
 
 The MSG_ZEROCOPY flag enables copy avoidance for socket send calls.
-The feature is currently implemented for TCP and UDP sockets.
+The feature is currently implemented for TCP, UDP and VSOCK (with
+virtio transport) sockets.
 
 
 Opportunity and Caveats
@@ -174,7 +175,7 @@  read_notification() call in the previous snippet. A notification
 is encoded in the standard error format, sock_extended_err.
 
 The level and type fields in the control data are protocol family
-specific, IP_RECVERR or IPV6_RECVERR.
+specific, IP_RECVERR or IPV6_RECVERR (for TCP or UDP socket).
 
 Error origin is the new type SO_EE_ORIGIN_ZEROCOPY. ee_errno is zero,
 as explained before, to avoid blocking read and write system calls on
@@ -201,6 +202,7 @@  undefined, bar for ee_code, as discussed below.
 
 	printf("completed: %u..%u\n", serr->ee_info, serr->ee_data);
 
+For VSOCK socket, cmsg_level will be SOL_VSOCK and cmsg_type will be 0.
 
 Deferred copies
 ~~~~~~~~~~~~~~~
@@ -235,12 +237,15 @@  Implementation
 Loopback
 --------
 
+For TCP and UDP:
 Data sent to local sockets can be queued indefinitely if the receive
 process does not read its socket. Unbound notification latency is not
 acceptable. For this reason all packets generated with MSG_ZEROCOPY
 that are looped to a local socket will incur a deferred copy. This
 includes looping onto packet sockets (e.g., tcpdump) and tun devices.
 
+For VSOCK:
+Data path sent to local sockets is the same as for non-local sockets.
 
 Testing
 =======
@@ -254,3 +259,6 @@  instance when run with msg_zerocopy.sh between a veth pair across
 namespaces, the test will not show any improvement. For testing, the
 loopback restriction can be temporarily relaxed by making
 skb_orphan_frags_rx identical to skb_orphan_frags.
+
+For VSOCK type of socket example can be found in  tools/testing/vsock/
+vsock_test_zerocopy.c.