app/test: fix stack overflow in fib6_perf_autotest
PATCH 1/1 app/test: fix stack overflow in fib6_perf_autotest
Test fib6_perf_autotest was hitting a stack overflow on Windows with MSVC.
The fix is to move some of the data from the stack to the heap.
--- app/test/test_fib6_perf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
app/test/test_fib6_perf.c +12 -2
@@ -9,6 +9,7 @@#include <rte_cycles.h> #include <rte_random.h> +#include <rte_malloc.h> #include <rte_memory.h> #include <rte_fib6.h>
@@ -73,8 +74,14 @@ test_fib6_perf(void)uint64_t next_hop_add;int status =0 ;int64_t count =0 ; -struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES ]; -uint64_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_FIB_ASSERT (ip_batch !=NULL ); + +uint64_t *next_hops =rte_calloc ("next_hops" , +NUM_IPS_ENTRIES ,sizeof (uint64_t ),0 ); +TEST_FIB_ASSERT (next_hops !=NULL ); conf.type =RTE_FIB6_TRIE ; conf.default_nh =0 ;
@@ -151,6 +158,9 @@ test_fib6_perf(void)rte_fib6_free (fib); +rte_free (next_hops); +rte_free (ip_batch); +return 0 ; }
Signature · 1 line
2.47.0.vfs.0.3
Quoted 7 lines · On Mon, 23 Dec 2024 13:10:33 -0800 Andre Muezerie…
From: Andre Muezerie <[email protected]>
To: Vladimir Medvedkin <[email protected]>
Cc: [email protected], Andre Muezerie <[email protected]>
Subject: [PATCH] app/test: fix stack overflow infib6_perf_autotest
Date: Mon, 23 Dec 2024 13:10:33 -0800
X-Mailer: git-send-email 1.8.3.1
Quoted 6 lines
Test
fib6_perf_autotestwas hitting a stack overflow on Windows with MSVC.The fix is to move some of the data from the stack to the heap.
Signed-off-by Andre Muezerie <[email protected]>
Use regular malloc please.rte_malloc comes from hugepages which are more limited and slower to manipulate.
Quoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Mon, 23 Dec 2024 13:10:33 -0800 Andre Muezerie…
From: Andre Muezerie <[email protected]>
To: Vladimir Medvedkin <[email protected]>
Cc: [email protected], Andre Muezerie <[email protected]>
Subject: [PATCH] app/test: fix stack overflow infib6_perf_autotest
Date: Mon, 23 Dec 2024 13:10:33 -0800
X-Mailer: git-send-email 1.8.3.1Test
fib6_perf_autotestwas hitting a stack overflow on Windows with MSVC.
Quoted 6 lines
Quoted 3 lines
The fix is to move some of the data from the stack to the heap.
Signed-off-by Andre Muezerie <[email protected]>Use regular malloc please.
rte_malloccomes from hugepages which are more limited and slower to manipulate.
I recently submitted a patch for a test with a very similar issue and during review one of the reviewers encouraged me to use rte_calloc to allocate memory for the arrays, which I think makes sense (I had used malloc initially):
Even though this is a perf test, the code responsible for the memory allocations is not in the path for which time measurements are being taken (points between rte_rdtsc calls), so perf for the memory allocation code is probably not so critical.
That being said, if you still feel strongly that malloc should be used instead let me know and I can make that change.
Thanks,
Andre Muezerie
Medvedkin, Vladimir
Acked-byHi,
I think using rte_malloc(rte_calloc) here would be a better choice because:
- As Andre mentioned allocation happens outside of the performance measurement section
- Due to relatively large size of the memory allocated for ip_batch/next_hops some CPUs may experience TLB cache pressure, which will affect performance measurement results.
With that being said
Quoted 37 lines · Andre Muezerie
Quoted 10 lines · Stephen Hemminger
Quoted 7 lines · On Mon, 23 Dec 2024 13:10:33 -0800 Andre Muezerie…
From: Andre Muezerie <[email protected]>
To: Vladimir Medvedkin <[email protected]>
Cc: [email protected], Andre Muezerie <[email protected]>
Subject: [PATCH] app/test: fix stack overflow infib6_perf_autotest
Date: Mon, 23 Dec 2024 13:10:33 -0800
X-Mailer: git-send-email 1.8.3.1Quoted 8 lines
Quoted 6 lines
Test
fib6_perf_autotestwas hitting a stack overflow on Windows with MSVC.The fix is to move some of the data from the stack to the heap.
Signed-off-by Andre Muezerie <[email protected]>Use regular malloc please.
rte_malloccomes from hugepages which are more limited and slower to manipulate.I recently submitted a patch for a test with a very similar issue and during review one of the reviewers encouraged me to use
rte_callocto allocate memory for the arrays, which I think makes sense (I had used malloc initially):Even though this is a perf test, the code responsible for the memory allocations is not in the path for which time measurements are being taken (points between
rte_rdtsccalls), so perf for the memory allocation code is probably not so critical.That being said, if you still feel strongly that malloc should be used instead let me know and I can make that change.
Thanks,
Andre Muezerie
Signature · 2 lines
Regards, Vladimir
David Marchand
AppliedQuoted 8 lines · Andre Muezerie
Test
fib6_perf_autotestwas hitting a stack overflow on Windows with MSVC.The fix is to move some of the data from the stack to the heap.
Signed-off-by Andre Muezerie <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand