public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 1/3] tcp_splice: Register fds with epoll at flow creation
Date: Mon, 19 Jan 2026 19:36:29 +1100	[thread overview]
Message-ID: <aW3tDYcpSIEHC6Rx@zatzit> (raw)
In-Reply-To: <b37cb5b8-8983-4d0b-aef3-ab2090c5d778@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3157 bytes --]

On Mon, Jan 19, 2026 at 09:10:42AM +0100, Laurent Vivier wrote:
> On 1/19/26 05:45, David Gibson wrote:
> > On Fri, Jan 16, 2026 at 04:52:21PM +0100, Laurent Vivier wrote:
> > > Register both splice connection sockets with epoll using empty events
> > > (events=0) in tcp_splice_connect(), before initiating the connection.
> > > 
> > > This allows tcp_splice_epoll_ctl() to always use EPOLL_CTL_MOD, removing
> > > the need to check whether fds are already registered. As a result, the
> > > conditional ADD/MOD logic is no longer needed, simplifying the function.
> > > 
> > > Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> > 
> > Nice!  One query below.
> > 
> > > ---
> > >   tcp_splice.c | 20 ++++++++++----------
> > >   1 file changed, 10 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/tcp_splice.c b/tcp_splice.c
> > > index a7c04ca8652a..cb81e012ee4b 100644
> > > --- a/tcp_splice.c
> > > +++ b/tcp_splice.c
> > > @@ -142,20 +142,12 @@ static uint32_t tcp_splice_conn_epoll_events(uint16_t events, unsigned sidei)
> > >   static int tcp_splice_epoll_ctl(struct tcp_splice_conn *conn)
> > >   {
> > >   	uint32_t events[2];
> > > -	int m;
> > > -
> > > -	if (flow_in_epoll(&conn->f)) {
> > > -		m = EPOLL_CTL_MOD;
> > > -	} else {
> > > -		flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT);
> > > -		m = EPOLL_CTL_ADD;
> > > -	}
> > >   	events[0] = tcp_splice_conn_epoll_events(conn->events, 0);
> > >   	events[1] = tcp_splice_conn_epoll_events(conn->events, 1);
> > > -	if (flow_epoll_set(&conn->f, m, events[0], conn->s[0], 0) ||
> > > -	    flow_epoll_set(&conn->f, m, events[1], conn->s[1], 1)) {
> > > +	if (flow_epoll_set(&conn->f, EPOLL_CTL_MOD, events[0], conn->s[0], 0) ||
> > > +	    flow_epoll_set(&conn->f, EPOLL_CTL_MOD, events[1], conn->s[1], 1)) {
> > >   		int ret = -errno;
> > >   		flow_perror(conn, "ERROR on epoll_ctl()");
> > >   		return ret;
> > > @@ -368,6 +360,14 @@ static int tcp_splice_connect(const struct ctx *c, struct tcp_splice_conn *conn)
> > >   	pif_sockaddr(c, &sa, tgtpif, &tgt->eaddr, tgt->eport);
> > > +	flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT);
> > > +	if (flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->s[0], 0) ||
> > > +	    flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->s[1], 1)) {
> > > +		int ret = -errno;
> > > +		flow_perror(conn, "Cannot register to epollfd");
> > > +		return ret;
> > 
> > Do we need to worry about rollback here, if the first one succeeds,
> > but the second one fails?
> 
> If we return an error here, tcp_splice_conn_from_sock() sets the CLOSING
> flag on the connection and conn_flag() handles the closing flag by calling
> epoll_del() for both sockets. So the cleanup path handles this case already.
> 
> None of the error cases in tcp_splice_connect() worries about rollback, so
> it's simpler to do the same.

Ok, that makes sense.  Maybe add that explanation to the commit
message?

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-01-19  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 15:52 [PATCH 0/3] Register TCP flows with epoll at creation time Laurent Vivier
2026-01-16 15:52 ` [PATCH 1/3] tcp_splice: Register fds with epoll at flow creation Laurent Vivier
2026-01-19  4:45   ` David Gibson
2026-01-19  8:10     ` Laurent Vivier
2026-01-19  8:36       ` David Gibson [this message]
2026-01-16 15:52 ` [PATCH 2/3] tcp: " Laurent Vivier
2026-01-19  4:48   ` David Gibson
2026-01-19  8:56     ` Laurent Vivier
2026-01-16 15:52 ` [PATCH 3/3] flow: Remove EPOLLFD_ID_INVALID Laurent Vivier
2026-01-19  4:51   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aW3tDYcpSIEHC6Rx@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).