DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] app/test: use memcpy in ipsec test
@ 2026-05-29 15:46 Stephen Hemminger
  2026-05-29 16:42 ` Konstantin Ananyev
  2026-06-02 19:36 ` [EXTERNAL] " Akhil Goyal
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2026-05-29 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev, Vladimir Medvedkin

This test has tables of data that get copied with rte_memcpy.
But when compiled without always inline the compiler gets confused
by the inlining of rte_memcpy and thinks that it is possible for AVX
code to reference past the input data.

Workaround is to use memcpy() which is better for this test anyway
since regular memcpy has more static checking from compiler and
analyzers.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_ipsec.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c
index 139c1e8dec..b5a430996d 100644
--- a/app/test/test_ipsec.c
+++ b/app/test/test_ipsec.c
@@ -10,7 +10,6 @@
 #include <rte_hexdump.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
-#include <rte_memcpy.h>
 #include <rte_cycles.h>
 #include <rte_bus_vdev.h>
 #include <rte_ip.h>
@@ -559,7 +558,7 @@ setup_test_string(struct rte_mempool *mpool, const char *string,
 			return NULL;
 		}
 		if (string != NULL)
-			rte_memcpy(dst, string, t_len);
+			memcpy(dst, string, t_len);
 		else
 			memset(dst, 0, t_len);
 	}
@@ -604,22 +603,22 @@ setup_test_string_tunneled(struct rte_mempool *mpool, const char *string,
 	/* copy outer IP and ESP header */
 	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
 	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
-	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
+	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
 	dst += sizeof(ipv4_outer);
 	m->l3_len = sizeof(ipv4_outer);
-	rte_memcpy(dst, &esph, sizeof(esph));
+	memcpy(dst, &esph, sizeof(esph));
 	dst += sizeof(esph);
 
 	if (string != NULL) {
 		/* copy payload */
-		rte_memcpy(dst, string, len);
+		memcpy(dst, string, len);
 		dst += len;
 		/* copy pad bytes */
-		rte_memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
+		memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
 			sizeof(esp_pad_bytes)));
 		dst += padlen;
 		/* copy ESP tail header */
-		rte_memcpy(dst, &espt, sizeof(espt));
+		memcpy(dst, &espt, sizeof(espt));
 	} else
 		memset(dst, 0, t_len);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 15:46 [PATCH] app/test: use memcpy in ipsec test Stephen Hemminger
@ 2026-05-29 16:42 ` Konstantin Ananyev
  2026-05-29 20:45   ` Morten Brørup
  2026-06-02 19:36 ` [EXTERNAL] " Akhil Goyal
  1 sibling, 1 reply; 8+ messages in thread
From: Konstantin Ananyev @ 2026-05-29 16:42 UTC (permalink / raw)
  To: Stephen Hemminger, dev@dpdk.org; +Cc: Vladimir Medvedkin



> 
> This test has tables of data that get copied with rte_memcpy.
> But when compiled without always inline the compiler gets confused
> by the inlining of rte_memcpy and thinks that it is possible for AVX
> code to reference past the input data.
> 
> Workaround is to use memcpy() which is better for this test anyway
> since regular memcpy has more static checking from compiler and
> analyzers.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  app/test/test_ipsec.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c
> index 139c1e8dec..b5a430996d 100644
> --- a/app/test/test_ipsec.c
> +++ b/app/test/test_ipsec.c
> @@ -10,7 +10,6 @@
>  #include <rte_hexdump.h>
>  #include <rte_mbuf.h>
>  #include <rte_malloc.h>
> -#include <rte_memcpy.h>
>  #include <rte_cycles.h>
>  #include <rte_bus_vdev.h>
>  #include <rte_ip.h>
> @@ -559,7 +558,7 @@ setup_test_string(struct rte_mempool *mpool, const
> char *string,
>  			return NULL;
>  		}
>  		if (string != NULL)
> -			rte_memcpy(dst, string, t_len);
> +			memcpy(dst, string, t_len);
>  		else
>  			memset(dst, 0, t_len);
>  	}
> @@ -604,22 +603,22 @@ setup_test_string_tunneled(struct rte_mempool
> *mpool, const char *string,
>  	/* copy outer IP and ESP header */
>  	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
>  	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
> -	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> +	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
>  	dst += sizeof(ipv4_outer);
>  	m->l3_len = sizeof(ipv4_outer);
> -	rte_memcpy(dst, &esph, sizeof(esph));
> +	memcpy(dst, &esph, sizeof(esph));
>  	dst += sizeof(esph);
> 
>  	if (string != NULL) {
>  		/* copy payload */
> -		rte_memcpy(dst, string, len);
> +		memcpy(dst, string, len);
>  		dst += len;
>  		/* copy pad bytes */
> -		rte_memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
> +		memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
>  			sizeof(esp_pad_bytes)));
>  		dst += padlen;
>  		/* copy ESP tail header */
> -		rte_memcpy(dst, &espt, sizeof(espt));
> +		memcpy(dst, &espt, sizeof(espt));
>  	} else
>  		memset(dst, 0, t_len);
> 
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>

> 2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 16:42 ` Konstantin Ananyev
@ 2026-05-29 20:45   ` Morten Brørup
  2026-05-29 22:52     ` Stephen Hemminger
  2026-05-29 22:58     ` Stephen Hemminger
  0 siblings, 2 replies; 8+ messages in thread
From: Morten Brørup @ 2026-05-29 20:45 UTC (permalink / raw)
  To: Konstantin Ananyev, Stephen Hemminger, dev; +Cc: Vladimir Medvedkin

> > This test has tables of data that get copied with rte_memcpy.
> > But when compiled without always inline the compiler gets confused
> > by the inlining of rte_memcpy and thinks that it is possible for AVX
> > code to reference past the input data.
> >
> > Workaround is to use memcpy() which is better for this test anyway
> > since regular memcpy has more static checking from compiler and
> > analyzers.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  app/test/test_ipsec.c | 13 ++++++-------
> >  1 file changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c
> > index 139c1e8dec..b5a430996d 100644
> > --- a/app/test/test_ipsec.c
> > +++ b/app/test/test_ipsec.c
> > @@ -10,7 +10,6 @@
> >  #include <rte_hexdump.h>
> >  #include <rte_mbuf.h>
> >  #include <rte_malloc.h>
> > -#include <rte_memcpy.h>
> >  #include <rte_cycles.h>
> >  #include <rte_bus_vdev.h>
> >  #include <rte_ip.h>
> > @@ -559,7 +558,7 @@ setup_test_string(struct rte_mempool *mpool,
> const
> > char *string,
> >  			return NULL;
> >  		}
> >  		if (string != NULL)
> > -			rte_memcpy(dst, string, t_len);
> > +			memcpy(dst, string, t_len);
> >  		else
> >  			memset(dst, 0, t_len);
> >  	}
> > @@ -604,22 +603,22 @@ setup_test_string_tunneled(struct rte_mempool
> > *mpool, const char *string,
> >  	/* copy outer IP and ESP header */
> >  	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
> >  	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
> > -	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> > +	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));

How about:
*dst = ipv4_outer;

Don't know if it applies here.

> >  	dst += sizeof(ipv4_outer);
> >  	m->l3_len = sizeof(ipv4_outer);
> > -	rte_memcpy(dst, &esph, sizeof(esph));
> > +	memcpy(dst, &esph, sizeof(esph));
> >  	dst += sizeof(esph);
> >
> >  	if (string != NULL) {
> >  		/* copy payload */
> > -		rte_memcpy(dst, string, len);
> > +		memcpy(dst, string, len);
> >  		dst += len;
> >  		/* copy pad bytes */
> > -		rte_memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
> > +		memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
> >  			sizeof(esp_pad_bytes)));
> >  		dst += padlen;
> >  		/* copy ESP tail header */
> > -		rte_memcpy(dst, &espt, sizeof(espt));
> > +		memcpy(dst, &espt, sizeof(espt));

Also here:
*dst = espt;

Also don't know if it applies here.

> >  	} else
> >  		memset(dst, 0, t_len);
> >
> > --
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 
> > 2.53.0

With or without suggested changes:
Acked-by: Morten Brørup <mb@smartsharesystems.com>

If you are curious too...
Does the compiler still get confused about AVX rte_memcpy (without this patch), if applying the rte_memcpy patch?
https://patchwork.dpdk.org/project/dpdk/patch/20260521185631.116046-1-mb@smartsharesystems.com/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 20:45   ` Morten Brørup
@ 2026-05-29 22:52     ` Stephen Hemminger
  2026-05-30  5:31       ` Morten Brørup
  2026-05-29 22:58     ` Stephen Hemminger
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2026-05-29 22:52 UTC (permalink / raw)
  To: Morten Brørup; +Cc: Konstantin Ananyev, dev, Vladimir Medvedkin

On Fri, 29 May 2026 22:45:00 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:

> > > @@ -604,22 +603,22 @@ setup_test_string_tunneled(struct rte_mempool
> > > *mpool, const char *string,
> > >  	/* copy outer IP and ESP header */
> > >  	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
> > >  	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
> > > -	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> > > +	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));  
> 
> How about:
> *dst = ipv4_outer;
> 
> Don't know if it applies here.

Good idea but dst is char *.
I suppose could use a cast but at that point the good
properties of assignment disappear.

Didn't want to go changing other code.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 20:45   ` Morten Brørup
  2026-05-29 22:52     ` Stephen Hemminger
@ 2026-05-29 22:58     ` Stephen Hemminger
  2026-05-30  5:36       ` Morten Brørup
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2026-05-29 22:58 UTC (permalink / raw)
  To: Morten Brørup; +Cc: Konstantin Ananyev, dev, Vladimir Medvedkin

On Fri, 29 May 2026 22:45:00 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:

> If you are curious too...
> Does the compiler still get confused about AVX rte_memcpy (without this patch), if applying the rte_memcpy patch?
> https://patchwork.dpdk.org/project/dpdk/patch/20260521185631.116046-1-mb@smartsharesystems.com/

No still fails.

This is if __rte_always_inline is defined as just inline as an experiment.
Compiler gets confused in virtio_net because of matching conditions doing
initialization in virtio_net.

Also, has issue with rte_memcpy.

ninja: Entering directory `build'
[2352/3763] Compiling C object lib/librte_vhost.a.p/vhost_virtio_net.c.o
../lib/vhost/virtio_net.c: In function ‘desc_to_mbuf’:
../lib/vhost/virtio_net.c:3025:34: warning: ‘pkts_info’ may be used uninitialized [-Wmaybe-uninitialized]
 3025 |                         pkts_info[slot_idx].nethdr = *hdr;
      |                                  ^
../lib/vhost/virtio_net.c:2915:37: note: ‘pkts_info’ was declared here
 2915 |         struct async_inflight_info *pkts_info;
      |                                     ^~~~~~~~~
[3487/3763] Compiling C object app/dpdk-test.p/test_test_ipsec.c.o
In file included from /usr/lib/gcc/x86_64-linux-gnu/15/include/immintrin.h:43,
                 from ../lib/eal/x86/include/rte_rtm.h:8,
                 from ../lib/eal/x86/include/rte_spinlock.h:9,
                 from ../lib/mempool/rte_mempool.h:44,
                 from ../lib/mbuf/rte_mbuf.h:39,
                 from ../app/test/test_ipsec.c:11:
In function ‘_mm256_loadu_si256’,
    inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:119:9,
    inlined from ‘rte_mov64’ at ../lib/eal/x86/include/rte_memcpy.h:158:2,
    inlined from ‘rte_mov128’ at ../lib/eal/x86/include/rte_memcpy.h:170:2,
    inlined from ‘rte_memcpy_generic_more_than_64’ at ../lib/eal/x86/include/rte_memcpy.h:389:4,
    inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:715:10,
    inlined from ‘setup_test_string_tunneled.constprop’ at ../app/test/test_ipsec.c:615:3:
/usr/lib/gcc/x86_64-linux-gnu/15/include/avxintrin.h:873:10: warning: array subscript ‘__m256i_u[3]’ is partly outside array bounds of ‘const char[108]’ [-Warray-bounds=]
  873 |   return *__P;
      |          ^~~~
../app/test/test_ipsec.c: In function ‘setup_test_string_tunneled.constprop’:
../app/test/test_ipsec.c:527:12: note: at offset 96 into object ‘null_plain_data’ of size 108
  527 | const char null_plain_data[] =
      |            ^~~~~~~~~~~~~~~
[3763/3763] Linking target app/dpdk-test

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 22:52     ` Stephen Hemminger
@ 2026-05-30  5:31       ` Morten Brørup
  0 siblings, 0 replies; 8+ messages in thread
From: Morten Brørup @ 2026-05-30  5:31 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Konstantin Ananyev, dev, Vladimir Medvedkin

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, 30 May 2026 00.53
> 
> On Fri, 29 May 2026 22:45:00 +0200
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > > > @@ -604,22 +603,22 @@ setup_test_string_tunneled(struct
> rte_mempool
> > > > *mpool, const char *string,
> > > >  	/* copy outer IP and ESP header */
> > > >  	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
> > > >  	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
> > > > -	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> > > > +	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> >
> > How about:
> > *dst = ipv4_outer;
> >
> > Don't know if it applies here.
> 
> Good idea but dst is char *.
> I suppose could use a cast but at that point the good
> properties of assignment disappear.
> 
> Didn't want to go changing other code.

Agree. Better stick with memcpy() than type cast.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 22:58     ` Stephen Hemminger
@ 2026-05-30  5:36       ` Morten Brørup
  0 siblings, 0 replies; 8+ messages in thread
From: Morten Brørup @ 2026-05-30  5:36 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Konstantin Ananyev, dev, Vladimir Medvedkin

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, 30 May 2026 00.59
> 
> On Fri, 29 May 2026 22:45:00 +0200
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > If you are curious too...
> > Does the compiler still get confused about AVX rte_memcpy (without
> this patch), if applying the rte_memcpy patch?
> > https://patchwork.dpdk.org/project/dpdk/patch/20260521185631.116046-
> 1-mb@smartsharesystems.com/
> 
> No still fails.
> 
> This is if __rte_always_inline is defined as just inline as an
> experiment.
> Compiler gets confused in virtio_net because of matching conditions
> doing
> initialization in virtio_net.
> 
> Also, has issue with rte_memcpy.
> 
> ninja: Entering directory `build'
> [2352/3763] Compiling C object
> lib/librte_vhost.a.p/vhost_virtio_net.c.o
> ../lib/vhost/virtio_net.c: In function ‘desc_to_mbuf’:
> ../lib/vhost/virtio_net.c:3025:34: warning: ‘pkts_info’ may be used
> uninitialized [-Wmaybe-uninitialized]
>  3025 |                         pkts_info[slot_idx].nethdr = *hdr;
>       |                                  ^
> ../lib/vhost/virtio_net.c:2915:37: note: ‘pkts_info’ was declared here
>  2915 |         struct async_inflight_info *pkts_info;
>       |                                     ^~~~~~~~~
> [3487/3763] Compiling C object app/dpdk-test.p/test_test_ipsec.c.o
> In file included from /usr/lib/gcc/x86_64-linux-
> gnu/15/include/immintrin.h:43,
>                  from ../lib/eal/x86/include/rte_rtm.h:8,
>                  from ../lib/eal/x86/include/rte_spinlock.h:9,
>                  from ../lib/mempool/rte_mempool.h:44,
>                  from ../lib/mbuf/rte_mbuf.h:39,
>                  from ../app/test/test_ipsec.c:11:
> In function ‘_mm256_loadu_si256’,
>     inlined from ‘rte_mov32’ at
> ../lib/eal/x86/include/rte_memcpy.h:119:9,
>     inlined from ‘rte_mov64’ at
> ../lib/eal/x86/include/rte_memcpy.h:158:2,
>     inlined from ‘rte_mov128’ at
> ../lib/eal/x86/include/rte_memcpy.h:170:2,
>     inlined from ‘rte_memcpy_generic_more_than_64’ at
> ../lib/eal/x86/include/rte_memcpy.h:389:4,
>     inlined from ‘rte_memcpy’ at
> ../lib/eal/x86/include/rte_memcpy.h:715:10,
>     inlined from ‘setup_test_string_tunneled.constprop’ at
> ../app/test/test_ipsec.c:615:3:
> /usr/lib/gcc/x86_64-linux-gnu/15/include/avxintrin.h:873:10: warning:
> array subscript ‘__m256i_u[3]’ is partly outside array bounds of ‘const
> char[108]’ [-Warray-bounds=]
>   873 |   return *__P;
>       |          ^~~~
> ../app/test/test_ipsec.c: In function
> ‘setup_test_string_tunneled.constprop’:
> ../app/test/test_ipsec.c:527:12: note: at offset 96 into object
> ‘null_plain_data’ of size 108
>   527 | const char null_plain_data[] =
>       |            ^~~~~~~~~~~~~~~
> [3763/3763] Linking target app/dpdk-test

Interesting experiment. Thanks for sharing.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [EXTERNAL] [PATCH] app/test: use memcpy in ipsec test
  2026-05-29 15:46 [PATCH] app/test: use memcpy in ipsec test Stephen Hemminger
  2026-05-29 16:42 ` Konstantin Ananyev
@ 2026-06-02 19:36 ` Akhil Goyal
  1 sibling, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2026-06-02 19:36 UTC (permalink / raw)
  To: Stephen Hemminger, dev@dpdk.org; +Cc: Konstantin Ananyev, Vladimir Medvedkin

> This test has tables of data that get copied with rte_memcpy.
> But when compiled without always inline the compiler gets confused
> by the inlining of rte_memcpy and thinks that it is possible for AVX
> code to reference past the input data.
> 
> Workaround is to use memcpy() which is better for this test anyway
> since regular memcpy has more static checking from compiler and
> analyzers.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Applied to dpdk-next-crypto
Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-02 19:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 15:46 [PATCH] app/test: use memcpy in ipsec test Stephen Hemminger
2026-05-29 16:42 ` Konstantin Ananyev
2026-05-29 20:45   ` Morten Brørup
2026-05-29 22:52     ` Stephen Hemminger
2026-05-30  5:31       ` Morten Brørup
2026-05-29 22:58     ` Stephen Hemminger
2026-05-30  5:36       ` Morten Brørup
2026-06-02 19:36 ` [EXTERNAL] " Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox