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.129.124]) by passt.top (Postfix) with ESMTP id 7EDA25A026B for ; Mon, 13 Feb 2023 02:22:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676251333; 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=ypIztj6n7M77Nd7w4/bvX/0ytZy2xN6LZYSc69akJ4Q=; b=T8spdV+Q02l3Znbh3voemnHQCFQwedLEsWpGxvmfNKWxn9QLeDKmUex1iZhsKVjugEIvhz 8H68MTk8RKMPHjoFbBVdJe3DIYeJa4Ma19QdywdI/yb6B/lUuJoKUEcd60PTB565WZ/u/7 p9vNN57uGcFzVzYVVK+VLNnBftzFcpE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-381-2UIA4zYUOaieelfD4yU0Zw-1; Sun, 12 Feb 2023 20:22:09 -0500 X-MC-Unique: 2UIA4zYUOaieelfD4yU0Zw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B5A7380671B; Mon, 13 Feb 2023 01:22:09 +0000 (UTC) Received: from maya.cloud.tilaa.com (unknown [10.33.32.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AE1E492B15; Mon, 13 Feb 2023 01:22:09 +0000 (UTC) Date: Mon, 13 Feb 2023 02:13:56 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v3 06/18] tcp: Combine two parts of pasta tap send path together Message-ID: <20230213021356.6acff1f1@elisabeth> In-Reply-To: <20230106004322.985665-7-david@gibson.dropbear.id.au> References: <20230106004322.985665-1-david@gibson.dropbear.id.au> <20230106004322.985665-7-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: QBFC7TGPGBBF5TQ5UWDJ6IFWC5EQ2UPW X-Message-ID-Hash: QBFC7TGPGBBF5TQ5UWDJ6IFWC5EQ2UPW 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 Fri, 6 Jan 2023 11:43:10 +1100 David Gibson wrote: > tcp_l2_buf_flush() open codes the loop across each frame in a group, but > but calls tcp_l2_buf_write_one() to send each frame to the pasta tuntap > device. Combine these two pasta-specific operations into > tcp_l2_buf_flush_pasta() which is a little cleaner and will enable further > cleanups. > > Signed-off-by: David Gibson > --- > tcp.c | 40 ++++++++++++++++++---------------------- > 1 file changed, 18 insertions(+), 22 deletions(-) > > diff --git a/tcp.c b/tcp.c > index d96122d..9960a35 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1391,23 +1391,25 @@ static void tcp_rst_do(struct ctx *c, struct tcp_tap_conn *conn); > } while (0) > > /** > - * tcp_l2_buf_write_one() - Write a single buffer to tap file descriptor > + * tcp_l2_buf_flush_pasta() - Send frames on the pasta tap interface > * @c: Execution context > - * @iov: struct iovec item pointing to buffer > - * @ts: Current timestamp > - * > - * Return: 0 on success, negative error code on failure (tap reset possible) > + * @iov: Pointer to array of buffers, one per frame > + * @n: Number of buffers/frames to flush > */ > -static int tcp_l2_buf_write_one(struct ctx *c, const struct iovec *iov) > +static void tcp_l2_buf_flush_pasta(struct ctx *c, > + const struct iovec *iov, size_t n) > { > - if (write(c->fd_tap, (char *)iov->iov_base + 4, iov->iov_len - 4) < 0) { > - debug("tap write: %s", strerror(errno)); > - if (errno != EAGAIN && errno != EWOULDBLOCK) > - tap_handler(c, c->fd_tap, EPOLLERR, NULL); > - return -errno; > - } > + size_t i; > > - return 0; > + for (i = 0; i < n; i++) { > + if (write(c->fd_tap, (char *)iov->iov_base + 4, > + iov->iov_len - 4) < 0) { It took me a moment to miss this during review, but a very long time to figure out later. :( This always sends the first frame in 'iov'. Surprisingly, pasta_tcp performance tests work just fine most of the times: for data connections we usually end up moving a single frame at a time, and retransmissions hide the issue for control messages. I just posted a patch on top of this, you don't have to respin, and it's actually more convenient for me to apply this with a fix at this point. -- Stefano