[PATCH] test: defer timer initialization
David Marchand
david.marchand at redhat.com
Sat Oct 17 16:47:47 CEST 2026
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.
Cc: stable at dpdk.org
Signed-off-by: David Marchand <david.marchand at redhat.com>
---
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(-)
diff --git a/app/test/test.c b/app/test/test.c
index c610c3588e..8f23325cb6 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -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;
diff --git a/app/test/test_pdcp.c b/app/test/test_pdcp.c
index 784e2dddd9..4802225791 100644
--- a/app/test/test_pdcp.c
+++ b/app/test/test_pdcp.c
@@ -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);
diff --git a/app/test/test_timer.c b/app/test/test_timer.c
index c936843ddc..c943d3155d 100644
--- a/app/test/test_timer.c
+++ b/app/test/test_timer.c
@@ -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");
diff --git a/app/test/test_timer_perf.c b/app/test/test_timer_perf.c
index d2d74ebbc6..feb2e910b5 100644
--- a/app/test/test_timer_perf.c
+++ b/app/test/test_timer_perf.c
@@ -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);
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 6f8b448ff8..4f0ae04062 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -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();
diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_secondary.c
index 529774f4d0..0f325365ad 100644
--- a/app/test/test_timer_secondary.c
+++ b/app/test/test_timer_secondary.c
@@ -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");
--
2.54.0
More information about the dev
mailing list