public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Jon Maloy <jmaloy@redhat.com>
Cc: passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com,
	dgibson@redhat.com
Subject: Re: [PATCH v2] tcp: unify payload and flags l2 frames array
Date: Mon, 4 Nov 2024 13:29:53 +1100	[thread overview]
Message-ID: <ZygxoQLFJEnWuNUP@zatzit> (raw)
In-Reply-To: <ZyggiteQ45GT7i_j@zatzit>

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

On Mon, Nov 04, 2024 at 12:16:58PM +1100, David Gibson wrote:
> On Fri, Nov 01, 2024 at 08:51:32PM -0400, Jon Maloy wrote:
> > In order to reduce static memory and code footprint, we merge
> > the array for l2 flag frames into the one for payload frames.
> > 
> > This change also ensures that no flag message will be sent out
> > over the l2 media bypassing already queued payload messages.
> > 
> > Performance measurements with iperf3, where we force all
> > traffic via the tap queue, show no significant difference:

Spotted a couple of extra things I missed in my previous mail.

[snip]
> > @@ -107,13 +96,6 @@ void tcp_sock_iov_init(const struct ctx *c)
> >  		tcp_payload[i].th.ack = 1;
> >  	}
> >  
> > -	for (i = 0; i < ARRAY_SIZE(tcp_flags); i++) {
> > -		tcp6_flags_ip[i] = ip6;
> > -		tcp4_flags_ip[i] = iph;
> > -		tcp_flags[i].th.doff = sizeof(struct tcphdr) / 4;
> > -		tcp_flags[i].th.ack = 1;
> > -	}
> > -
> >  	for (i = 0; i < TCP_FRAMES_MEM; i++) {
> >  		struct iovec *iov = tcp_l2_iov[i];
> >

Because you're now setting all the flags fields for every frame, you
should remove the initialisation of th.ack from iov_init.

[snip]
> > @@ -274,6 +237,9 @@ static void tcp_data_to_tap(const struct ctx *c, struct tcp_tap_conn *conn,
> >  		iov[TCP_IOV_IP] = IOV_OF_LVALUE(tcp6_payload_ip[tcp_payload_used]);
> >  		iov[TCP_IOV_ETH].iov_base = &tcp6_eth_src;
> >  	}
> > +	payload = iov[TCP_IOV_PAYLOAD].iov_base;
> > +	flags = &payload->th.window - 1;
> > +	*(flags) = PAYLOAD_FLAGS;
> 
> I think this is likely to run afoul of TBAA rules, which could cause
> miscompiles because cc assumes *flags is not aliased with payload->th.
> Although it's more bulky, I think it's better to explicitly assign
> each of the fields in struct tcphdr.  The compiler should be able to
> boil it down to the same instructions in any case.
> 
> Note that now we're using the netinet version of struct tcphdr, it has
> an anonymous union so you can use th_flags, rather than the one bit
> fields (doesn't include doffset, though).

Actually, looking at this again, you shouldn't need to update doff in
any case - it's the same for flag frames and data frames.  Of course,
it's plausible there's no point pre-filling the doff (or any other)
header fields, but I don't think changing that should be in scope for
this patch.

I hope to post this afternoon a bunch of different buffer cleanups,
along with vhost rebased on those and other changes.  Unfortunately
those will conflict with this patch, sorry.

-- 
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:[~2024-11-04  2:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-02  0:51 [PATCH v2] tcp: unify payload and flags l2 frames array Jon Maloy
2024-11-04  1:16 ` David Gibson
2024-11-04  2:29   ` David Gibson [this message]

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=ZygxoQLFJEnWuNUP@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=dgibson@redhat.com \
    --cc=jmaloy@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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).