test: defer timer initialization
PATCH 1/1 test: defer timer initialization
Initialize timers only in unit tests that do require them. This removes an unconditional memzone allocation (3MB on ARM). This avoids failures of the eal_flags_file_prefix_autotest unit test that runs in legacy mem mode and has a tight 18MB memory budget.
--- app/test/test.c | 8 -------- app/test/test_pdcp.c | 6 ++++++ app/test/test_timer.c | 7 +++++++ app/test/test_timer_perf.c | 7 +++++++ app/test/test_timer_racecond.c | 6 ++++++ app/test/test_timer_secondary.c | 12 ++++++++++++ 6 files changed, 38 insertions(+), 8 deletions(-)
app/test/test.c +0 -8
@@ -162,14 +162,6 @@ main(int argc, char **argv) prgname = argv[0 ]; -#ifdef RTE_LIB_TIMER - ret =rte_timer_subsystem_init (); -if (ret <0 && ret != -EALREADY ) { - ret =-1 ; - goto out; - } -#endif -if (commands_init () <0 ) { ret =-1 ; goto out;
app/test/test_pdcp.c +6 -0
@@ -1759,6 +1759,12 @@ test_expiry_with_rte_timer(const struct pdcp_test_conf *ul_conf)if (ul_conf->entity.pdcp_xfrm.pkt_dir ==RTE_SECURITY_PDCP_DOWNLINK )return TEST_SKIPPED ; + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } +/* Set up a timer */ rte_timer_init (&timer);
app/test/test_timer.c +7 -0
@@ -540,12 +540,19 @@ test_timer(void)unsigned i;uint64_t cur_time;uint64_t hz; +int ret;if (rte_lcore_count () <2 ) {printf ("Not enough cores for timer_autotest, expecting at least 2\n" );return TEST_SKIPPED ; } + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } +/* sanity check our timer sources and timer config values */ if (timer_sanity_check () <0 ) {printf ("Timer sanity checks failed\n" );
app/test/test_timer_perf.c +7 -0
@@ -41,6 +41,13 @@ test_timer_perf(void)struct rte_timer *tms;uint64_t start_tsc, end_tsc, delay_start;unsigned lcore_id =rte_lcore_id (); +int ret; + + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } tms =rte_malloc (NULL ,sizeof (*tms) *MAX_ITERATIONS ,0 );
app/test/test_timer_racecond.c +6 -0
@@ -121,6 +121,12 @@ test_timer_racecond(void)unsigned lcore_id;unsigned i; + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + main_lcore = lcore_id =rte_lcore_id (); hz =rte_get_timer_hz ();
app/test/test_timer_secondary.c +12 -0
@@ -134,6 +134,12 @@ test_timer_secondary(void)return TEST_SKIPPED ; } + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + mz =rte_memzone_reserve (TEST_INFO_MZ_NAME ,sizeof (*test_info),SOCKET_ID_ANY ,0 ); TEST_ASSERT_NOT_NULL(mz, "Couldn't allocate memory for "
@@ -188,6 +194,12 @@ test_timer_secondary(void)struct rte_timer *tim;unsigned int i; + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + mz =rte_memzone_lookup (TEST_INFO_MZ_NAME );TEST_ASSERT_NOT_NULL (mz,"Couldn't lookup memzone for " "test info" );
Signature · 1 line
2.54.0
PATCH v2 1/1 test: defer timer initialization
In reply to David MarchandInitialize timers only in unit tests that do require them.
This removes an unconditional memzone allocation (3MB on ARM) and avoids failures of the eal_flags_file_prefix_autotest unit test that runs in legacy mem mode and has a tight 18MB memory budget.
---
Changes since v1:
- fixed overwritten default return code in pdcp_autotest,
- factorized timer init in timer_secondary_autotest,
--- app/test/test.c | 8 -------- app/test/test_pdcp.c | 10 +++++++++- app/test/test_timer.c | 7 +++++++ app/test/test_timer_perf.c | 7 +++++++ app/test/test_timer_racecond.c | 6 ++++++ app/test/test_timer_secondary.c | 18 ++++++++++++------ 6 files changed, 41 insertions(+), 15 deletions(-)
app/test/test.c +0 -8
@@ -162,14 +162,6 @@ main(int argc, char **argv) prgname = argv[0 ]; -#ifdef RTE_LIB_TIMER - ret =rte_timer_subsystem_init (); -if (ret <0 && ret != -EALREADY ) { - ret =-1 ; - goto out; - } -#endif -if (commands_init () <0 ) { ret =-1 ; goto out;
app/test/test_pdcp.c +9 -1
@@ -1751,7 +1751,7 @@ test_expiry_with_rte_timer(const struct pdcp_test_conf *ul_conf)struct test_rte_timer_args timer_args;struct rte_pdcp_entity *pdcp_entity;struct pdcp_test_conf dl_conf; -int ret =TEST_FAILED , nb_out; +int ret, nb_out;struct rte_timer timer = {0 };const int start_count =0 ;
@@ -1759,6 +1759,14 @@ test_expiry_with_rte_timer(const struct pdcp_test_conf *ul_conf)if (ul_conf->entity.pdcp_xfrm.pkt_dir ==RTE_SECURITY_PDCP_DOWNLINK )return TEST_SKIPPED ; + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + + ret =TEST_FAILED ; +/* Set up a timer */ rte_timer_init (&timer);
app/test/test_timer.c +7 -0
@@ -540,12 +540,19 @@ test_timer(void)unsigned i;uint64_t cur_time;uint64_t hz; +int ret;if (rte_lcore_count () <2 ) {printf ("Not enough cores for timer_autotest, expecting at least 2\n" );return TEST_SKIPPED ; } + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } +/* sanity check our timer sources and timer config values */ if (timer_sanity_check () <0 ) {printf ("Timer sanity checks failed\n" );
app/test/test_timer_perf.c +7 -0
@@ -41,6 +41,13 @@ test_timer_perf(void)struct rte_timer *tms;uint64_t start_tsc, end_tsc, delay_start;unsigned lcore_id =rte_lcore_id (); +int ret; + + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } tms =rte_malloc (NULL ,sizeof (*tms) *MAX_ITERATIONS ,0 );
app/test/test_timer_racecond.c +6 -0
@@ -121,6 +121,12 @@ test_timer_racecond(void)unsigned lcore_id;unsigned i; + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + main_lcore = lcore_id =rte_lcore_id (); hz =rte_get_timer_hz ();
app/test/test_timer_secondary.c +12 -6
@@ -127,13 +127,19 @@ test_timer_secondary(void)struct test_info *test_info;int ret; -if (proc_type ==RTE_PROC_PRIMARY ) { -if (rte_lcore_count () <NUM_LCORES_NEEDED ) { -printf ("Not enough cores for test_timer_secondary, expecting at least %u\n" , -NUM_LCORES_NEEDED ); -return TEST_SKIPPED ; - } +if (proc_type ==RTE_PROC_PRIMARY &&rte_lcore_count () <NUM_LCORES_NEEDED ) { +printf ("Not enough cores for test_timer_secondary, expecting at least %u\n" , +NUM_LCORES_NEEDED ); +return TEST_SKIPPED ; + } + ret =rte_timer_subsystem_init (); +if (ret <0 && ret != -EALREADY ) { +printf ("timer subsystem init failed: %d\n" , ret); +return TEST_FAILED ; + } + +if (proc_type ==RTE_PROC_PRIMARY ) { mz =rte_memzone_reserve (TEST_INFO_MZ_NAME ,sizeof (*test_info),SOCKET_ID_ANY ,0 ); TEST_ASSERT_NOT_NULL(mz, "Couldn't allocate memory for "
Signature · 1 line
2.54.0
Quoted 10 lines · David Marchand
Initialize timers only in unit tests that do require them.
This removes an unconditional memzone allocation (3MB on ARM) and avoids failures of the
eal_flags_file_prefix_autotestunit test that runs in legacy mem mode and has a tight 18MB memory budget.Signed-off-by David Marchand <[email protected]>Acked-by Morten Brørup <[email protected]>
David Marchand
AppliedQuoted 7 lines · David Marchand
Initialize timers only in unit tests that do require them.
This removes an unconditional memzone allocation (3MB on ARM) and avoids failures of the
eal_flags_file_prefix_autotestunit test that runs in legacy mem mode and has a tight 18MB memory budget.
Quoted 5 lines
Signed-off-by David Marchand <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand