From patchwork Sat Jun 3 20:49:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 102919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1842134vqr; Sat, 3 Jun 2023 14:00:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4I3pxiomNbpCLJSO/b1Qs+Ra7x2PuzdNeYIQanVp/FkA0/JQK9BPYpaMpr+CG58iPUsYbn X-Received: by 2002:a17:902:e88f:b0:1b0:6361:a1b3 with SMTP id w15-20020a170902e88f00b001b06361a1b3mr4562800plg.53.1685826037301; Sat, 03 Jun 2023 14:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685826037; cv=none; d=google.com; s=arc-20160816; b=Wdequpx/beBrqyXus0phOnrEhucaDKlrvWuo3VcjbcRTIu6XoZWO32QT/+/c2Ptpyh k2Zvo+Y44va4Ze8hRM0LlZUiyCXvdSO0f6cD+SVncE8wBO/InqerzifrUb5Mmm8me08u e4Z0x0QH1i12jXVCoUGVQH2xQuJwhuNNtY/eHnGywpCz/+yCcOOCZxJSBfkbMAxPjqli hDn59RBSfYbrYRLqyXaj5bcFmu6z7w1FApurl9yeLwtVXhNgwb9DNYUQC47iYq66fsJP 1yDsGKxKPsWVS25mCZbBKm9f9trU/xLu3vPv0WCrEaLTegdr2vFKyx1sNmaHaCJ9Ah7U 3zQA== 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=dXr+GIu8Zm+IAJzZ6mwmY2cDmvd5mo+b/fOvW2U8kdk=; b=kqD/Y0f4N3gV+4Nfv2CnyB3HbznSv7UKPT6hpHglCiDzkN4LdVP/Fsn6YD+yGL7DBj HQ8XHZqq2ITm37i8dL2qO0IfdTMXEmqDrHxZArs/L3eknYE8f2t++YfXIoupB7o84GB/ LxXr4abppyfTL1wodyFOqnYEEt+Y+yoLwF2irX4ecPOzvCWjORrMPzKsDzEIugHX+eeE KoUGKJSLLvIGVlM1EmuoaFwHgnmN4zsxiZkAR0pdAgG/8tClaCcfawpYpTyoXuGGT7tl mJ1gZtQIp0QSPjgIXtooaEoKAJZqouIdvIEftM5ArFlbdoMD/IX6WEx19LZrmYEpXarf ksSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b="ks/7oWLt"; 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 6-20020a170902c10600b001ab007aff67si3033324pli.32.2023.06.03.14.00.25; Sat, 03 Jun 2023 14:00:37 -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="ks/7oWLt"; 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 S233584AbjFCUzX (ORCPT + 99 others); Sat, 3 Jun 2023 16:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232378AbjFCUy7 (ORCPT ); Sat, 3 Jun 2023 16:54:59 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095101A4; Sat, 3 Jun 2023 13:54:56 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 297185FD38; Sat, 3 Jun 2023 23:54:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685825688; bh=dXr+GIu8Zm+IAJzZ6mwmY2cDmvd5mo+b/fOvW2U8kdk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ks/7oWLtr330mkiMnbGgANJJCiYqGyGQCEeTfb987iEuqYyr5+9r9b7DRlEB/pxeo ISh3gxPb/3LEcuMNoNYgRLI9Gptgxf2R2yCOxKCBkr157M2hIZ9joS9NM+YUMBok6U p1+9uCsE3tGbYXuxNX4vmmhNr/MdcYvLqq3M1x+VM/m/CVsPozGt4/AG2BTkDCfrWU yOJ7dLtrywEsY6o8xwEDzs54xtn/BRpJp+8AzoWNj1jLkKPUfjjKVotOBiEDG7yGau /w++evFeX9TSkItCLzrkwu1fNuixwtgHr+eix+AZ0W44OaOfJ3shSDNmdXkoe7Obm9 57Nn/Y8yExQnw== 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:48 +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 08/17] vsock: check for MSG_ZEROCOPY support on send Date: Sat, 3 Jun 2023 23:49:30 +0300 Message-ID: <20230603204939.1598818-9-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?1767716723072903966?= X-GMAIL-MSGID: =?utf-8?q?1767716723072903966?= This feature totally depends on transport, so if transport doesn't support it, return error. Signed-off-by: Arseniy Krasnov --- include/net/af_vsock.h | 7 +++++++ net/vmw_vsock/af_vsock.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h index 0e7504a42925..ec09edc5f3a0 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -177,6 +177,9 @@ struct vsock_transport { /* Read a single skb */ int (*read_skb)(struct vsock_sock *, skb_read_actor_t); + + /* Zero-copy. */ + bool (*msgzerocopy_allow)(void); }; /**** CORE ****/ @@ -243,4 +246,8 @@ static inline void __init vsock_bpf_build_proto(void) {} #endif +static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t) +{ + return t->msgzerocopy_allow && t->msgzerocopy_allow(); +} #endif /* __AF_VSOCK_H__ */ diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 07803d9fbf6d..033006e1b5ad 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1824,6 +1824,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, goto out; } + if (msg->msg_flags & MSG_ZEROCOPY && + !vsock_msgzerocopy_allow(transport)) { + err = -EOPNOTSUPP; + goto out; + } + /* Wait for room in the produce queue to enqueue our user's data. */ timeout = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);