DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: Ferruh Yigit <ferruh.yigit@amd.com>,
	Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "hujiayu.hu@foxmail.com" <hujiayu.hu@foxmail.com>,
	"roretzla@linux.microsoft.com" <roretzla@linux.microsoft.com>,
	"bruce.richardson@intel.com" <bruce.richardson@intel.com>,
	"anatoly.burakov@intel.com" <anatoly.burakov@intel.com>,
	"vladimir.medvedkin@intel.com" <vladimir.medvedkin@intel.com>,
	"kumaraparamesh92@gmail.com" <kumaraparamesh92@gmail.com>
Subject: RE: [RFC 2/4] gro: remove use of VLAs
Date: Thu, 13 Jun 2024 10:20:23 +0000	[thread overview]
Message-ID: <d741dd76ada84664a8198edfebcf08ee@huawei.com> (raw)
In-Reply-To: <d47974c0-9548-45cc-8e6c-7cebcc24c768@amd.com>



> 
> On 5/23/2024 5:26 PM, Konstantin Ananyev wrote:
> > From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> >
> > ../lib/gro/rte_gro.c:182:34: warning: variable length array used [-Wvla]
> > ../lib/gro/rte_gro.c:363:34: warning: variable length array used [-Wvla]
> >
> > In both cases the pattern is the same: we use unprocess_pkts[nb_pkts] to
> > collect un-used by GRO packets, and then copy them to the start of
> > input/output pkts[] array.
> > In both cases, we can safely copy pkts[i] into already
> > processed entry at the same array, i.e. into pkts[unprocess_num].
> > Such change eliminates need of temporary VLA: unprocess_pkts[nb_pkts].
> >
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > ---
> >  lib/gro/rte_gro.c | 40 ++++++++++++++--------------------------
> >  1 file changed, 14 insertions(+), 26 deletions(-)
> >
> > diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c
> > index db86117609..6d5aadf32a 100644
> > --- a/lib/gro/rte_gro.c
> > +++ b/lib/gro/rte_gro.c
> > @@ -179,7 +179,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  	struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM]
> >  			= {{{0}} };
> >
> > -	struct rte_mbuf *unprocess_pkts[nb_pkts];
> >  	uint32_t item_num;
> >  	int32_t ret;
> >  	uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts;
> > @@ -275,7 +274,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  				/* Merge successfully */
> >  				nb_after_gro--;
> >  			else if (ret < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) &&
> >  				do_vxlan_udp_gro) {
> >  			ret = gro_vxlan_udp4_reassemble(pkts[i],
> > @@ -284,7 +283,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  				/* Merge successfully */
> >  				nb_after_gro--;
> >  			else if (ret < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) &&
> >  				do_tcp4_gro) {
> >  			ret = gro_tcp4_reassemble(pkts[i], &tcp_tbl, 0);
> > @@ -292,7 +291,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  				/* merge successfully */
> >  				nb_after_gro--;
> >  			else if (ret < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) &&
> >  				do_udp4_gro) {
> >  			ret = gro_udp4_reassemble(pkts[i], &udp_tbl, 0);
> > @@ -300,7 +299,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  				/* merge successfully */
> >  				nb_after_gro--;
> >  			else if (ret < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) &&
> >  				do_tcp6_gro) {
> >  			ret = gro_tcp6_reassemble(pkts[i], &tcp6_tbl, 0);
> > @@ -308,21 +307,15 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,
> >  				/* merge successfully */
> >  				nb_after_gro--;
> >  			else if (ret < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else
> > -			unprocess_pkts[unprocess_num++] = pkts[i];
> > +			pkts[unprocess_num++] = pkts[i];
> >  	}
> >
> >  	if ((nb_after_gro < nb_pkts)
> >  		 || (unprocess_num < nb_pkts)) {
> > -		i = 0;
> > -		/* Copy unprocessed packets */
> > -		if (unprocess_num > 0) {
> > -			memcpy(&pkts[i], unprocess_pkts,
> > -					sizeof(struct rte_mbuf *) *
> > -					unprocess_num);
> > -			i = unprocess_num;
> > -		}
> > +
> > +		i = unprocess_num;
> >
> >  		/* Flush all packets from the tables */
> >  		if (do_vxlan_tcp_gro) {
> >
> 
> ack to re-use 'pkts[]' buffer for unprocessed packets, that should work.
> 
> But as a more general GRO question, above 'rte_gro_reassemble_burst()'
> functions seems returns 'nb_after_gro' and as far as I can see that
> amount of mbufs sits in the 'pkts[]'.
> When packets flushed from tables, flushed packets are replaced to
> 'pkts[]' but still 'nb_after_gro' returned, there is no way for
> application to know that more than 'nb_after_gro' mbufs available in the
> 'pkts[]'. Shouldn't return value increased per flushed packet?
> 
> Ahh, I can see it was the case before, but it is updated (perhaps
> broken) in commit:
> 74080d7dcf31 ("gro: support IPv6 for TCP")

Actually my first thought was - we should return 'I' here.
but then looking at the code more carefully, I realized that it is correct:
nb_after_gro - would contain valid number of packets
(at least I wasn't able to find a case when it wouldn't). 
Though yeh, it wasn't very obvious for me at first place, so might be
extra comment wouldn't hurt here.

> 
> 
> I wonder when GRO last tested!
> @Jiayu, did you have a chance to test GRO recently?
> 
> 
> > @@ -360,7 +353,6 @@ rte_gro_reassemble(struct rte_mbuf **pkts,
> >  		uint16_t nb_pkts,
> >  		void *ctx)
> >  {
> > -	struct rte_mbuf *unprocess_pkts[nb_pkts];
> >  	struct gro_ctx *gro_ctx = ctx;
> >  	void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl;
> >  	uint64_t current_time;
> > @@ -396,33 +388,29 @@ rte_gro_reassemble(struct rte_mbuf **pkts,
> >  				do_vxlan_tcp_gro) {
> >  			if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl,
> >  						current_time) < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) &&
> >  				do_vxlan_udp_gro) {
> >  			if (gro_vxlan_udp4_reassemble(pkts[i], vxlan_udp_tbl,
> >  						current_time) < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) &&
> >  				do_tcp4_gro) {
> >  			if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
> >  						current_time) < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) &&
> >  				do_udp4_gro) {
> >  			if (gro_udp4_reassemble(pkts[i], udp_tbl,
> >  						current_time) < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) &&
> >  				do_tcp6_gro) {
> >  			if (gro_tcp6_reassemble(pkts[i], tcp6_tbl,
> >  						current_time) < 0)
> > -				unprocess_pkts[unprocess_num++] = pkts[i];
> > +				pkts[unprocess_num++] = pkts[i];
> >  		} else
> > -			unprocess_pkts[unprocess_num++] = pkts[i];
> > -	}
> > -	if (unprocess_num > 0) {
> > -		memcpy(pkts, unprocess_pkts, sizeof(struct rte_mbuf *) *
> > -				unprocess_num);
> > +			pkts[unprocess_num++] = pkts[i];
> >
> 
> ack


  reply	other threads:[~2024-06-13 10:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 16:26 [RFC 0/4] remove use of VLA Konstantin Ananyev
2024-05-23 16:26 ` [RFC 1/4] gro: fix overwrite unprocessed packets Konstantin Ananyev
2024-06-12  0:48   ` Ferruh Yigit
2024-05-23 16:26 ` [RFC 2/4] gro: remove use of VLAs Konstantin Ananyev
2024-06-12  0:48   ` Ferruh Yigit
2024-06-13 10:20     ` Konstantin Ananyev [this message]
2024-06-14 15:11       ` Ferruh Yigit
2024-06-28 12:57         ` Konstantin Ananyev
2024-05-23 16:26 ` [RFC 3/4] net/ixgbe: " Konstantin Ananyev
2024-06-12  1:00   ` Ferruh Yigit
2024-05-23 16:26 ` [RFC 4/4] net/ice: " Konstantin Ananyev
2024-06-12  1:12   ` Ferruh Yigit
2024-06-13 10:32     ` Konstantin Ananyev
2024-06-14 15:31       ` Ferruh Yigit
2024-06-12  1:14 ` [RFC 0/4] remove use of VLA Ferruh Yigit
2024-06-13 10:43   ` Konstantin Ananyev

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=d741dd76ada84664a8198edfebcf08ee@huawei.com \
    --to=konstantin.ananyev@huawei.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=hujiayu.hu@foxmail.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=kumaraparamesh92@gmail.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=vladimir.medvedkin@intel.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.
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 NNTP newsgroup(s).