DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/test: fix stack overflow in lpm6_perf_autotest
@ 2024-12-13  2:39 Andre Muezerie
  2024-12-13 10:22 ` Medvedkin, Vladimir
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andre Muezerie @ 2024-12-13  2:39 UTC (permalink / raw)
  To: Bruce Richardson, Vladimir Medvedkin; +Cc: dev, Andre Muezerie

Test lpm6_perf_autotest was hitting a stack overflow on Windows
with both MSVC and Clang.

The fix is to move some of the data from the stack to the heap.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_lpm6_perf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index 1860a99ed6..8231ad825d 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -117,8 +117,12 @@ test_lpm6_perf(void)
 	total_time = 0;
 	count = 0;
 
-	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
-	int32_t next_hops[NUM_IPS_ENTRIES];
+	struct rte_ipv6_addr *ip_batch = (struct rte_ipv6_addr *)malloc(
+			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES);
+	TEST_LPM_ASSERT(ip_batch != NULL);
+
+	int32_t *next_hops = (int32_t *)malloc(sizeof(int32_t) * NUM_IPS_ENTRIES);
+	TEST_LPM_ASSERT(next_hops != NULL);
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
 		ip_batch[i] = large_ips_table[i].ip;
@@ -153,6 +157,9 @@ test_lpm6_perf(void)
 	printf("Average LPM Delete: %g cycles\n",
 			(double)total_time / NUM_ROUTE_ENTRIES);
 
+	free(next_hops);
+	free(ip_batch);
+
 	rte_lpm6_delete_all(lpm);
 	rte_lpm6_free(lpm);
 
-- 
2.47.0.vfs.0.3


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

* Re: [PATCH] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13  2:39 [PATCH] app/test: fix stack overflow in lpm6_perf_autotest Andre Muezerie
@ 2024-12-13 10:22 ` Medvedkin, Vladimir
  2024-12-13 17:05   ` Andre Muezerie
  2024-12-13 17:08   ` Stephen Hemminger
  2024-12-13 17:08 ` [PATCH v2] " Andre Muezerie
  2024-12-18 15:21 ` [PATCH v3] " Andre Muezerie
  2 siblings, 2 replies; 8+ messages in thread
From: Medvedkin, Vladimir @ 2024-12-13 10:22 UTC (permalink / raw)
  To: Andre Muezerie, Bruce Richardson; +Cc: dev

Hi Andre,

On 13/12/2024 02:39, Andre Muezerie wrote:
> Test lpm6_perf_autotest was hitting a stack overflow on Windows
> with both MSVC and Clang.
>
> The fix is to move some of the data from the stack to the heap.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
>   app/test/test_lpm6_perf.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
> index 1860a99ed6..8231ad825d 100644
> --- a/app/test/test_lpm6_perf.c
> +++ b/app/test/test_lpm6_perf.c
> @@ -117,8 +117,12 @@ test_lpm6_perf(void)
>   	total_time = 0;
>   	count = 0;
>   
> -	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
> -	int32_t next_hops[NUM_IPS_ENTRIES];
> +	struct rte_ipv6_addr *ip_batch = (struct rte_ipv6_addr *)malloc(
why not rte_malloc?
> +			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES);
> +	TEST_LPM_ASSERT(ip_batch != NULL);
> +
> +	int32_t *next_hops = (int32_t *)malloc(sizeof(int32_t) * NUM_IPS_ENTRIES);
> +	TEST_LPM_ASSERT(next_hops != NULL);
>   
>   	for (i = 0; i < NUM_IPS_ENTRIES; i++)
>   		ip_batch[i] = large_ips_table[i].ip;
> @@ -153,6 +157,9 @@ test_lpm6_perf(void)
>   	printf("Average LPM Delete: %g cycles\n",
>   			(double)total_time / NUM_ROUTE_ENTRIES);
>   
> +	free(next_hops);
> +	free(ip_batch);
> +
>   	rte_lpm6_delete_all(lpm);
>   	rte_lpm6_free(lpm);
>   

-- 
Regards,
Vladimir


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

* Re: [PATCH] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13 10:22 ` Medvedkin, Vladimir
@ 2024-12-13 17:05   ` Andre Muezerie
  2024-12-13 17:08   ` Stephen Hemminger
  1 sibling, 0 replies; 8+ messages in thread
From: Andre Muezerie @ 2024-12-13 17:05 UTC (permalink / raw)
  To: Medvedkin, Vladimir; +Cc: Bruce Richardson, dev

On Fri, Dec 13, 2024 at 10:22:20AM +0000, Medvedkin, Vladimir wrote:
> Hi Andre,
> 
> On 13/12/2024 02:39, Andre Muezerie wrote:
> >Test lpm6_perf_autotest was hitting a stack overflow on Windows
> >with both MSVC and Clang.
> >
> >The fix is to move some of the data from the stack to the heap.
> >
> >Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> >---
> >  app/test/test_lpm6_perf.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> >diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
> >index 1860a99ed6..8231ad825d 100644
> >--- a/app/test/test_lpm6_perf.c
> >+++ b/app/test/test_lpm6_perf.c
> >@@ -117,8 +117,12 @@ test_lpm6_perf(void)
> >  	total_time = 0;
> >  	count = 0;
> >-	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
> >-	int32_t next_hops[NUM_IPS_ENTRIES];
> >+	struct rte_ipv6_addr *ip_batch = (struct rte_ipv6_addr *)malloc(
> why not rte_malloc?

For no good reason :-)
I'll update the patch.
Thanks for the suggestion.

Andre Muezerie

> >+			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES);
> >+	TEST_LPM_ASSERT(ip_batch != NULL);
> >+
> >+	int32_t *next_hops = (int32_t *)malloc(sizeof(int32_t) * NUM_IPS_ENTRIES);
> >+	TEST_LPM_ASSERT(next_hops != NULL);
> >  	for (i = 0; i < NUM_IPS_ENTRIES; i++)
> >  		ip_batch[i] = large_ips_table[i].ip;
> >@@ -153,6 +157,9 @@ test_lpm6_perf(void)
> >  	printf("Average LPM Delete: %g cycles\n",
> >  			(double)total_time / NUM_ROUTE_ENTRIES);
> >+	free(next_hops);
> >+	free(ip_batch);
> >+
> >  	rte_lpm6_delete_all(lpm);
> >  	rte_lpm6_free(lpm);
> 
> -- 
> Regards,
> Vladimir

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

* Re: [PATCH] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13 10:22 ` Medvedkin, Vladimir
  2024-12-13 17:05   ` Andre Muezerie
@ 2024-12-13 17:08   ` Stephen Hemminger
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2024-12-13 17:08 UTC (permalink / raw)
  To: Medvedkin, Vladimir; +Cc: Andre Muezerie, Bruce Richardson, dev

On Fri, 13 Dec 2024 10:22:20 +0000
"Medvedkin, Vladimir" <vladimir.medvedkin@intel.com> wrote:

> Hi Andre,
> 
> On 13/12/2024 02:39, Andre Muezerie wrote:
> > Test lpm6_perf_autotest was hitting a stack overflow on Windows
> > with both MSVC and Clang.
> >
> > The fix is to move some of the data from the stack to the heap.
> >
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > ---
> >   app/test/test_lpm6_perf.c | 11 +++++++++--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
> > index 1860a99ed6..8231ad825d 100644
> > --- a/app/test/test_lpm6_perf.c
> > +++ b/app/test/test_lpm6_perf.c
> > @@ -117,8 +117,12 @@ test_lpm6_perf(void)
> >   	total_time = 0;
> >   	count = 0;
> >   
> > -	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
> > -	int32_t next_hops[NUM_IPS_ENTRIES];
> > +	struct rte_ipv6_addr *ip_batch = (struct rte_ipv6_addr *)malloc(  
> why not rte_malloc?
> > +			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES);
> > +	TEST_LPM_ASSERT(ip_batch != NULL);

There is no need for rte_malloc() here. The data doesn't need to
come from hugepages and regular malloc() has more checking.

But the cast is unnecessary in C.

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

* [PATCH v2] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13  2:39 [PATCH] app/test: fix stack overflow in lpm6_perf_autotest Andre Muezerie
  2024-12-13 10:22 ` Medvedkin, Vladimir
@ 2024-12-13 17:08 ` Andre Muezerie
  2024-12-13 17:15   ` Stephen Hemminger
  2024-12-18 15:21 ` [PATCH v3] " Andre Muezerie
  2 siblings, 1 reply; 8+ messages in thread
From: Andre Muezerie @ 2024-12-13 17:08 UTC (permalink / raw)
  To: andremue; +Cc: bruce.richardson, dev, vladimir.medvedkin

Test lpm6_perf_autotest was hitting a stack overflow on Windows
with both MSVC and Clang.

The fix is to move some of the data from the stack to the heap.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_lpm6_perf.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index 1860a99ed6..a09e8611ce 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -10,6 +10,7 @@
 
 #include <rte_cycles.h>
 #include <rte_random.h>
+#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
@@ -117,8 +118,14 @@ test_lpm6_perf(void)
 	total_time = 0;
 	count = 0;
 
-	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
-	int32_t next_hops[NUM_IPS_ENTRIES];
+	struct rte_ipv6_addr *ip_batch =
+			(struct rte_ipv6_addr *)rte_malloc("ip_batch",
+			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES, 0);
+	TEST_LPM_ASSERT(ip_batch != NULL);
+
+	int32_t *next_hops = (int32_t *)rte_malloc("next_hops",
+			sizeof(int32_t) * NUM_IPS_ENTRIES, 0);
+	TEST_LPM_ASSERT(next_hops != NULL);
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
 		ip_batch[i] = large_ips_table[i].ip;
@@ -153,6 +160,9 @@ test_lpm6_perf(void)
 	printf("Average LPM Delete: %g cycles\n",
 			(double)total_time / NUM_ROUTE_ENTRIES);
 
+	rte_free(next_hops);
+	rte_free(ip_batch);
+
 	rte_lpm6_delete_all(lpm);
 	rte_lpm6_free(lpm);
 
-- 
2.47.0.vfs.0.3


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

* Re: [PATCH v2] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13 17:08 ` [PATCH v2] " Andre Muezerie
@ 2024-12-13 17:15   ` Stephen Hemminger
  2024-12-18 15:12     ` Andre Muezerie
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-12-13 17:15 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: bruce.richardson, dev, vladimir.medvedkin

On Fri, 13 Dec 2024 09:08:22 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> +	struct rte_ipv6_addr *ip_batch =
> +			(struct rte_ipv6_addr *)rte_malloc("ip_batch",
> +			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES, 0

Cast is not needed here.
If you are going to allocate an array, use calloc() or rte_calloc()

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

* Re: [PATCH v2] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13 17:15   ` Stephen Hemminger
@ 2024-12-18 15:12     ` Andre Muezerie
  0 siblings, 0 replies; 8+ messages in thread
From: Andre Muezerie @ 2024-12-18 15:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: bruce.richardson, dev, vladimir.medvedkin

On Fri, Dec 13, 2024 at 09:15:40AM -0800, Stephen Hemminger wrote:
> On Fri, 13 Dec 2024 09:08:22 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > +	struct rte_ipv6_addr *ip_batch =
> > +			(struct rte_ipv6_addr *)rte_malloc("ip_batch",
> > +			sizeof(struct rte_ipv6_addr) * NUM_IPS_ENTRIES, 0
> 
> Cast is not needed here.
> If you are going to allocate an array, use calloc() or rte_calloc()

Thanks for the comments. I'll update the patch.

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

* [PATCH v3] app/test: fix stack overflow in lpm6_perf_autotest
  2024-12-13  2:39 [PATCH] app/test: fix stack overflow in lpm6_perf_autotest Andre Muezerie
  2024-12-13 10:22 ` Medvedkin, Vladimir
  2024-12-13 17:08 ` [PATCH v2] " Andre Muezerie
@ 2024-12-18 15:21 ` Andre Muezerie
  2 siblings, 0 replies; 8+ messages in thread
From: Andre Muezerie @ 2024-12-18 15:21 UTC (permalink / raw)
  To: andremue; +Cc: stephen, bruce.richardson, dev, vladimir.medvedkin

Test lpm6_perf_autotest was hitting a stack overflow on Windows
with both MSVC and Clang.

The fix is to move some of the data from the stack to the heap.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_lpm6_perf.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index 1860a99ed6..59df0a958a 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -10,6 +10,7 @@
 
 #include <rte_cycles.h>
 #include <rte_random.h>
+#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
@@ -117,8 +118,13 @@ test_lpm6_perf(void)
 	total_time = 0;
 	count = 0;
 
-	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
-	int32_t next_hops[NUM_IPS_ENTRIES];
+	struct rte_ipv6_addr *ip_batch = rte_calloc("ip_batch",
+			NUM_IPS_ENTRIES, sizeof(struct rte_ipv6_addr), 0);
+	TEST_LPM_ASSERT(ip_batch != NULL);
+
+	int32_t *next_hops = rte_calloc("next_hops",
+			NUM_IPS_ENTRIES, sizeof(int32_t), 0);
+	TEST_LPM_ASSERT(next_hops != NULL);
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
 		ip_batch[i] = large_ips_table[i].ip;
@@ -153,6 +159,9 @@ test_lpm6_perf(void)
 	printf("Average LPM Delete: %g cycles\n",
 			(double)total_time / NUM_ROUTE_ENTRIES);
 
+	rte_free(next_hops);
+	rte_free(ip_batch);
+
 	rte_lpm6_delete_all(lpm);
 	rte_lpm6_free(lpm);
 
-- 
2.47.0.vfs.0.3


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

end of thread, other threads:[~2024-12-18 15:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-13  2:39 [PATCH] app/test: fix stack overflow in lpm6_perf_autotest Andre Muezerie
2024-12-13 10:22 ` Medvedkin, Vladimir
2024-12-13 17:05   ` Andre Muezerie
2024-12-13 17:08   ` Stephen Hemminger
2024-12-13 17:08 ` [PATCH v2] " Andre Muezerie
2024-12-13 17:15   ` Stephen Hemminger
2024-12-18 15:12     ` Andre Muezerie
2024-12-18 15:21 ` [PATCH v3] " Andre Muezerie

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).