From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id F0B115A005E for ; Wed, 4 Jan 2023 18:45:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672854299; 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=w2kN2fr11G1yw8+kNDtzsamPkwk9LunmodXdhnkoxPg=; b=Fbgo/54g/3GHtx9lM0jYYgEo+z9w6ge/6K3n5bfVZ1BorMq2JWgH0ozzcYqyzHOKFxVL9I up3P4Kr76gX8qkT4PVHd3/zNxY1tHZbhQcn+4M2cgZudR2Jtj5mfERnNRcR1sMhy9IgJM2 v04oTF+U6GreGzoMwXMMR5RUomk7YaE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-FPKQq2i3P9ehigay8_glYQ-1; Wed, 04 Jan 2023 12:44:58 -0500 X-MC-Unique: FPKQq2i3P9ehigay8_glYQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 57D0A185A78B; Wed, 4 Jan 2023 17:44:58 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-4.brq.redhat.com [10.40.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3D5E2026D4B; Wed, 4 Jan 2023 17:44:57 +0000 (UTC) Date: Wed, 4 Jan 2023 18:44:38 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v3 6/8] udp: Unify udp_sock_handler_splice() with udp_sock_handler() Message-ID: <20230104184438.2e43da08@elisabeth> In-Reply-To: <20230104054426.120668-7-david@gibson.dropbear.id.au> References: <20230104054426.120668-1-david@gibson.dropbear.id.au> <20230104054426.120668-7-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: PLYVJT6JNO3ZPX277PESUDNE3TJ7ACM3 X-Message-ID-Hash: PLYVJT6JNO3ZPX277PESUDNE3TJ7ACM3 X-MailFrom: sbrivio@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: passt-dev@passt.top X-Mailman-Version: 3.3.3 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 Wed, 4 Jan 2023 16:44:24 +1100 David Gibson wrote: > These two functions now have a very similar structure, and their first > part (calling recvmmsg()) is functionally identical. So, merge the two > functions into one. > > This does have the side effect of meaning we no longer receive multiple > packets at once for splice (we already didn't for tap). This does hurt > throughput for small spliced packets, but improves it for large spliced > packets and tap packets. > > Signed-off-by: David Gibson > --- > udp.c | 95 ++++++++++++++++++++++------------------------------------- > 1 file changed, 35 insertions(+), 60 deletions(-) > > diff --git a/udp.c b/udp.c > index f6c07a5..32ca83e 100644 > --- a/udp.c > +++ b/udp.c > @@ -590,52 +590,6 @@ static void udp_splice_sendfrom(const struct ctx *c, unsigned start, unsigned n, > sendmmsg(s, mmh_send + start, n, MSG_NOSIGNAL); > } > > -/** > - * udp_sock_handler_splice() - Handler for socket mapped to "spliced" connection > - * @c: Execution context > - * @ref: epoll reference > - * @events: epoll events bitmap > - * @now: Current timestamp > - */ > -static void udp_sock_handler_splice(const struct ctx *c, union epoll_ref ref, > - uint32_t events, const struct timespec *now) > -{ > - in_port_t dst = ref.r.p.udp.udp.port; > - int v6 = ref.r.p.udp.udp.v6, n, i, m; > - struct mmsghdr *mmh_recv; > - > - if (!(events & EPOLLIN)) > - return; > - > - if (v6) > - mmh_recv = udp6_l2_mh_sock; > - else > - mmh_recv = udp4_l2_mh_sock; > - > - n = recvmmsg(ref.r.s, mmh_recv, UDP_MAX_FRAMES, 0, NULL); > - > - if (n <= 0) > - return; > - > - if (v6) > - udp6_localname.sin6_port = htons(dst); > - else > - udp4_localname.sin_port = htons(dst); > - > - for (i = 0; i < n; i += m) { > - in_port_t src = sa_port(v6, mmh_recv[i].msg_hdr.msg_name); > - > - for (m = 1; i + m < n; m++) { > - void *mname = mmh_recv[i + m].msg_hdr.msg_name; > - if (sa_port(v6, mname) != src) > - break; > - } > - > - udp_splice_sendfrom(c, i, m, src, dst, v6, ref.r.p.udp.udp.ns, > - ref.r.p.udp.udp.orig, now); > - } > -} > - > /** > * udp_update_hdr4() - Update headers for one IPv4 datagram > * @c: Execution context > @@ -944,32 +898,53 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, > const struct timespec *now) > { > /* For not entirely clear reasons (data locality?) pasta gets > - * better throughput if we receive the datagrams one at a > - * time. > + * better throughput if we receive tap datagrams one at a > + * atime. For small splice datagrams throughput is slightly > + * better if we do batch, but it's slightly worse for large > + * splice datagrams. Since we don't know before we receive > + * whether we'll use tap or splice, always go one at a time > + * for pasta mode. > */ > ssize_t n = (c->mode == MODE_PASST ? UDP_MAX_FRAMES : 1); > in_port_t dstport = ref.r.p.udp.udp.port; > bool v6 = ref.r.p.udp.udp.v6; > - struct mmsghdr *sock_mmh; > + struct mmsghdr *mmh_recv; > + unsigned int i, m; > + ssize_t n; This doesn't build, you're redefining 'n' after the new version of 4/8. I could drop this on merge (the rest of the series would be ready to merge) but as you usually prefer to respin anyway, I'll wait for that. -- Stefano