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=NPzaeHml; 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 7F45C5A0262 for ; Thu, 04 Jun 2026 07:45:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780551901; 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=HTmmARnJtj55mF5KpSIYGkqbWuGbpSHGvkfbdi5hCkE=; b=NPzaeHml2xZiyHmnczynWSIHBXOfspszzww7qTA82FCcRFWAiVJEKzat0wzQz9d3hdYCJt EwB13Uw3Yt/5YRDqun7ewD+me4TFtdmgNxIMcHqizZsgdFQr2TKWf1Ri7++rQ4GrRGcazQ o/2Eq8I3yJ/y7953VMy210zmTgjZBSg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-B2eZ-PQ9PB2w3pjZL2o29Q-1; Thu, 04 Jun 2026 01:44:59 -0400 X-MC-Unique: B2eZ-PQ9PB2w3pjZL2o29Q-1 X-Mimecast-MFC-AGG-ID: B2eZ-PQ9PB2w3pjZL2o29Q_1780551899 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490bde3d239so2053445e9.1 for ; Wed, 03 Jun 2026 22:44:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780551898; x=1781156698; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HTmmARnJtj55mF5KpSIYGkqbWuGbpSHGvkfbdi5hCkE=; b=mNcJDtZszoZzuJxIYUPR6XcGMp/L01bxMhJHK7yQp1bfiORAFGVQtW23MRT9sIrUVx DRcI4ZVv0ggW7m+650DihWCcNCG/8zBjz96UNsO/Z6TKkAOJ10afm/t7p3tIS4DZODi8 sMTObWcI+co/bzVHw09U76qSxFMn/PovoRjXmjBIBM7UBjTp27zl6iTM6Pgw7+V4/k6/ BRuPbNgdEGTkDHA0j+cB6nYkYABatrfrlaHdIldOuJrPYD3w3es5uDDZVRk9PmKKEoCK f9yxSpUM9HMoDK46W1kFt8+c5Qfr+MRjMyaP/8x+FpPPEFjVCBcdtih3vF3UnjRn8fO/ TwMw== X-Gm-Message-State: AOJu0Yxk7/nGzRAuQ7+xUMb/5xZ5+mh0I/oANcFoFWdXvkI9GQ1TCDch i2mWDqraZY29iisFfQntC5onwtLZ4A/MuqRW5W2cYHmiKmWS+2s7sXV4bUlhVEq5OZJ/GnxRvCH zNgc2ySnxY0IPSNxH+KM9Obgplm0xvVMrTTq70NntZkWzcL+4fzuGuaqAWkCUGA== X-Gm-Gg: Acq92OE8Jh9W6SgM6DvoBOQKU/jRG0vyX6oPtuM72t44JUmUKzzjELd412exClLGzuZ /ElIH+5KnflQpfI9uXQOsT6eLigFBvXmFvzzDp5P6lpCHyxjQDkkf4IxJdc7hPQl7m4cw5kIrLZ zMZYavooTlX1wF5Fv7ZMjjXOKM7eTx5Rkrxet/1ulX7zRFMTZ8wkNlnm/fQ8DMov+Pd6XHomPZa FPT4dNLbZ0NdniOr9x0IrgMrO1xVMKrWHv4lZrAtaEemdAzM8FEbKYjVqvQtNwpW+7Zjf2kiBIJ cg8naR8HqnXqLmYtl4NmIgcpVQP3xdyB2xPxJgbxxC7Tu+0+49gkLw9d21DdfWCKq0P3/GOpIx8 ynEF2FEWq5N8ucJ9uRHALHr9XXcWI85FYFeQifpI7hfqdbcFIwaCNe0IOldpy X-Received: by 2002:a05:600c:83c8:b0:490:47e0:e13f with SMTP id 5b1f17b1804b1-490b5d1cf3emr113155105e9.3.1780551898499; Wed, 03 Jun 2026 22:44:58 -0700 (PDT) X-Received: by 2002:a05:600c:83c8:b0:490:47e0:e13f with SMTP id 5b1f17b1804b1-490b5d1cf3emr113154505e9.3.1780551897982; Wed, 03 Jun 2026 22:44:57 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3c183asm46189575e9.6.2026.06.03.22.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 22:44:57 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 8/8] tcp_splice: Exit forwarding earlier when stalled read side Message-ID: <20260604074456.06254db2@elisabeth> In-Reply-To: References: <20260528050213.679685-1-david@gibson.dropbear.id.au> <20260528050213.679685-9-david@gibson.dropbear.id.au> <20260604064146.2dbb9e3f@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 04 Jun 2026 07:44:56 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: fGK_YQQUox6-jJlscB5Hdej_MHnx8f-FRZND5nJ2GEo_1780551899 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: OVENBCVS25X2CPKMSDWDZTELG64PETZF X-Message-ID-Hash: OVENBCVS25X2CPKMSDWDZTELG64PETZF 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.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 Thu, 4 Jun 2026 15:26:36 +1000 David Gibson wrote: > On Thu, Jun 04, 2026 at 06:41:47AM +0200, Stefano Brivio wrote: > > On Thu, 28 May 2026 15:02:13 +1000 > > David Gibson wrote: > > > > > At the end of our loop we have a conditional 'break' that exits if we're > > > at EOF on the read side and have nothing left in the pipe. This doesn't > > > depend on anything write-side, so we can move it earlier, avoiding an > > > unnecessary write side splice in this case. > > > > > > Furthermore, there's also nothing to be done write side if we've hit EAGAIN > > > on the read side and the pipe is empty, so exit early for that case as > > > well. > > > > > > Signed-off-by: David Gibson > > > --- > > > tcp_splice.c | 18 +++++++++++------- > > > 1 file changed, 11 insertions(+), 7 deletions(-) > > > > > > diff --git a/tcp_splice.c b/tcp_splice.c > > > index 565596d3..623ca926 100644 > > > --- a/tcp_splice.c > > > +++ b/tcp_splice.c > > > @@ -497,9 +497,17 @@ static int tcp_splice_forward(struct ctx *c, > > > > > > flow_trace(conn, "%zi from read-side call", readlen); > > > > > > - if (!readlen) { > > > - conn_event(conn, FIN_RCVD(fromsidei)); > > > - } else if (readlen > 0) { > > > + if (readlen <= 0) { > > > + if (!readlen) /* EOF */ > > > + conn_event(conn, FIN_RCVD(fromsidei)); > > > + > > > + /* We're either blocked or at EOF on the read side, and > > > + * there's nothing in the pipe so there's nothing to do > > > + * write side either. > > > + */ > > > + if (!conn->pending[fromsidei]) > > > + break; > > > + } else { > > > conn->pending[fromsidei] += readlen; > > > > > > if (readlen >= (long)c->tcp.pipe_size * 90 / 100) > > > @@ -530,10 +538,6 @@ static int tcp_splice_forward(struct ctx *c, > > > break; > > > > > > conn->pending[fromsidei] -= written; > > > - > > > - if (conn->events & FIN_RCVD(fromsidei) && > > > - !conn->pending[fromsidei]) > > > - break; > > > > The rest of the series looks good to me and I'm running tests now > > before pushing, but I can't convince myself of the correctness of this > > change. > > > > The first part makes sense as an additional condition to exit the loop > > and avoid an additional splice() call that would just return EAGAIN. > > > > But this one is a different condition because it happens to check > > conn->pending[fromsidei] right after we subtracted 'written' from it, > > and we know we have no input data anymore, so it avoids a useless > > (although I think harmless) read-side splice() call in the next > > iteration of the loop, doesn't it? > > Good point. If there was data in the pipe before the read-splice(), > then we get EOF, then we empty the pipe with the write-splice() we > know we're done and don't need to read-splice() again. > > I'm also pretty sure it's harmless, as long as repeated read-splice()s > after EOF return either EOF again or EAGAIN, and I can't really see it > doing anything else. > > Given that, and the fact you're already testing, I guess it makes more > sense to do a fixup on top, rather than respinning? But the commit message of this one would still be misleading because we're not actually "moving" the condition, and the fix-up would just add back these four lines (I guess?), so I think it would be more practical if you could send a new version of 8/8 only (you can base it on 7/8). -- Stefano