| 269 | #define NB_STRESS2_TIMERS 8192 |
| 270 | |
| 271 | static int |
| 272 | timer_stress2_main_loop(__rte_unused void *arg) |
| 273 | { |
| 274 | static struct rte_timer *timers; |
| 275 | int i, ret; |
| 276 | uint64_t delay = rte_get_timer_hz() / 20; |
| 277 | unsigned int lcore_id = rte_lcore_id(); |
| 278 | unsigned int main_lcore = rte_get_main_lcore(); |
| 279 | int32_t my_collisions = 0; |
| 280 | static uint32_t collisions; |
| 281 | |
| 282 | if (lcore_id == main_lcore) { |
| 283 | cb_count = 0; |
| 284 | test_failed = 0; |
| 285 | __atomic_store_n(&collisions, 0, __ATOMIC_RELAXED); |
| 286 | timers = rte_malloc(NULL, sizeof(*timers) * NB_STRESS2_TIMERS, 0); |
| 287 | if (timers == NULL) { |
| 288 | printf("Test Failed\n"); |
| 289 | printf("- Cannot allocate memory for timers\n" ); |
| 290 | test_failed = 1; |
| 291 | main_start_workers(); |
| 292 | goto cleanup; |
| 293 | } |
| 294 | for (i = 0; i < NB_STRESS2_TIMERS; i++) |
| 295 | rte_timer_init(&timers[i]); |
| 296 | main_start_workers(); |
| 297 | } else { |
| 298 | worker_wait_to_start(); |
| 299 | if (test_failed) |
| 300 | goto cleanup; |
| 301 | } |
| 302 | |
| 303 | /* have all cores schedule all timers on main lcore */ |
| 304 | for (i = 0; i < NB_STRESS2_TIMERS; i++) { |
| 305 | ret = rte_timer_reset(&timers[i], delay, SINGLE, main_lcore, |
| 306 | timer_stress2_cb, NULL); |
| 307 | /* there will be collisions when multiple cores simultaneously |
| 308 | * configure the same timers */ |
| 309 | if (ret != 0) |
| 310 | my_collisions++; |
| 311 | } |
| 312 | if (my_collisions != 0) |
| 313 | __atomic_fetch_add(&collisions, my_collisions, __ATOMIC_RELAXED); |
| 314 | |
| 315 | /* wait long enough for timers to expire */ |
| 316 | rte_delay_ms(100); |
| 317 | |
| 318 | /* all cores rendezvous */ |
| 319 | if (lcore_id == main_lcore) { |
| 320 | main_wait_for_workers(); |
| 321 | } else { |
| 322 | worker_finish(); |
| 323 | } |
| 324 | |
| 325 | /* now check that we get the right number of callbacks */ |
| 326 | if (lcore_id == main_lcore) { |
| 327 | my_collisions = __atomic_load_n(&collisions, __ATOMIC_RELAXED); |
| 328 | if (my_collisions != 0) |
nothing calls this directly
no test coverage detected