From patchwork Mon May 22 07:39:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 97159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1274591vqo; Mon, 22 May 2023 00:50:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7G3idDQBRIyINtxoec24rOjMxh2gwTaX6FZiSku/LfVlQSc37Z3ejtpYSsgFUNcaKCd25z X-Received: by 2002:a17:902:d4c5:b0:1ac:6b92:70c8 with SMTP id o5-20020a170902d4c500b001ac6b9270c8mr12994747plg.48.1684741842525; Mon, 22 May 2023 00:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741842; cv=none; d=google.com; s=arc-20160816; b=bHj1zulvtM0mQO2zSxJF7/6QZE7Fyb9HAXPr1dOi9AV9eucNWVWy8wIJUlDkR+RVhb ZshG98BxezO10vWhXAKL6rwpEHBsSw7v3dfgt1Vfr7sFNzyGqvkHsIwsugIyw1cwaolJ ByMkPWifs4qf7hykhuMEAoUxyv/bVSrs4tHBkRqbq1wOZNFYxHNpuXVRxRJ8Lf7zjh+0 lQ4x7LOp9OXBuFkXwCvcCDuynUtfb241nFgTZGnDNxA1X5DSLqiXZyFOPBYx17U1rOPg RyWQF61kWixKuOHaYaeXr0xC3PfP5G/kCdqBo2oFy17b94e/nnghxsGVtvDvZiMZVHf/ XqxQ== 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=bssnvLexqEUxF02BGzlDNoUHg0Dh1EhcDs119IBL86zvGY6JJrKQ+1rALZaikRWLi7 ydi9AxYNQiN/5EMFqOdnxjPAn7fnqD+kFX/U2YisO6QqpUVCzwRaNoskvsxnz021p66X xQkEwzBkHC5B+gYxrzodAnJzUncaY8a0975xHcCT3R3eFusOGyhT17a6q+bD+M1yMQWt RGEBPNqnuM65IBOnsC1YG45woXPgiNu+PE0OzUzXKYqNbUzAVPn3kfXDjw5RYcIeinuK A3wBR2dwk6MYHgfANonaA03AWr0U9aVq4TAIuiq6sHNhBDGTFQV9Ji9RpOeFATygEghC AhgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=FkbuJcet; 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 j11-20020a170902da8b00b001a920be2722si4373287plx.610.2023.05.22.00.50.27; Mon, 22 May 2023 00:50:42 -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=FkbuJcet; 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 S232735AbjEVHqL (ORCPT + 99 others); Mon, 22 May 2023 03:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbjEVHpA (ORCPT ); Mon, 22 May 2023 03:45:00 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86D7B9; Mon, 22 May 2023 00:44:58 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 670A75FD58; Mon, 22 May 2023 10:44:56 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741496; bh=tL2E1Y90S5bBkA16ZM0oXYsz18KCFk1Zn9JPdTBbPT8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=FkbuJcet7/EeE21YdTm700Ur3nc8dAzhkK906t8tCzyoOguXcRwW/XJqWGWzso/TB gslDKyJwpgtxjlNA7yHGVYFvCnieFVvwizU9vcM3rEjJ2eeoph0wycEBZpFDF4y6Qb B61Y67cvLpQ6Y0ipqbOCxO6nzBvvW974Me1357J0ui5NO9iDN+/d4/haePisxdvnVu HrbYi9S7FQpHZeqm3xYOJ2jYiPHsrl0hFsSNYH1OYoKecvivVI+kWsjdoZfY225rTl wqDgvBy3WSJWpu6WjaDmRiDip3a2uCyprXUYmcd+lFk2ZZbQAxNFLOxCw2y7u8+dyx cn3POZlU5uIfg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 22 May 2023 10:44:56 +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 v3 14/17] docs: net: description of MSG_ZEROCOPY for AF_VSOCK Date: Mon, 22 May 2023 10:39:47 +0300 Message-ID: <20230522073950.3574171-15-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> References: <20230522073950.3574171-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/05/22 04:49:00 #21364689 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 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?1766579862231287518?= X-GMAIL-MSGID: =?utf-8?q?1766579862231287518?= 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.