With large core system this would end up taking too long and
test would time out. Scale the number of timers based on
the number lcores available.

Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
Cc: [email protected]

Signed-off-by: Stephen Hemminger <[email protected]>
---
 app/test/test_timer_secondary.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_secondary.c
index 8bff904ed4..003782b89c 100644
--- a/app/test/test_timer_secondary.c
+++ b/app/test/test_timer_secondary.c
@@ -27,7 +27,8 @@ test_timer_secondary(void)
 
 #include "process.h"
 
-#define NUM_TIMERS             (1 << 20) /* ~1M timers */
+#define NUM_TIMERS_MAX         (1 << 20) /* ~1M timers */
+#define NUM_TIMERS_MIN         (1 << 14) /* 16K minimum */
 #define NUM_LCORES_NEEDED      3
 #define TEST_INFO_MZ_NAME      "test_timer_info_mz"
 #define MSECPERSEC             1E3
@@ -38,11 +39,12 @@ struct test_info {
        unsigned int main_lcore;
        unsigned int mgr_lcore;
        unsigned int sec_lcore;
+       unsigned int num_timers;
        uint32_t timer_data_id;
        volatile int expected_count;
        volatile int expired_count;
        struct rte_mempool *tim_mempool;
-       struct rte_timer *expired_timers[NUM_TIMERS];
+       struct rte_timer *expired_timers[NUM_TIMERS_MAX];
        int expired_timers_idx;
        volatile int exit_flag;
 };
@@ -138,8 +140,10 @@ test_timer_secondary(void)
                                     "test data");
                test_info = mz->addr;
 
+               test_info->num_timers = test_scale_iterations(NUM_TIMERS_MAX, 
NUM_TIMERS_MIN);
+
                test_info->tim_mempool = rte_mempool_create("test_timer_mp",
-                               NUM_TIMERS, sizeof(struct rte_timer), 0, 0,
+                               test_info->num_timers, sizeof(struct 
rte_timer), 0, 0,
                                NULL, NULL, NULL, NULL, rte_socket_id(), 0);
 
                ret = rte_timer_data_alloc(&test_info->timer_data_id);
@@ -178,14 +182,14 @@ test_timer_secondary(void)
        } else if (proc_type == RTE_PROC_SECONDARY) {
                uint64_t ticks, timeout_ms;
                struct rte_timer *tim;
-               int i;
+               unsigned int i;
 
                mz = rte_memzone_lookup(TEST_INFO_MZ_NAME);
                TEST_ASSERT_NOT_NULL(mz, "Couldn't lookup memzone for "
                                     "test info");
                test_info = mz->addr;
 
-               for (i = 0; i < NUM_TIMERS; i++) {
+               for (i = 0; i < test_info->num_timers; i++) {
                        rte_mempool_get(test_info->tim_mempool, (void **)&tim);
 
                        rte_timer_init(tim);
-- 
2.51.0

Reply via email to