Linux Trace Kernel
 help / color / mirror / Atom feed
From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Jia Jia <physicalmtea@gmail.com>
Cc: "Stefano Garzarella" <sgarzare@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	virtualization@lists.linux.dev, kvm@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v6 2/2] vsock/virtio: amortize RX socket locking for stream packets
Date: Thu, 3 Dec 2026 08:23:25 -0800	[thread overview]
Message-ID: <axGXfT2fya5jtZCt@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <CAJwVaM+pnmwSxhWkGWS73+4RSr04yUOHxrs3kBk8ZGKRJQ4-JQ@mail.gmail.com>

On Thu, Dec 03, 2026 at 11:30:40AM +0800, Jia Jia wrote:
> >
> > On Fri, Nov 27, 2026 at 06:27:00AM +0000, Jia Jia wrote:
> > >The virtio-vsock RX worker looks up a socket and takes its lock for every
> > >packet. Retain the connected lookup reference and socket lock across a
> > >bounded run of STREAM/RW packets for one established native socket.
> > >
> > >Reuse the locked socket while packets match the same flow. Finish the
> > >batch on a malformed packet, flow change, non-RW traffic, or a change to
> > >the socket state, transport, protocol, sockmap state, or receive buffer
> > >limits. A connected lookup miss falls back to the existing receive path,
> > >which can still find a bound socket.
> > >
> > >Limit an uninterrupted socket-lock ownership interval to 64 packets and
> > >64 KiB of payload. The payload limit is one
> > >VIRTIO_VSOCK_MAX_PKT_BUF_SIZE. Small or zero-length packets still incur
> > >per-packet work, so an independent packet limit is needed. The 64-packet
> > >limit uses VHOST_NET_BATCH as a reference; it is a policy choice rather
> > >than a protocol limit.
> > >
> > >Beyond these limits, a larger batch would only further amortize socket
> > >lookup and lock/unlock operations, while virtqueue work, validation,
> > >tracing, skb ownership, credit update, and queueing remain per-packet. I
> > >therefore expect diminishing returns while the uninterrupted socket-lock
> > >interval continues to grow, but I have not measured larger limits yet.
> > >
> > >Only the guest virtio RX worker is changed. The benchmark exercises the
> > >host-sender-to-guest-receiver direction, where this worker is on the
> > >receive path. I have not measured the corresponding worker and socket-lock
> > >overhead in vhost-vsock or vsock_loopback, and they use different worker
> > >and locking models. Leave those paths unchanged pending separate policy
> > >and validation. I plan to evaluate vhost-vsock separately as follow-up
> > >work.
> > >
> > >Performance:
> > >
> > >These results cover both patches in this series.
> > >
> > >Tested on a single-stream vsock connection (one Guest receiver thread on
> > >CPU0, virtio-vsock IRQ on Guest CPU1, fresh QEMU Guest per state, with 16
> > >accepted, balanced AB/BA pairs per payload). The host uses vhost-vsock.
> > >
> > >For throughput, vsock_perf runs on the host as the
> > >sender, with a custom single-threaded Guest receiver pinned to Guest CPU0
> > >using blocking recv(). The table uses a 64K buffer. The virtio-vsock
> > >IRQ/RX worker is pinned to Guest CPU1. To normalize run times across
> > >payloads into a bounded, deterministic window and avoid long runs being
> > >skewed by host background noise or virtualization scheduling jitter,
> > >transfer sizes scale proportionally with the request size (64B/64M,
> > >256B/256M, etc.), capped at 2G for 4K-64K. The custom receiver keeps the
> > >recv() size and count explicit; vsock_perf's receiver uses poll()+read().
> > >
> > >End-to-end RX throughput
> > >(64K Guest recv() size, SO_RCVLOWAT=1; Gbit/s):
> > >
> > >  payload  baseline RX  series RX  throughput change (95% CI)
> > >           (Gbit/s)     (Gbit/s)
> > >  64B          0.1212      0.2555  +110.81% [+106.99%, +114.70%]
> > >  256B         0.5551      1.0212  +83.95% [+79.94%, +88.06%]
> > >  512B         1.0568      1.8761  +77.53% [+73.02%, +82.15%]
> > >  1K           1.9260      3.1453  +63.31% [+58.58%, +68.17%]
> > >  4K           3.5175      6.3239  +79.78% [+72.79%, +87.06%]
> > >  8K           4.1183      5.6867  +38.08% [+31.06%, +45.48%]
> > >  16K          5.0155      6.8346  +36.27% [+31.12%, +41.62%]
> > >  64K          5.0541      5.8403  +15.56% [+11.12%, +20.17%]
> > >
> > >Fixed-syscall stress test
> > >(receiver recv() size = sender write size; Gbit/s):
> > >
> > >  payload  baseline RX  series RX  throughput change (95% CI)
> > >           (Gbit/s)     (Gbit/s)
> > >  64B          0.1435      0.2750  +91.60% [+82.19%, +101.50%]
> > >       recv() calls (baseline/series): 1048577/1048577
> > >  256B         0.4218      0.9659  +129.00% [+110.65%, +148.95%]
> > >       recv() calls (baseline/series): 1048577/1048577
> > >  512B         0.8062      1.6979  +110.60% [+94.49%, +128.04%]
> > >       recv() calls (baseline/series): 1048577/1048577
> > >  1K           1.5116      2.9585  +95.72% [+85.22%, +106.82%]
> > >       recv() calls (baseline/series): 1048577/1048577
> > >  4K           2.9234      6.3365  +116.75% [+110.78%, +122.89%]
> > >       recv() calls (baseline/series): 538537/525565
> > >  8K           4.0430      7.1193  +76.09% [+69.04%, +83.44%]
> > >       recv() calls (baseline/series): 276901/264412
> > >  16K          4.9182      7.7688  +57.96% [+54.40%, +61.60%]
> > >       recv() calls (baseline/series): 147674/132088
> > >  64K          5.6683      7.1636  +26.38% [+20.49%, +32.56%]
> > >       recv() calls (baseline/series): 50615/33343
> > >
> > >Signed-off-by: Jia Jia <physicalmtea@gmail.com>
> > >---
> > > include/linux/virtio_vsock.h                  |  23 ++
> > > .../events/vsock_virtio_transport_common.h    |  40 +--
> > > net/vmw_vsock/virtio_transport.c              |   7 +-
> > > net/vmw_vsock/virtio_transport_common.c       | 268 +++++++++++++++++-
> > > 4 files changed, 297 insertions(+), 41 deletions(-)
> > >
> > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
> > >index f91704731057e..748633aa0cc81 100644
> > >--- a/include/linux/virtio_vsock.h
> > >+++ b/include/linux/virtio_vsock.h
> > >@@ -282,6 +282,29 @@ void virtio_transport_destruct(struct vsock_sock *vsk);
> > >
> > > void virtio_transport_recv_pkt(struct virtio_transport *t,
> > >                              struct sk_buff *skb, struct net *net);
> > >+
> > >+/*
> > >+ * Initialize a batch to zero before use. A non-empty batch owns @sk's socket
> > >+ * lock and the reference returned by vsock_find_connected_socket_net(). The
> > >+ * caller retains both until it calls virtio_transport_rx_batch_finish(). An
> > >+ * empty batch owns neither.
> > >+ */
> > >+struct virtio_transport_rx_batch {
> > >+      struct sock *sk;
> > >+      unsigned int pkts;
> > >+      size_t bytes;
> > >+};
> > >+
> > >+static inline bool
> > >+virtio_transport_rx_batch_empty(const struct virtio_transport_rx_batch *batch)
> > >+{
> > >+      return !batch->sk;
> > >+}
> > >+
> > >+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,
> > >+                                   struct sk_buff *skb, struct net *net,
> > >+                                   struct virtio_transport_rx_batch *batch);
> > >+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch);
> > > void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);
> > > u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
> > > void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
> > >diff --git a/include/trace/events/vsock_virtio_transport_common.h b/include/trace/events/vsock_virtio_transport_common.h
> > >index f1ebe36787c3d..53a4c9ec47dae 100644
> > >--- a/include/trace/events/vsock_virtio_transport_common.h
> > >+++ b/include/trace/events/vsock_virtio_transport_common.h
> > >@@ -88,24 +88,12 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
> > >
> > > TRACE_EVENT(virtio_transport_recv_pkt,
> > >       TP_PROTO(
> > >-               __u32 src_cid, __u32 src_port,
> > >-               __u32 dst_cid, __u32 dst_port,
> > >-               __u32 len,
> > >-               __u16 type,
> > >-               __u16 op,
> > >-               __u32 flags,
> > >-               __u32 buf_alloc,
> > >-               __u32 fwd_cnt
> > >+               const struct virtio_vsock_hdr *hdr,
> > >+               const struct sockaddr_vm *src,
> > >+               const struct sockaddr_vm *dst
> > >       ),
> > >       TP_ARGS(
> > >-              src_cid, src_port,
> > >-              dst_cid, dst_port,
> > >-              len,
> > >-              type,
> > >-              op,
> > >-              flags,
> > >-              buf_alloc,
> > >-              fwd_cnt
> > >+              hdr, src, dst
> > >       ),
> > >       TP_STRUCT__entry(
> > >               __field(__u32, src_cid)
> > >@@ -120,16 +108,16 @@ TRACE_EVENT(virtio_transport_recv_pkt,
> > >               __field(__u32, fwd_cnt)
> > >       ),
> > >       TP_fast_assign(
> > >-              __entry->src_cid = src_cid;
> > >-              __entry->src_port = src_port;
> > >-              __entry->dst_cid = dst_cid;
> > >-              __entry->dst_port = dst_port;
> > >-              __entry->len = len;
> > >-              __entry->type = type;
> > >-              __entry->op = op;
> > >-              __entry->flags = flags;
> > >-              __entry->buf_alloc = buf_alloc;
> > >-              __entry->fwd_cnt = fwd_cnt;
> > >+              __entry->src_cid = src->svm_cid;
> > >+              __entry->src_port = src->svm_port;
> > >+              __entry->dst_cid = dst->svm_cid;
> > >+              __entry->dst_port = dst->svm_port;
> > >+              __entry->len = le32_to_cpu(hdr->len);
> > >+              __entry->type = le16_to_cpu(hdr->type);
> > >+              __entry->op = le16_to_cpu(hdr->op);
> > >+              __entry->flags = le32_to_cpu(hdr->flags);
> > >+              __entry->buf_alloc = le32_to_cpu(hdr->buf_alloc);
> > >+              __entry->fwd_cnt = le32_to_cpu(hdr->fwd_cnt);
> > >       ),
> > >       TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
> > >                 "buf_alloc=%u fwd_cnt=%u",
> > >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
> > >index 4f9aa9c4c3aa5..9af85712bd387 100644
> > >--- a/net/vmw_vsock/virtio_transport.c
> > >+++ b/net/vmw_vsock/virtio_transport.c
> > >@@ -633,6 +633,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
> > > {
> > >       struct virtio_vsock *vsock =
> > >               container_of(work, struct virtio_vsock, rx_work);
> > >+      struct virtio_transport_rx_batch batch = {};
> > >       struct virtqueue *vq;
> > >
> > >       mutex_lock(&vsock->rx_lock);
> > >@@ -666,6 +667,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
> > >                       /* Drop short/long packets */
> > >                       if (unlikely(len < sizeof(*hdr) ||
> > >                                    len > virtio_vsock_skb_len(skb))) {
> > >+                              virtio_transport_rx_batch_finish(&batch);
> > >                               kfree_skb(skb);
> > >                               continue;
> > >                       }
> > >@@ -673,6 +675,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
> > >                       hdr = virtio_vsock_hdr(skb);
> > >                       payload_len = le32_to_cpu(hdr->len);
> > >                       if (unlikely(payload_len > len - sizeof(*hdr))) {
> > >+                              virtio_transport_rx_batch_finish(&batch);
> > >                               kfree_skb(skb);
> > >                               continue;
> > >                       }
> > >@@ -685,11 +688,13 @@ static void virtio_transport_rx_work(struct work_struct *work)
> > >                       /* Force virtio-transport into global mode since it
> > >                        * does not yet support local-mode namespacing.
> > >                        */
> > >-                      virtio_transport_recv_pkt(&virtio_transport, skb, NULL);
> > >+                      virtio_transport_recv_pkt_batch(&virtio_transport, skb,
> > >+                                                      NULL, &batch);
> > >               }
> > >       } while (!virtqueue_enable_cb(vq));
> > >
> > > out:
> > >+      virtio_transport_rx_batch_finish(&batch);
> > >       if (vsock->rx_buf_nr < vsock->rx_buf_max_nr / 2)
> > >               virtio_vsock_rx_fill(vsock);
> > > out_nofill:
> > >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> > >index bebf63115b263..34d6864917bc9 100644
> > >--- a/net/vmw_vsock/virtio_transport_common.c
> > >+++ b/net/vmw_vsock/virtio_transport_common.c
> > >@@ -33,6 +33,15 @@
> > > #define MAX_COLLAPSE_LEN \
> > >       SKB_MAX_ORDER(VIRTIO_VSOCK_SKB_HEADROOM, PAGE_ALLOC_COSTLY_ORDER)
> > >
> > >+/*
> > >+ * Bound the interval that an RX worker owns a socket lock. One maximum packet
> > >+ * buffer (64 KiB) bounds payload in one uninterrupted ownership interval.
> > >+ * Small and zero-length packets need a packet limit to bound per-packet work;
> > >+ * the 64-packet policy uses VHOST_NET_BATCH as a reference.
> > >+ */
> > >+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS    64
> > >+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES   VIRTIO_VSOCK_MAX_PKT_BUF_SIZE
> > >+
> > > static void virtio_transport_cancel_close_work(struct vsock_sock *vsk,
> > >                                              bool cancel_timeout);
> > > static s64 virtio_transport_has_space(struct virtio_vsock_sock *vvs);
> > >@@ -1787,10 +1796,70 @@ virtio_transport_find_socket(struct sockaddr_vm *src,
> > >       return sk;
> > > }
> > >
> > >+static bool
> > >+virtio_transport_recv_pkt_set_owner(struct sk_buff *skb, struct sock *sk)
> > >+{
> > >+      if (skb_set_owner_sk_safe(skb, sk))
> > >+              return true;
> > >+
> > >+      WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
> > >+      return false;
> > >+}
> > >+
> > >+static bool
> > >+virtio_transport_sock_has_psock(const struct sock *sk)
> > >+{
> > >+      return (uintptr_t)rcu_access_pointer(__sk_user_data(sk)) &
> > >+             SK_USER_DATA_PSOCK;
> > >+}
> > >+
> > >+/* The caller holds sk's socket lock. */
> > >+static bool
> > >+virtio_transport_rx_batch_can_continue(struct virtio_transport *t,
> > >+                                     struct sock *sk, u32 len)
> > >+{
> > >+      struct virtio_vsock_sock *vvs;
> > >+      struct vsock_sock *vsk;
> > >+
> > >+      vsk = vsock_sk(sk);
> > >+      vvs = vsk->trans;
> > >+
> > >+      /*
> > >+       * Keep a connected lookup reference only for the native, established
> > >+       * STREAM path. Sockets outside ESTABLISHED can change table membership;
> > >+       * a completed or reassigned socket must resume the per-packet path.
> > >+       */
> > >+      if (sk->sk_state != TCP_ESTABLISHED ||
> > >+          sk->sk_type != SOCK_STREAM ||
> > >+          sock_flag(sk, SOCK_DONE) ||
> > >+          vsk->transport != &t->transport || !vvs)
> > >+              return false;
> > >+
> > >+      return (u64)vvs->buf_used + len <= vvs->buf_alloc;
> >
> > Should we remove this, since it will be checked in
> > virtio_transport_inc_rx_pkt() in any case?
> >
> 
> I originally added this for the same kind of boundary
> case discussed in v5. The v5 case checked the skb
> metadata budget, while this checks the payload
> against buf_alloc.
> 
> Given that, this special handling probably isn't necessary,
> so I'll remove it in the next version.
> 
> > >+}
> > >+
> > >+/* The caller holds sk's socket lock. */
> > >+static bool
> > >+virtio_transport_rx_batch_can_receive(struct virtio_transport *t,
> > >+                                    struct sock *sk, u32 len)
> > >+{
> > >+      if (!virtio_transport_rx_batch_can_continue(t, sk, len))
> > >+              return false;
> > >+
> > >+      /*
> > >+       * Sockmap can replace sk_prot and publish a psock without the socket lock.
> > >+       * Check both at each packet boundary; a boundary that sees a replacement
> > >+       * returns to the existing per-packet path.
> > >+       */
> > >+      return READ_ONCE(sk->sk_prot) == sk->sk_prot_creator &&
> > >+             !virtio_transport_sock_has_psock(sk);
> >
> > Is this a leftover or we really need this check?
> >
> 
> Yes, virtio_transport_sock_has_psock() is no longer
> needed either. I'll remove it in the next version. Thanks.
> 
> > >+}
> > >+
> > > /*
> > >- * The caller holds sk's socket lock.
> > >+ * The caller holds sk's socket lock. Return false if socket/source validation
> > >+ * rejects the packet.
> > >  */
> > >-static void
> > >+static bool
> > > virtio_transport_recv_pkt_locked(struct virtio_transport *t,
> > >                                struct sk_buff *skb, struct sock *sk,
> > >                                struct net *net)
> > >@@ -1813,7 +1882,7 @@ virtio_transport_recv_pkt_locked(struct virtio_transport *t,
> > >            !vsock_check_source(vsk, &t->transport, &src))) {
> > >               (void)virtio_transport_reset_no_sock(t, skb, net);
> > >               kfree_skb(skb);
> > >-              return;
> > >+              return false;
> > >       }
> > >
> > >       space_available = virtio_transport_space_update(sk, skb);
> > >@@ -1846,6 +1915,8 @@ virtio_transport_recv_pkt_locked(struct virtio_transport *t,
> > >               kfree_skb(skb);
> > >               break;
> > >       }
> > >+
> > >+      return true;
> > > }
> > >
> > > /* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
> > >@@ -1863,14 +1934,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
> > >       vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
> > >                       le32_to_cpu(hdr->dst_port));
> > >
> > >-      trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
> > >-                                      dst.svm_cid, dst.svm_port,
> > >-                                      le32_to_cpu(hdr->len),
> > >-                                      le16_to_cpu(hdr->type),
> > >-                                      le16_to_cpu(hdr->op),
> > >-                                      le32_to_cpu(hdr->flags),
> > >-                                      le32_to_cpu(hdr->buf_alloc),
> > >-                                      le32_to_cpu(hdr->fwd_cnt));
> > >+      trace_virtio_transport_recv_pkt(hdr, &src, &dst);
> >
> > Why we are doing these changes in this patch?
> >
> 
> In v5, I initially added a helper around this tracepoint for the new
> batching call site. Bobby suggested refactoring the tracepoint directly
> instead, since the helper was unnecessary. Since this patch has two call
> sites for the tracepoint, I kept that refactoring.

FTR, between the refactoring and my very first suggestion of not
changing the trace calls at all, I still prefer my very first suggestion
of not changing them.

> 
> > >
> > >       if (!virtio_transport_valid_type(le16_to_cpu(hdr->type))) {
> > >               (void)virtio_transport_reset_no_sock(t, skb, net);
> > >@@ -1892,10 +1956,8 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
> > >               goto free_pkt;
> > >       }
> > >
> > >-      if (!skb_set_owner_sk_safe(skb, sk)) {
> > >-              WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
> > >+      if (!virtio_transport_recv_pkt_set_owner(skb, sk))
> > >               goto free_pkt;
> > >-      }
> > >
> > >       lock_sock(sk);
> > >       virtio_transport_recv_pkt_locked(t, skb, sk, net);
> > >@@ -1912,6 +1974,184 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
> > > }
> > > EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt);
> > >
> > >+/*
> > >+ * Release an active RX batch. A non-empty batch holds the socket lock and the
> > >+ * reference returned by vsock_find_connected_socket_net(). An empty batch
> > >+ * holds neither.
> > >+ */
> > >+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch)
> > >+{
> > >+      struct sock *sk = batch->sk;
> > >+
> > >+      batch->sk = NULL;
> > >+      batch->pkts = 0;
> > >+      batch->bytes = 0;
> > >+
> > >+      if (!sk)
> > >+              return;
> > >+
> > >+      release_sock(sk);
> > >+      sock_put(sk);
> > >+}
> > >+EXPORT_SYMBOL_GPL(virtio_transport_rx_batch_finish);
> > >+
> > >+static bool
> > >+virtio_transport_rx_batch_matches(const struct virtio_transport_rx_batch *batch,
> > >+                                const struct sockaddr_vm *src,
> > >+                                const struct sockaddr_vm *dst,
> > >+                                struct net *net)
> > >+{
> > >+      struct vsock_sock *vsk = vsock_sk(batch->sk);
> > >+
> > >+      /* The connected table is keyed by peer address and local port. */
> > >+      return vsock_addr_equals_addr(src, &vsk->remote_addr) &&
> > >+             dst->svm_port == vsk->local_addr.svm_port &&
> > >+             vsock_net_check_mode(sock_net(batch->sk), net);
> > >+}
> > >+
> > >+static bool
> > >+virtio_transport_rx_batch_can_add(const struct virtio_transport_rx_batch *batch,
> > >+                                u32 len)
> > >+{
> > >+      if (batch->pkts >= VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS ||
> > >+          batch->bytes >= VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES)
> >
> > Why putting a limit to the total bytes in a batch?
> >
> 
> My thinking is that the two limits bound different things: the 64-packet
> limit bounds per-packet work for small or zero-length packets, while the
> 64 K limit bounds how much data can be queued while the reader is unable
> to acquire the socket lock.
> 
> A single packet can carry up to 64K, so a packet-only limit could let one
> batch cover up to 4M. Since the receive buffer can be enlarged, the
> default 256K buffer is not a substitute for that bound. Keeping the byte
> limit also bounds the delay before the reader can dequeue data and return
> credit to the peer, since that cannot happen while the batch holds the
> socket lock.
> 
> I would therefore prefer to keep both limits.

I'm still not sure I entirely understand this point. Bounding the byte
count bounds the delay before a reader can dequeue data? Can you point
to the part of the code that sees increased delay because of high byte
counts? I think my mental model must be missing something.

Best,
Bobby

      parent reply	other threads:[~2026-12-03 16:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:26 [PATCH net-next v6 0/2] vsock/virtio: reduce RX per-packet socket overhead Jia Jia
2026-11-27  6:26 ` [PATCH net-next v6 1/2] vsock/virtio: split socket lookup from locked RX processing Jia Jia
2026-11-27  6:27 ` [PATCH net-next v6 2/2] vsock/virtio: amortize RX socket locking for stream packets Jia Jia
2026-12-02 13:28   ` Stefano Garzarella
2026-12-03  3:30     ` Jia Jia
2026-12-03  9:54       ` Jia Jia
2026-12-03 16:23       ` Bobby Eshleman [this message]

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=axGXfT2fya5jtZCt@devvm29614.prn0.facebook.com \
    --to=bobbyeshleman@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=physicalmtea@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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