From patchwork Mon May 22 07:39:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 97153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1273372vqo; Mon, 22 May 2023 00:47:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NFGjYeIN6DzZUu+MTxmzA5oJEewFyNssIIdzbd0VcVWkK5VQPs6eLBzoe/WpnLlYWBM57 X-Received: by 2002:a05:6a21:78a4:b0:10a:dd89:420f with SMTP id bf36-20020a056a2178a400b0010add89420fmr7283605pzc.6.1684741644581; Mon, 22 May 2023 00:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741644; cv=none; d=google.com; s=arc-20160816; b=ewsULSHoLNkKod3e35ETJg7H87ORYlJeprJ4q+m20B7xuPW+7AJ8SLlGMx+15awFUJ mjEhee5uUmtgwonHzGYrbCgwnnauaKq/urX2vZz57z8/UeCjNlkdfKVExt91ZerN+TsK p1fFjgD5vAhAzol2G4sN01ArAXSBhszgnGvTRtoJhKUli9u88rq/0vX/4mPSMlOHf9GK VmqITB3+LVuGhJxMQc0ub4Y0TKL9giiCePjfbnB0523Qjh0qdAbOu/9uuqgxfIrbG96o jRwoZvaWmYqLdeEgj86Q66fwIkxpmamcl6GqtO04etcza4IF8prhDLZLciGmXWBZ6wm+ K0cA== 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=rdOhUerakR8PkBSqvNyyaQ4KUq1usiTH07SMuCH4gko=; b=JU6J11xox6ddoo4uZmrhjKD1bIl/ZfdhGGpplWxrFPVFs/r7IeE54VF6Y82fOHGZFJ n6MWR7HzOlMKoFr8kI3xyA5CAJOqIWGC72Flv4WOzWt5ilju0lVzGA+CHoD6kxtCNbjf Ow5F/plMMCpl/VDzWTJlDvWczQUeX17FFjQ3c9c4T2qLM9ialqRFAC471Oc9QlNHZF/N Ky/RjCysJiOEybImY89uphOoJqN/VXtYOVzNAuwqXpJJPhAcsY8hzcPKosRlzVWjoO16 IVLtJaTzncwf71AXkpZGh2DHoAXeeDifYg1Z8KJpmzqCDKseU2J0jN1AxX6sc45u576z SjNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=afhzMxdk; 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 bk13-20020a056a02028d00b0053b86623b4esi419948pgb.83.2023.05.22.00.47.12; Mon, 22 May 2023 00:47:24 -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=afhzMxdk; 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 S232769AbjEVHpm (ORCPT + 99 others); Mon, 22 May 2023 03:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232667AbjEVHox (ORCPT ); Mon, 22 May 2023 03:44:53 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7BBAC; Mon, 22 May 2023 00:44:52 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id E31415FD52; Mon, 22 May 2023 10:44:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741489; bh=rdOhUerakR8PkBSqvNyyaQ4KUq1usiTH07SMuCH4gko=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=afhzMxdkDtJUmBXzFtC7IxMqv6onxs+XsBptdqzYoOCTGQd2AyLHJl4NtJ27Z/esk jpeIdiSteqcvNwzWT+N6ULi3n/Hw4hH+s58W2XLjQP1YKLOuGZTHxPZlocXVyXW8vs FwCi7xD3YJ77rryf6ny+UYH1fz3SI+6UVJRbwm7Znv2QuqL1NU9yivRbIo8ws8+AWZ dUznSEF0JA4FMb0kt0BOqVU3YbUlqnXtkYRIKWPu4Pfnr98FRpKo4q+ZoMu9Fd79i5 eGJKT46r2bWgsqunoXymFfJY/F55XL495sPs77MYTx4p3xyFGVqost4qW9HSfKQPn/ dXnDXfADInQJg== 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: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 v3 08/17] vsock: check for MSG_ZEROCOPY support Date: Mon, 22 May 2023 10:39:41 +0300 Message-ID: <20230522073950.3574171-9-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?1766579654867890888?= X-GMAIL-MSGID: =?utf-8?q?1766579654867890888?= 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 b2da791d920b..dbfe82ee7769 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);