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=cWoxj8RH; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 0B31B5A0265 for ; Mon, 11 May 2026 11:37:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778492269; 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=DMkoTb66fL5uk2KkOPAV0Stu2wDRrrckmdhv5NPBZwI=; b=cWoxj8RHL7jgQHA+35m2pGN4SA1/2kIqaUX7gIjbrmMSAA/7VemIleHFWEebN0jm/O9Idd EPf2We0AIsMUSY74iqi+VkvO2lmwSj93EvMmeOj/vl4jsTBS3eba7TngcESkcrKInEY4a4 aghQAwAW+E1dLfIukHwE7Ogrs9Qsd1Q= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-297-PzZZWeHlMjC-gmcZjIn8AA-1; Mon, 11 May 2026 05:37:48 -0400 X-MC-Unique: PzZZWeHlMjC-gmcZjIn8AA-1 X-Mimecast-MFC-AGG-ID: PzZZWeHlMjC-gmcZjIn8AA_1778492268 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8eb04352972so784349285a.2 for ; Mon, 11 May 2026 02:37:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778492268; x=1779097068; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DMkoTb66fL5uk2KkOPAV0Stu2wDRrrckmdhv5NPBZwI=; b=dlbw0raIlujnyZ6c3e0cX1Kqk8oIGHTxqfHua7P/lWQEPH9QIkblQWkOtYLWbE2YXp Jjo0xmObm87pUzo2sQPIooMXpU27sFkEt5+S3pohKvqqlYb3mwmGu+Tw2cYFaSmbpJT8 cvuOUC/Du08g7FfK87880co+SCZkuOydjBEJ4qoWZu/kr9aj+tcn1H6CUCnPKSBLJoR5 XNkBXw26FddsN7Vb0nTvy+hk57veg1eStwCgxlAS1iC5SC4q9IvapTMbiTZcKG0Il4Ni eFqchAhsoJG0VoVPOBrTZaEIAxqz8M6hZO/A3++5OTyy7Zfp+qpnIfbEb1lTWJQZfHvj TF7g== X-Forwarded-Encrypted: i=1; AFNElJ9JB946ABffHxPS4duoWlZl5pFKoz7krftzBCIGddA6oZsjqPW3rwjEpH3+S0lim85B4jC/BynZmxw=@passt.top X-Gm-Message-State: AOJu0Yw34c3A2ksY0ln7fkMycSAoT8WXvmVPgCbvuVyGZiFxVFxLG+a/ ZteafnbbTg5WWwt3aXaIG8pBw5wRBk4cDEq8fyYhylKiti8eRMnpaaNpYZBBKrlhYsUMr0Kj95V eIMKIEP/vJDnNAgX2H1fp2HDjZCx3I1u5GkhqwtFyOGfq4ev55LNXpA== X-Gm-Gg: Acq92OF1BfaJP7Lalh7wLx7Zl8ySL4jwgJ72cmaKXqQiybwA1cDY+AFUO28UQmUtyS2 nk++rYnQ+B/iLyVRChnIXDB83BSIyi+nkAgKPvGG8sbatWy61mCDNvwrkWr+AHgbuZ2OcEH7GJk nFnMRIgK8B+XO9QcE8SH0F0cUhwcz+Azhj6N+k7LgLCg6PO3x6giUJAhWYU/lEv4Dr2wtSUbi+a qI7xYPGAhEz8yMNzynptg9uAeKmZPvLX+4jb6TL8b5psYjqd5frsPKfYq/aAF+fu8quemjpiLoO 7AWJUEnhkEWdZ/AkDEaxuFjz4dII8ELxVbUN1DcOuLD/RA1N2CPiYT/X714xtmKe2eM+uDsZoKN kzN7a6KHUjiOMAeQuO0dxp+o+D3vNHbMpEcTqPWGZwKaQoARqq0282lQtqYwxP0V/HyF5/Jiu6L jzRZkyzv363dpq X-Received: by 2002:a05:620a:46a0:b0:8cf:e32e:8a0a with SMTP id af79cd13be357-9090e6e2f8dmr1274659285a.18.1778492267521; Mon, 11 May 2026 02:37:47 -0700 (PDT) X-Received: by 2002:a05:620a:46a0:b0:8cf:e32e:8a0a with SMTP id af79cd13be357-9090e6e2f8dmr1274655785a.18.1778492266782; Mon, 11 May 2026 02:37:46 -0700 (PDT) Received: from [192.168.2.15] (lnsm4-toronto63-142-116-28-118.internet.virginmobile.ca. [142.116.28.118]) by smtp.gmail.com with ESMTPSA id af79cd13be357-907b9c524bbsm992294885a.1.2026.05.11.02.37.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 May 2026 02:37:46 -0700 (PDT) Message-ID: <85665e4f-49e5-431a-8c4e-05baa6fa92ca@redhat.com> Date: Mon, 11 May 2026 05:37:45 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 05/10] udp_vu: Pass iov explicitly to helpers instead of using file-scoped array To: Laurent Vivier , passt-dev@passt.top References: <20260416155721.3807225-1-lvivier@redhat.com> <20260416155721.3807225-6-lvivier@redhat.com> From: Jon Maloy In-Reply-To: <20260416155721.3807225-6-lvivier@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vd-RWLf6byCwC383UBW_hfIkB560lXH5haFmYH2y6nk_1778492268 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: VYWD3RVMWPDEZ62LAQVH4OIEEOMLG2FX X-Message-ID-Hash: VYWD3RVMWPDEZ62LAQVH4OIEEOMLG2FX X-MailFrom: jmaloy@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: David Gibson 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: On 2026-04-16 11:57, Laurent Vivier wrote: > udp_vu_sock_recv(), udp_vu_prepare(), and udp_vu_csum() all operated on > the file-scoped iov_vu[] array directly. Pass iov and count as explicit > parameters instead, and move iov_vu[] and elem[] to function-local > statics in udp_vu_sock_to_tap(), the only function that needs them. > > Signed-off-by: Laurent Vivier > Reviewed-by: David Gibson Reviewed-by: Jon Maloy See below. > --- > udp_vu.c | 67 +++++++++++++++++++++++++++++--------------------------- > 1 file changed, 35 insertions(+), 32 deletions(-) > [...] oside, int iov_used) > +static void udp_vu_csum(const struct flowside *toside, const struct iovec *iov, > + size_t cnt) > { > const struct in_addr *src4 = inany_v4(&toside->oaddr); > const struct in_addr *dst4 = inany_v4(&toside->eaddr); > - char *base = iov_vu[0].iov_base; > + char *base = iov[0].iov_base; > struct udp_payload_t *bp; > struct iov_tail data; > > if (src4 && dst4) { > bp = vu_payloadv4(base); > - data = IOV_TAIL(iov_vu, iov_used, (char *)&bp->data - base); > + data = IOV_TAIL(iov, cnt, (char *)&bp->data - base); > csum_udp4(&bp->uh, *src4, *dst4, &data); > } else { > bp = vu_payloadv6(base); > - data = IOV_TAIL(iov_vu, iov_used, (char *)&bp->data - base); > + data = IOV_TAIL(iov, cnt, (char *)&bp->data - base); > csum_udp6(&bp->uh, &toside->oaddr.a6, &toside->eaddr.a6, &data); > } > } > @@ -179,7 +180,9 @@ static void udp_vu_csum(const struct flowside *toside, int iov_used) > 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); > + static struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; I think this declaration should move one line down. /jon > bool v6 = !(inany_v4(&toside->eaddr) && inany_v4(&toside->oaddr)); > + static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; > struct vu_dev *vdev = c->vdev; > struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; > int i; > @@ -212,9 +215,9 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx) > > assert((size_t)elem_cnt == iov_cnt); /* one iovec per element */ > > - dlen = udp_vu_sock_recv(s, v6, &iov_cnt); > + dlen = udp_vu_sock_recv(iov_vu, &iov_cnt, s, v6); > if (dlen < 0) { > - vu_queue_rewind(vq, iov_cnt); > + vu_queue_rewind(vq, elem_cnt); > break; > } > > @@ -224,12 +227,12 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx) > vu_queue_rewind(vq, elem_cnt - elem_used); > > if (iov_cnt > 0) { > - udp_vu_prepare(c, toside, dlen); > + udp_vu_prepare(c, iov_vu, toside, dlen); > if (*c->pcap) { > - udp_vu_csum(toside, iov_cnt); > + udp_vu_csum(toside, iov_vu, iov_cnt); > pcap_iov(iov_vu, iov_cnt, VNET_HLEN); > } > - vu_flush(vdev, vq, elem, iov_cnt); > + vu_flush(vdev, vq, elem, elem_used); > vu_queue_notify(vdev, vq); > } > }