From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PV81+sge; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 09ADB5A0272 for ; Fri, 31 Jul 2026 18:23:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785515018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iRrRCcA9t25FhtsbvSMtx6ZAqfJ3KoXQpUuy+mY+cIg=; b=PV81+sge6yLXNWvJSZRIu7+kLKJQG3rgmPwt+RD5yzFtbj6akxgb1FE+9fSwMCyLwmDEeU sVELqgSFhGC6kfXzhvSj/accN2F1vukSZbqwJjQV1QjUPILSltww9Og7/TNoO2kxeIORqf 2p5NabCV4yGCD5XTAQlMMmb5yYjkrJw= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-5e6VwkOLP2KwOy1bdSBAzA-1; Fri, 31 Jul 2026 12:23:36 -0400 X-MC-Unique: 5e6VwkOLP2KwOy1bdSBAzA-1 X-Mimecast-MFC-AGG-ID: 5e6VwkOLP2KwOy1bdSBAzA_1785515015 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ACF3218002C7 for ; Fri, 31 Jul 2026 16:23:35 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E0B131956044; Fri, 31 Jul 2026 16:23:34 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v2 04/10] udp_vu: Make virtqueue buffers stack-local for thread safety Date: Fri, 31 Jul 2026 18:23:23 +0200 Message-ID: <20260731162329.3552800-5-lvivier@redhat.com> In-Reply-To: <20260731162329.3552800-1-lvivier@redhat.com> References: <20260731162329.3552800-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZUK8aPMjZ5UXNi4SnIuI2MRxUFT0SUEXGgGOHrIjffM_1785515015 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: FTVK3WOGOE74RLEZTQPIT6KU563KUARE X-Message-ID-Hash: FTVK3WOGOE74RLEZTQPIT6KU563KUARE X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- udp_vu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/udp_vu.c b/udp_vu.c index 21fa891b3b51..c045e421001c 100644 --- a/udp_vu.c +++ b/udp_vu.c @@ -151,9 +151,9 @@ 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]; + struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; + struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; int toguest = QPAIR_TOGUEST_QUEUE(qpair); - static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; struct vu_dev *vdev = c->vdev; struct vu_virtq *vq = &vdev->vq[toguest]; size_t hdrlen = udp_vu_hdrlen(v6); -- 2.54.0