public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 4/8] udp_vu: Make virtqueue buffers stack-local for thread safety
Date: Thu, 2 Jul 2026 12:37:36 +1000	[thread overview]
Message-ID: <akXO8A3a9oEqU9PM@zatzit> (raw)
In-Reply-To: <20260616171052.3785909-5-lvivier@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]

On Tue, Jun 16, 2026 at 07:10:48PM +0200, Laurent Vivier wrote:
> The function-local static buffers elem[] and iov_vu[] in
> udp_vu_sock_to_tap() are shared across all threads. When multiple
> worker threads process UDP vhost-user data concurrently, they would
> stomp on each other's buffers.
> 
> Remove the static qualifier so each call gets its own stack-allocated
> arrays, eliminating cross-thread sharing.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

I generally dislike static locals anyway, though they have their uses.
I'd be happy to see this applied independent of the rest of the
series.

> ---
>  udp_vu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/udp_vu.c b/udp_vu.c
> index 864e7a99b8d9..342673dc7e6d 100644
> --- a/udp_vu.c
> +++ b/udp_vu.c
> @@ -146,8 +146,8 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx,
>  {
>  	const struct flowside *toside = flowside_at_sidx(tosidx);
>  	bool v6 = !(inany_v4(&toside->eaddr) && inany_v4(&toside->oaddr));
> -	static struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE];
> -	static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE];
> +	struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE];
> +	struct iovec iov_vu[VIRTQUEUE_MAX_SIZE];

Nit, this needs a little re-ordering to preserve the reverse christmas tree.

>  	int rx_queue = QPAIR_TOGUEST_QUEUE(qpair);
>  	struct vu_dev *vdev = c->vdev;
>  	struct vu_virtq *vq = &vdev->vq[rx_queue];
> -- 
> 2.54.0
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-07-02  2:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 17:10 [PATCH 0/8] multithreading: Prepare data structures for concurrent queue pair workers Laurent Vivier
2026-06-16 17:10 ` [PATCH 1/8] tap: Convert packet pools to per-queue-pair arrays for multiqueue Laurent Vivier
2026-06-29  9:59   ` David Gibson
2026-06-16 17:10 ` [PATCH 2/8] tap: Make L4 sequence pools per-qpair for thread safety Laurent Vivier
2026-07-02  2:27   ` David Gibson
2026-06-16 17:10 ` [PATCH 3/8] tcp: Make static buffers stack-local " Laurent Vivier
2026-07-02  2:32   ` David Gibson
2026-06-16 17:10 ` [PATCH 4/8] udp_vu: Make virtqueue " Laurent Vivier
2026-07-02  2:37   ` David Gibson [this message]
2026-06-16 17:10 ` [PATCH 5/8] flow: Make flow timer per-caller " Laurent Vivier
2026-07-02  2:49   ` David Gibson
2026-06-16 17:10 ` [PATCH 6/8] tcp: Make TCP timer state per-caller and guard global tasks Laurent Vivier
2026-07-02  2:55   ` David Gibson
2026-06-16 17:10 ` [PATCH 7/8] tcp: Protect init socket pools with mutex for thread safety Laurent Vivier
2026-07-02  2:59   ` David Gibson
2026-06-16 17:10 ` [PATCH 8/8] flow: Add mutex and per-qpair filtering to flow table operations Laurent Vivier
2026-07-02  3:03   ` David Gibson

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=akXO8A3a9oEqU9PM@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).