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=HJbbL/s8; 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 CC8B45A0265 for ; Fri, 05 Jun 2026 12:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780657186; 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=VPQAD6ercnC5RC4ZV52f0E3icW8hAm8YoPw2PyvAf5w=; b=HJbbL/s8mqm6r9Ah8jycHXzZMVzSNwrrL16lawT3LGy0kt/G92WQP7xyCpnwMpVYGajBHZ /O3paT47UGBHGudlLI7sT1cjBSyE5vpZzniT2m9MnxazrAR7cqVbOekEqRqVRdOSPMom8j hz4zPRjkL7VdkGATB7DcZM5fqdNpmRg= 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-608-aKPELP52OAm1itwfM7kyng-1; Fri, 05 Jun 2026 06:59:45 -0400 X-MC-Unique: aKPELP52OAm1itwfM7kyng-1 X-Mimecast-MFC-AGG-ID: aKPELP52OAm1itwfM7kyng_1780657184 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490afe64f26so8751085e9.0 for ; Fri, 05 Jun 2026 03:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780657184; x=1781261984; 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=VPQAD6ercnC5RC4ZV52f0E3icW8hAm8YoPw2PyvAf5w=; b=Nqa9VXu4EYzGx+6doOAMXX8Zq0NE1nj2IDo6OZ2PnuX2cV71t4c3Z11tfNIq5bgWNg aLRizjPaax9xeFfBTWaeGMgXuivAKCjIdoAtdxZSTxkO7oXwryYluI5nlgNhY/FBLnu5 XD00KQ8U6+TrQmPfZqEP6CkPQA38c31vV1MAXr6bE6iR2O1DwVdy4MgazrV6bNMrr16H 0hZNy9fZJmvHrNvAxB00MRFrDZDdAisA2GBE/9VQWn0qCGvJZFibw2COS9pCG9rD7BX+ x6PWG3UpY/TrKUThcms+/c4wWF0LZe3HIWp7J7bXSMo901f4gqekgvZrOJlDhvCyQ84z 3MGQ== X-Gm-Message-State: AOJu0YzhEL2bGN+yerntXrru8DJoY9ESjYTTeH9kpnXKro8ZJkLTnNyr nQjCI3VtDqoR7b9aejhJcQR/eSJ9k3GVhPkE5l/ryUfkNOj19XnqRgM+LoDsEmG4xE+Hbrwza3P ZxS1jyGuaWeRE2d9SYCaBZxF7hSOrgwwtr1KOH/C//PcQo3gd0gd+4g== X-Gm-Gg: Acq92OH+NoA72BZUv+/zW3Fr3Lj4xYxnmUfs+z9wO0ya4zKK1QKz5fB7x31ZhwYQj5I w3r6jd7eXln9uqKhekrmavlESms+Yup0Jox3TPqL9JmWLWvsNnMGrjwZmssuG8RCj4JLE0o9t/z lsyTY/V6ONWgEUiRgWy0YI5jdzTaW2lkkKJgvN/hNLRSB3onxPgOtI0Ydj7tdWYpICyFmz7G0AN O69YWGbhqU0a7eytIYIOA0sUy+ErT5mFlWouBTijucxvE/ehlzEJEj7y8DsI0+kmrm0iwkkyDyY o//khXxzYacc+0ZBWzFhPv3OtMeaM3PrCpC/NjWZlKDd4P0zfAcXKO2iUOYAHpja2FwwhlG6Yd4 F2g+Xvz9wIfyJRmX55yGSknoewcI0NhezdKENOEE1z+2FAs0lNn7yo+a/4+gg X-Received: by 2002:a05:600c:1986:b0:489:32b:ac0b with SMTP id 5b1f17b1804b1-490c2cc27bdmr32141405e9.6.1780657184204; Fri, 05 Jun 2026 03:59:44 -0700 (PDT) X-Received: by 2002:a05:600c:1986:b0:489:32b:ac0b with SMTP id 5b1f17b1804b1-490c2cc27bdmr32140355e9.6.1780657182997; Fri, 05 Jun 2026 03:59:42 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3d66c8sm137291015e9.10.2026.06.05.03.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 03:59:42 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 8/8] tcp_splice: Improve EOF and read stall exit conditions Message-ID: <20260605125940.09263492@elisabeth> In-Reply-To: <20260605003808.1596631-1-david@gibson.dropbear.id.au> References: <20260528050213.679685-9-david@gibson.dropbear.id.au> <20260605003808.1596631-1-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Fri, 05 Jun 2026 12:59:42 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aFzQcgBctaH-5To8m-eR_APJY-dLwgxWsWUitk172iE_1780657184 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: HU7FO4NILVWX6Y2MGN4WPLU6256P7W2C X-Message-ID-Hash: HU7FO4NILVWX6Y2MGN4WPLU6256P7W2C 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 Fri, 5 Jun 2026 10:34:16 +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 makes > sense: at EOF there's nothing left to do read-side and with nothing in the > pipe there's nothing to do write side either. > > The same is true if the read side hit an EAGAIN and the pipe is empty: > there's nothing we can do (for now) read side, and with an empty pipe > nothing write side either. So, generalise the condition to exit on either > EOF or EAGAIN read side. > > Furthermore, if the read side is at EOF or EAGAIN and there's already > nothing in the pipe before the write-side splice(), then that write side > splice() can't accomplish anything, so exit the loop early in that case > avoiding a harmless but unnecessary write-splice(). > > Signed-off-by: David Gibson > --- > tcp_splice.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > Changes in v2: > * Duplicate rather than move the test, it's valuable in both places. > * Make comments and commit message clearer > > diff --git a/tcp_splice.c b/tcp_splice.c > index 565596d3..1e3c7749 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) > @@ -531,9 +539,11 @@ static int tcp_splice_forward(struct ctx *c, > > conn->pending[fromsidei] -= written; > > - if (conn->events & FIN_RCVD(fromsidei) && > - !conn->pending[fromsidei]) > + if (!conn->pending[fromsidei] && readlen <= 0) { > + /* Read side is EOF or EAGAIN, and we emptied the pipe. > + * No more we can do for now, */ Changed "now," to "now.", added empty comment line, applied. > break; > + } > } > > /* We need write-side wakeups if and only if we have data in the pipe to -- Stefano