From: Simon Horman <simon.horman@corigine.com>
To: Bobby Eshleman <bobby.eshleman@bytedance.com>
Cc: 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>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Bryan Tan <bryantan@vmware.com>, Vishnu Dasa <vdasa@vmware.com>,
VMware PV-Drivers Reviewers <pv-drivers@vmware.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hyperv@vger.kernel.org
Subject: Re: [PATCH RFC net-next v3 7/8] vsock: Add lockless sendmsg() support
Date: Wed, 31 May 2023 18:22:19 +0200 [thread overview]
Message-ID: <ZHd0O1L7FH2XJEnd@corigine.com> (raw)
In-Reply-To: <20230413-b4-vsock-dgram-v3-7-c2414413ef6a@bytedance.com>
On Wed, May 31, 2023 at 12:35:11AM +0000, Bobby Eshleman wrote:
...
Hi Bobby,
some more feedback from my side.
> Throughput metrics for single-threaded SOCK_DGRAM and
> single/multi-threaded SOCK_STREAM showed no statistically signficant
nit: s/signficant/significant/
> throughput changes (lowest p-value reaching 0.27), with the range of the
> mean difference ranging between -5% to +1%.
>
> Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
...
> @@ -120,8 +125,8 @@ struct vsock_transport {
>
> /* DGRAM. */
> int (*dgram_bind)(struct vsock_sock *, struct sockaddr_vm *);
> - int (*dgram_enqueue)(struct vsock_sock *, struct sockaddr_vm *,
> - struct msghdr *, size_t len);
> + int (*dgram_enqueue)(const struct vsock_transport *, struct vsock_sock *,
> + struct sockaddr_vm *, struct msghdr *, size_t len);
Perhaps just a personal preference, but the arguments for these callbacks
could have names.
> bool (*dgram_allow)(u32 cid, u32 port);
> int (*dgram_get_cid)(struct sk_buff *skb, unsigned int *cid);
> int (*dgram_get_port)(struct sk_buff *skb, unsigned int *port);
> @@ -196,6 +201,17 @@ void vsock_core_unregister(const struct vsock_transport *t);
> /* The transport may downcast this to access transport-specific functions */
> const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk);
>
> +static inline struct vsock_remote_info *
> +vsock_core_get_remote_info(struct vsock_sock *vsk)
> +{
> +
nit: no blank line here
> + /* vsk->remote_info may be accessed if the rcu read lock is held OR the
> + * socket lock is held
> + */
> + return rcu_dereference_check(vsk->remote_info,
> + lockdep_sock_is_held(sk_vsock(vsk)));
> +}
> +
> /**** UTILS ****/
>
> /* vsock_table_lock must be held */
...
> @@ -300,17 +449,36 @@ static void vsock_insert_unbound(struct vsock_sock *vsk)
> spin_unlock_bh(&vsock_table_lock);
> }
>
> -void vsock_insert_connected(struct vsock_sock *vsk)
> +int vsock_insert_connected(struct vsock_sock *vsk)
> {
> - struct list_head *list = vsock_connected_sockets(
> - &vsk->remote_addr, &vsk->local_addr);
> + struct list_head *list;
> + struct vsock_remote_info *remote_info;
nit: I know that this file doesn't follow the reverse xmas tree
scheme - longest line to shortest - for local variable declarations.
But as networking code I think it would be good towards towards
that scheme as code is changed.
struct vsock_remote_info *remote_info;
struct list_head *list;
> +
> + rcu_read_lock();
> + remote_info = vsock_core_get_remote_info(vsk);
> + if (!remote_info) {
> + rcu_read_unlock();
> + return -EINVAL;
> + }
> + list = vsock_connected_sockets(&remote_info->addr, &vsk->local_addr);
> + rcu_read_unlock();
>
> spin_lock_bh(&vsock_table_lock);
> __vsock_insert_connected(list, vsk);
> spin_unlock_bh(&vsock_table_lock);
> +
> + return 0;
> }
...
> @@ -1120,7 +1122,9 @@ virtio_transport_recv_connecting(struct sock *sk,
> case VIRTIO_VSOCK_OP_RESPONSE:
> sk->sk_state = TCP_ESTABLISHED;
> sk->sk_socket->state = SS_CONNECTED;
> - vsock_insert_connected(vsk);
> + err = vsock_insert_connected(vsk);
> + if (err)
> + goto destroy;
The destroy label uses skerr, but it is uninitialised here.
A W=1 or C=1 will probably tell you this.
> sk->sk_state_change(sk);
> break;
> case VIRTIO_VSOCK_OP_INVALID:
...
next prev parent reply other threads:[~2023-05-31 16:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 0:35 [PATCH RFC net-next v3 0/8] virtio/vsock: support datagrams Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 1/8] vsock/dgram: generalize recvmsg and drop transport->dgram_dequeue Bobby Eshleman
2023-05-31 15:56 ` Simon Horman
2023-06-01 7:53 ` Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 2/8] vsock: refactor transport lookup code Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 3/8] vsock: support multi-transport datagrams Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 4/8] vsock: make vsock bind reusable Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 5/8] virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 6/8] virtio/vsock: support dgrams Bobby Eshleman
2023-05-31 16:09 ` Simon Horman
2023-05-31 18:13 ` Dan Carpenter
2023-06-01 7:54 ` Bobby Eshleman
2023-05-31 0:35 ` [PATCH RFC net-next v3 7/8] vsock: Add lockless sendmsg() support Bobby Eshleman
2023-05-31 16:22 ` Simon Horman [this message]
2023-05-31 0:35 ` [PATCH RFC net-next v3 8/8] tests: add vsock dgram tests Bobby Eshleman
2023-06-05 20:42 ` [PATCH RFC net-next v3 0/8] virtio/vsock: support datagrams Arseniy Krasnov
2023-05-31 21:10 ` Bobby Eshleman
2023-06-06 18:15 ` Arseniy Krasnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZHd0O1L7FH2XJEnd@corigine.com \
--to=simon.horman@corigine.com \
--cc=bobby.eshleman@bytedance.com \
--cc=bryantan@vmware.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=haiyangz@microsoft.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pv-drivers@vmware.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=vdasa@vmware.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).