From patchwork Fri Sep 22 05:24:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 143244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5396278vqi; Fri, 22 Sep 2023 01:03:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGafsBiUBMttinpUlDi5m9TF5/TnfxfvYeBZWCazHoWtjf7rfDAf84lOV0P/XOQKQicief X-Received: by 2002:a05:6870:3052:b0:1b0:1e3b:5c21 with SMTP id u18-20020a056870305200b001b01e3b5c21mr7866856oau.1.1695369836796; Fri, 22 Sep 2023 01:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695369836; cv=none; d=google.com; s=arc-20160816; b=xjmwNizCorhYhdx5BewbqiAQy3IH9lJbDRzqcYAYIekWr5BMeqXZilD9hZniezEMFN B512k4y/ZlYq+kDv28+ImGkCB7KIE0IRzP1WP+K6w/5ykqwuZ5VkmroFokDhMjMQlPae 84Dg9z6gNbUu2laTJ7amS1Thi5oLqQkC1s+f7DCRAMrtHCN6D+V78Fq7k2RMYDDxzbvy fdZ7vfc4FCUXH+vUsN40wJ3oUlGPUNn5OjcQ2PAJCIdk6KTjLwGHm9helTe0byWCh0tE 7Q7K5AGnCxQKWCCdyccMZL1ysIOmHQ/1hYNvv3xnYbbDt3Q1Ei7UQs5sFt/zA+1SETD9 MmoQ== 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:dkim-filter; bh=Z9QjSJ6cghhhAlFPs4XS22HdVsw9F7q+6wRxQ20lZSA=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=rKKiYlbzhLMPNnLs49sBy1clS9LAo6A/8AO/F3007QrCebtdHOWM/uQe7TqCEeXRgW ZEtP79n6hbmAMAHTQ7laiAq60AlSwPnrGfmTiuMtQ8xDeXuGUgvCTB9sysAIk0kCoxT0 da51ngXVv66BHC7fgMCmLAgrilL7b3NdMsvz+XF95Fj7pjCLINdPoWsCEl3cnR776Qwf SzgaCAhDX8cpOBVOQCBs7NismUz7Fjl3JkL6qtUzElY+urgAewaN+rtfAnAj1qcJlxI0 YOfAxjd8Mkv8ffRKSuo9FS5ALpHBkt1adl22Qb1ovLePMYdhz+1Y0Wer53ZaCd1D9oF4 OMxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=cc6QqTiA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k63-20020a636f42000000b00577a519621bsi3183161pgc.231.2023.09.22.01.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 01:03:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=cc6QqTiA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 310198208AD8; Thu, 21 Sep 2023 22:32:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231373AbjIVFcW (ORCPT + 30 others); Fri, 22 Sep 2023 01:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbjIVFbx (ORCPT ); Fri, 22 Sep 2023 01:31:53 -0400 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51DB619D; Thu, 21 Sep 2023 22:31:46 -0700 (PDT) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id D53E010000C; Fri, 22 Sep 2023 08:31:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru D53E010000C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1695360704; bh=Z9QjSJ6cghhhAlFPs4XS22HdVsw9F7q+6wRxQ20lZSA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=cc6QqTiAf5rBzJtFlpV8yrV2XZh5t6p3rTrpfTxDfFaQ3hV1VsIAXQXxaJSqRd7Xg i1tEFvJX1heZHPYc5yeKkmFv201WrmmOfmwajXySPvk7AywweD3jaCQP7fbpoc1kj2 fqhW7pBarhjI7pP626hLsRMviehyeCNZAX5KhRblkGYywp5LaUYr4KySm2P/fUSGlT qVvwqcO6Y5xxMQMqzIOvRbbIQv4GMshtJfmbjdFchbpzeTGMLuWNlxSQcZDJ2wMCiu DCG6lrbWUKINxa6UgMcnR8hBufBDgRwXegMpb3idkTAtg5LP1XbKxAmm5avNBmTyG2 lM6CpzEy56vDw== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Fri, 22 Sep 2023 08:31:44 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 22 Sep 2023 08:31:44 +0300 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: , , , , , , Subject: [PATCH net-next v1 09/12] docs: net: description of MSG_ZEROCOPY for AF_VSOCK Date: Fri, 22 Sep 2023 08:24:25 +0300 Message-ID: <20230922052428.4005676-10-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230922052428.4005676-1-avkrasnov@salutedevices.com> References: <20230922052428.4005676-1-avkrasnov@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 180033 [Sep 21 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 534 534 808c2ea49f7195c68d40844e073217da4fa0d1e3, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;salutedevices.com:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1;100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/09/22 02:22:00 #21944311 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 22:32:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777724121770467584 X-GMAIL-MSGID: 1777724121770467584 This adds description of MSG_ZEROCOPY flag support for AF_VSOCK type of socket. Signed-off-by: Arseniy Krasnov --- Changelog: v5(big patchset) -> v1: * Add information about 'VSOCK_RECVERR'. * Do not break line for test path. Documentation/networking/msg_zerocopy.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/msg_zerocopy.rst b/Documentation/networking/msg_zerocopy.rst index b3ea96af9b49..78fb70e748b7 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,9 @@ 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). +For VSOCK socket, cmsg_level will be SOL_VSOCK and cmsg_type will be +VSOCK_RECVERR. 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 @@ -235,12 +238,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 +260,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.