From patchwork Sat Jun 3 20:49:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 102910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1841110vqr; Sat, 3 Jun 2023 13:56:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VgVVTrd8vKvF7LTUjfgv9yDA5YXhWPXDktzSGaDG45iTdKoxJasA/2Zv2FZMaa5I+fkEF X-Received: by 2002:a05:6870:a487:b0:18b:999:aa27 with SMTP id j7-20020a056870a48700b0018b0999aa27mr5105453oal.52.1685825799308; Sat, 03 Jun 2023 13:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685825799; cv=none; d=google.com; s=arc-20160816; b=vSAVVxSG1XAMoBvD4cdm1mAHqegpib0uL35epUYQmeHJ9iOpVTrM52tnswNr/vBIl8 JapTDoC47d+YcB2vl3Uviw7BTElChEN83lM/o9kMaqsN/gZsd9S6e/8uia7on/vHYTvq MooaWpDcn84yKR6AuthtlETtQH8Dm+oj+P3/7LJ2wYL8Av6ntbbTcIyAjBK9TVqsu6+y 3bnTqFbR53cd7R24EILXW74/vgo9w6zHW3kSm7ChGG/KEtdxy7rpYeHYJ6ANb2Qaeaz4 tAStUTTuX/OxSkNokHV0kz8dsR+zSmjswSDVwAmvDHl4n5P9OJadCKz+IaK7rmObtwlk lirQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tL2E1Y90S5bBkA16ZM0oXYsz18KCFk1Zn9JPdTBbPT8=; b=Zu6nhdsa6UeRt1BDF6mQEHQJzudHWDpYylur4cDQePZ+FF8uXuQrKjjxm+OSXWTxGA vwg2dqwmHRJKCStStpKK313Ksccl9uh3vD+cdTZkYeFh0nOE76TfuUDPbBLdTn47cwAS 0DennDqyHT83QFms5iCy6A6BNAbB67N5bX7a1hPQRBFFLViRbRBXPGTlHzvcSi8bVXnl H2GcP6rRLayihKiJIgwqjuSWScyXyflxYGQSPZJ7cIRYFaUJoKnou2+whul1e6UuGINa Hi6hhb/gVYW1DEbsi2ar+rtbjbpq/vZXdpTaeeI3ujE07ojPm5aSyhiXcIPJuLVugN5Q z9Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=RkDGbgFF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u72-20020a63794b000000b0053f24deef11si3124344pgc.318.2023.06.03.13.56.27; Sat, 03 Jun 2023 13:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=RkDGbgFF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233786AbjFCUzi (ORCPT + 99 others); Sat, 3 Jun 2023 16:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbjFCUzG (ORCPT ); Sat, 3 Jun 2023 16:55:06 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 703E71B4; Sat, 3 Jun 2023 13:54:57 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id B1DF35FD3E; Sat, 3 Jun 2023 23:54:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685825689; bh=tL2E1Y90S5bBkA16ZM0oXYsz18KCFk1Zn9JPdTBbPT8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=RkDGbgFFU3bql1NGpMnKp+sa9IgXSPVYdj8wJKb0NlMmUzuWkI6vLkSJpc/A+hgXp kR74vj1zoSnvFHiZ/jjkyeTAL+IDmnGVsFcYNElktnQq56H/m8OuWBEgXWTWFEdEQE Pw/mXw40KB8+rXlmn1YmxHnmqkxOepdFxD9Z8klnFZAy8P83qOLcEx67Vyq8jVf7On K7URpoNHn090hPm81Ta1ZjcuFkpe9DSkSiPlOa47oadsbBuvBF3/xzUN4URPbFjO7W /zA3FCSJ+1IPqEFggnPF0HpLRlR9kK1qvFbnp5T5CZ2lcFlIqXdwDJ6Sk88BrGWVYR dmqRm3sQsVYew== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sat, 3 Jun 2023 23:54:49 +0300 (MSK) From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v4 14/17] docs: net: description of MSG_ZEROCOPY for AF_VSOCK Date: Sat, 3 Jun 2023 23:49:36 +0300 Message-ID: <20230603204939.1598818-15-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> References: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/03 16:55:00 #21417531 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767716473316667855?= X-GMAIL-MSGID: =?utf-8?q?1767716473316667855?= This adds description of MSG_ZEROCOPY flag support for AF_VSOCK type of socket. Signed-off-by: Arseniy Krasnov --- 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. 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.