MCPcopy Create free account
hub / github.com/F-Stack/f-stack / timer_stress2_main_loop

Function timer_stress2_main_loop

dpdk/app/test/test_timer.c:271–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269#define NB_STRESS2_TIMERS 8192
270
271static int
272timer_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)

Callers

nothing calls this directly

Calls 14

rte_lcore_idFunction · 0.85
rte_get_main_lcoreFunction · 0.85
rte_mallocFunction · 0.85
main_start_workersFunction · 0.85
rte_timer_initFunction · 0.85
worker_wait_to_startFunction · 0.85
rte_timer_resetFunction · 0.85
rte_delay_msFunction · 0.85
main_wait_for_workersFunction · 0.85
worker_finishFunction · 0.85
rte_timer_manageFunction · 0.85
rte_timer_stopFunction · 0.85

Tested by

no test coverage detected