Message ID | 20230227-vsock-sockmap-upstream-v3-0-7e7f4ce623ee@bytedance.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3203254wrd; Tue, 28 Feb 2023 11:15:26 -0800 (PST) X-Google-Smtp-Source: AK7set9y9MrLOHfJrbVcsMlsIvDAYRYEpUzT7d47itEp+0DsSFBjnAqzAMSeH2zsNJYasReE7K51 X-Received: by 2002:a17:906:4d87:b0:878:72d0:2817 with SMTP id s7-20020a1709064d8700b0087872d02817mr4125238eju.29.1677611726453; Tue, 28 Feb 2023 11:15:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677611726; cv=none; d=google.com; s=arc-20160816; b=PAumiZrgDm6fqcF6ODcODVxPxnvXNY8qFLcIemX4ZVOg7KDKfnzbGi1yiGSXVlaqEJ 5FXqcjMAs94gdhNsDgexuX4LKRmpdO2C83y2fScif7G0nZGc5CGTLwGs62sfugBbm8qe WUTgKXq8jRBqSm2uZtVBz+MYdv2rzVqJbdDmHDbjG3eaEdLfRQTt1rRm4KglLA+yz3p7 lQxqhT0x6kwx7POQXdoN6h+BOV4VSGPDBR76BHVjJyF0xVhcP7NjxFj37PsiRO8CygAv OKc1psyBuV0FK+6s7mVdSxXowtiiBywZ69Zl3eFVfPkW+atU4uYGtuxoR+vjxw7MfFr1 QbBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=G9Ysv1tcjH+fhyGoDw4XqDTEVUICL5OL1IO4ayklgzk=; b=S1vktC+MrzkdNv40EHB0rehbvw2HZXriaI4ZP+AdsIPeJwXrhwBVYvXUBeSOJUZWPN nkZDPQFDu3g2utRDzvYlSvbPZ/5eqlT2AneeS63cgcJSOg/R7Lhle3aOj7JgxSln1kzQ VzcvRL1mOBN4CILXHi5fZe8pqqrYrWuoKljqPhMp2UMKOioFt/s3R6ZRc4JvxlYzfJUo OOOezdBPUZkr5QTtI1Ho+LA96JkkEGHGjEv11LrI/V9trMmLFVgvz4wkAxDooLUeneAi DwAYwqs2rNZTF0THOZNhXSHSTbVBb590fpgLcCTdjzn5a+fgV/nzLytlJUyX4ASAosgY 4RRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=VLMYWLCp; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gi18-20020a1709070c9200b008c3b647260asi794080ejc.627.2023.02.28.11.15.03; Tue, 28 Feb 2023 11:15:26 -0800 (PST) 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=@bytedance.com header.s=google header.b=VLMYWLCp; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbjB1TGo (ORCPT <rfc822;brysonjbanks@gmail.com> + 99 others); Tue, 28 Feb 2023 14:06:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjB1TGg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Feb 2023 14:06:36 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3087D30EA6 for <linux-kernel@vger.kernel.org>; Tue, 28 Feb 2023 11:06:12 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id ks17so7615974qvb.6 for <linux-kernel@vger.kernel.org>; Tue, 28 Feb 2023 11:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677611171; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=G9Ysv1tcjH+fhyGoDw4XqDTEVUICL5OL1IO4ayklgzk=; b=VLMYWLCpyG9X4gzuFdYxiV7f5THqkMJe6fuOSnQkoaLl47ZtPzYQwNe322VqQi9qSL ac1KuE9C4Yz+vJX2XOsacZQjL65w0x9s5YhYFkZ0Wjx0zXH2Uhw2I1n55TOopxHI4oWN qLeVGZHI9lesKsDSOkIpmPNyqqMHd8EB1PYeJur7qll/+GNK8XFqeJMRzs4laWxx8hVF wPf/UZ0QmJw7RuuCWx8EFH6V1DcmDct7kU6v4WM8slo0+foMGlKuWm94jLvh1SYUntxK hC2PQucXDwGGmu9v3nkfGeRVqJVycknzqFJUwHV0Awu3OzVFrGVYGb6uMn7ifz/zixCE 9wMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677611171; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G9Ysv1tcjH+fhyGoDw4XqDTEVUICL5OL1IO4ayklgzk=; b=evksSSkU9DQDq9E2EBGvKyt/hV3yPTvV8eQDGOhj9YiNcxOkHEiUaQG7ezNjDIDq4z Jr45H4U5QQudtjT8a4s3RQe+j1mMalJvJexdpflUUcYPiOhEU5wfnlFSGOOz1x+ZJliV Wt9dTrjPJS2/P7BMDPdb9UG0AvvBmr8zZ9+34o0jlqnvb7bvH85QFQwdgHIlvADEb58Z ZZnGxt/aLeCIR6+8N6/Kl8zsfILwNyTLek1wsY7R7ipwNNTEw24qQBJkfnE+XKv/HLtT EXReBqM/xgfySuCnxPJdNubD631wDiDX4bdVQ2sktWTt4o/DjwQLjex+qukfWewKnxfs 4U2Q== X-Gm-Message-State: AO0yUKUUnsS55dRA3iq25F45aL37PUxN1YuHIkPwtf3iPivcgY3F6zIH KGM3unFLceJhJ8kBZmlTjajmqg== X-Received: by 2002:a05:6214:3014:b0:56e:ff20:57c2 with SMTP id ke20-20020a056214301400b0056eff2057c2mr6277955qvb.10.1677611171233; Tue, 28 Feb 2023 11:06:11 -0800 (PST) Received: from n217-072-012.byted.org ([130.44.212.123]) by smtp.gmail.com with ESMTPSA id p13-20020a05620a15ed00b006fed58fc1a3sm7242810qkm.119.2023.02.28.11.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 11:06:10 -0800 (PST) From: Bobby Eshleman <bobby.eshleman@bytedance.com> Subject: [PATCH net-next v3 0/3] vsock: add support for sockmap Date: Tue, 28 Feb 2023 19:04:33 +0000 Message-Id: <20230227-vsock-sockmap-upstream-v3-0-7e7f4ce623ee@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAEFQ/mMC/12OTQrCMBSEryJv7ZM2Wq2uvIe4SJOJDZofklgU8 e6mbgQ3A8Mw882LMpJFpsPiRQmTzTb4atbLBalR+gvY6upJNGLdCLHjKQd15VmcjHyPuSRIx3u 97VS/aXcbKaiWB5nBQ5JejXNdY8ItRAdf5jQmGPv4Yk/kUdjjUehcE5OC4zLWzR+2bXvO9xhDK n94FbyHKna4gSfBDXe9MdJoNPttdxyeBbo+wEoFR+/3B7fELkPtAAAA To: Stefan Hajnoczi <stefanha@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>, Bobby Eshleman <bobby.eshleman@bytedance.com> X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759103393848423724?= X-GMAIL-MSGID: =?utf-8?q?1759103393848423724?= |
Series |
vsock: add support for sockmap
|
|
Message
Bobby Eshleman
Feb. 28, 2023, 7:04 p.m. UTC
Add support for sockmap to vsock.
We're testing usage of vsock as a way to redirect guest-local UDS
requests to the host and this patch series greatly improves the
performance of such a setup.
Compared to copying packets via userspace, this improves throughput by
121% in basic testing.
Tested as follows.
Setup: guest unix dgram sender -> guest vsock redirector -> host vsock
server
Threads: 1
Payload: 64k
No sockmap:
- 76.3 MB/s
- The guest vsock redirector was
"socat VSOCK-CONNECT:2:1234 UNIX-RECV:/path/to/sock"
Using sockmap (this patch):
- 168.8 MB/s (+121%)
- The guest redirector was a simple sockmap echo server,
redirecting unix ingress to vsock 2:1234 egress.
- Same sender and server programs
*Note: these numbers are from RFC v1
Only the virtio transport has been tested. The loopback transport was
used in writing bpf/selftests, but not thoroughly tested otherwise.
This series requires the skb patch.
Changes in v3:
- vsock/bpf: Refactor wait logic in vsock_bpf_recvmsg() to avoid
backwards goto
- vsock/bpf: Check psock before acquiring slock
- vsock/bpf: Return bool instead of int of 0 or 1
- vsock/bpf: Wrap macro args __sk/__psock in parens
- vsock/bpf: Place comment trailer */ on separate line
Changes in v2:
- vsock/bpf: rename vsock_dgram_* -> vsock_*
- vsock/bpf: change sk_psock_{get,put} and {lock,release}_sock() order
to minimize slock hold time
- vsock/bpf: use "new style" wait
- vsock/bpf: fix bug in wait log
- vsock/bpf: add check that recvmsg sk_type is one dgram, seqpacket, or
stream. Return error if not one of the three.
- virtio/vsock: comment __skb_recv_datagram() usage
- virtio/vsock: do not init copied in read_skb()
- vsock/bpf: add ifdef guard around struct proto in dgram_recvmsg()
- selftests/bpf: add vsock loopback config for aarch64
- selftests/bpf: add vsock loopback config for s390x
- selftests/bpf: remove vsock device from vmtest.sh qemu machine
- selftests/bpf: remove CONFIG_VIRTIO_VSOCKETS=y from config.x86_64
- vsock/bpf: move transport-related (e.g., if (!vsk->transport)) checks
out of fast path
Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
---
Bobby Eshleman (3):
vsock: support sockmap
selftests/bpf: add vsock to vmtest.sh
selftests/bpf: Add a test case for vsock sockmap
drivers/vhost/vsock.c | 1 +
include/linux/virtio_vsock.h | 1 +
include/net/af_vsock.h | 17 ++
net/vmw_vsock/Makefile | 1 +
net/vmw_vsock/af_vsock.c | 55 ++++++-
net/vmw_vsock/virtio_transport.c | 2 +
net/vmw_vsock/virtio_transport_common.c | 24 +++
net/vmw_vsock/vsock_bpf.c | 175 +++++++++++++++++++++
net/vmw_vsock/vsock_loopback.c | 2 +
tools/testing/selftests/bpf/config.aarch64 | 2 +
tools/testing/selftests/bpf/config.s390x | 3 +
tools/testing/selftests/bpf/config.x86_64 | 3 +
.../selftests/bpf/prog_tests/sockmap_listen.c | 163 +++++++++++++++++++
13 files changed, 443 insertions(+), 6 deletions(-)
---
base-commit: d83115ce337a632f996e44c9f9e18cadfcf5a094
change-id: 20230118-support-vsock-sockmap-connectible-2e1297d2111a
Best regards,
--
Bobby Eshleman <bobby.eshleman@bytedance.com>
---
Bobby Eshleman (3):
vsock: support sockmap
selftests/bpf: add vsock to vmtest.sh
selftests/bpf: add a test case for vsock sockmap
drivers/vhost/vsock.c | 1 +
include/linux/virtio_vsock.h | 1 +
include/net/af_vsock.h | 17 ++
net/vmw_vsock/Makefile | 1 +
net/vmw_vsock/af_vsock.c | 55 ++++++-
net/vmw_vsock/virtio_transport.c | 2 +
net/vmw_vsock/virtio_transport_common.c | 25 +++
net/vmw_vsock/vsock_bpf.c | 174 +++++++++++++++++++++
net/vmw_vsock/vsock_loopback.c | 2 +
tools/testing/selftests/bpf/config.aarch64 | 2 +
tools/testing/selftests/bpf/config.s390x | 3 +
tools/testing/selftests/bpf/config.x86_64 | 3 +
.../selftests/bpf/prog_tests/sockmap_listen.c | 163 +++++++++++++++++++
13 files changed, 443 insertions(+), 6 deletions(-)
---
base-commit: c2ea552065e43d05bce240f53c3185fd3a066204
change-id: 20230227-vsock-sockmap-upstream-9d65c84174a2
Best regards,
Comments
On Tue, Feb 28, 2023 at 07:04:33PM +0000, Bobby Eshleman wrote: > Add support for sockmap to vsock. > > We're testing usage of vsock as a way to redirect guest-local UDS > requests to the host and this patch series greatly improves the > performance of such a setup. > > Compared to copying packets via userspace, this improves throughput by > 121% in basic testing. besides the small comment, looks ok. Feel free to include my ack in v4: Acked-by: Michael S. Tsirkin <mst@redhat.com> > Tested as follows. > > Setup: guest unix dgram sender -> guest vsock redirector -> host vsock > server > Threads: 1 > Payload: 64k > No sockmap: > - 76.3 MB/s > - The guest vsock redirector was > "socat VSOCK-CONNECT:2:1234 UNIX-RECV:/path/to/sock" > Using sockmap (this patch): > - 168.8 MB/s (+121%) > - The guest redirector was a simple sockmap echo server, > redirecting unix ingress to vsock 2:1234 egress. > - Same sender and server programs > > *Note: these numbers are from RFC v1 > > Only the virtio transport has been tested. The loopback transport was > used in writing bpf/selftests, but not thoroughly tested otherwise. > > This series requires the skb patch. > > Changes in v3: > - vsock/bpf: Refactor wait logic in vsock_bpf_recvmsg() to avoid > backwards goto > - vsock/bpf: Check psock before acquiring slock > - vsock/bpf: Return bool instead of int of 0 or 1 > - vsock/bpf: Wrap macro args __sk/__psock in parens > - vsock/bpf: Place comment trailer */ on separate line > > Changes in v2: > - vsock/bpf: rename vsock_dgram_* -> vsock_* > - vsock/bpf: change sk_psock_{get,put} and {lock,release}_sock() order > to minimize slock hold time > - vsock/bpf: use "new style" wait > - vsock/bpf: fix bug in wait log > - vsock/bpf: add check that recvmsg sk_type is one dgram, seqpacket, or > stream. Return error if not one of the three. > - virtio/vsock: comment __skb_recv_datagram() usage > - virtio/vsock: do not init copied in read_skb() > - vsock/bpf: add ifdef guard around struct proto in dgram_recvmsg() > - selftests/bpf: add vsock loopback config for aarch64 > - selftests/bpf: add vsock loopback config for s390x > - selftests/bpf: remove vsock device from vmtest.sh qemu machine > - selftests/bpf: remove CONFIG_VIRTIO_VSOCKETS=y from config.x86_64 > - vsock/bpf: move transport-related (e.g., if (!vsk->transport)) checks > out of fast path > > Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com> > --- > Bobby Eshleman (3): > vsock: support sockmap > selftests/bpf: add vsock to vmtest.sh > selftests/bpf: Add a test case for vsock sockmap > > drivers/vhost/vsock.c | 1 + > include/linux/virtio_vsock.h | 1 + > include/net/af_vsock.h | 17 ++ > net/vmw_vsock/Makefile | 1 + > net/vmw_vsock/af_vsock.c | 55 ++++++- > net/vmw_vsock/virtio_transport.c | 2 + > net/vmw_vsock/virtio_transport_common.c | 24 +++ > net/vmw_vsock/vsock_bpf.c | 175 +++++++++++++++++++++ > net/vmw_vsock/vsock_loopback.c | 2 + > tools/testing/selftests/bpf/config.aarch64 | 2 + > tools/testing/selftests/bpf/config.s390x | 3 + > tools/testing/selftests/bpf/config.x86_64 | 3 + > .../selftests/bpf/prog_tests/sockmap_listen.c | 163 +++++++++++++++++++ > 13 files changed, 443 insertions(+), 6 deletions(-) > --- > base-commit: d83115ce337a632f996e44c9f9e18cadfcf5a094 > change-id: 20230118-support-vsock-sockmap-connectible-2e1297d2111a > > Best regards, > -- > Bobby Eshleman <bobby.eshleman@bytedance.com> > > --- > Bobby Eshleman (3): > vsock: support sockmap > selftests/bpf: add vsock to vmtest.sh > selftests/bpf: add a test case for vsock sockmap > > drivers/vhost/vsock.c | 1 + > include/linux/virtio_vsock.h | 1 + > include/net/af_vsock.h | 17 ++ > net/vmw_vsock/Makefile | 1 + > net/vmw_vsock/af_vsock.c | 55 ++++++- > net/vmw_vsock/virtio_transport.c | 2 + > net/vmw_vsock/virtio_transport_common.c | 25 +++ > net/vmw_vsock/vsock_bpf.c | 174 +++++++++++++++++++++ > net/vmw_vsock/vsock_loopback.c | 2 + > tools/testing/selftests/bpf/config.aarch64 | 2 + > tools/testing/selftests/bpf/config.s390x | 3 + > tools/testing/selftests/bpf/config.x86_64 | 3 + > .../selftests/bpf/prog_tests/sockmap_listen.c | 163 +++++++++++++++++++ > 13 files changed, 443 insertions(+), 6 deletions(-) > --- > base-commit: c2ea552065e43d05bce240f53c3185fd3a066204 > change-id: 20230227-vsock-sockmap-upstream-9d65c84174a2 > > Best regards, > -- > Bobby Eshleman <bobby.eshleman@bytedance.com>