Skip to content

Commit

Permalink
service: fix core mapping reset
Browse files Browse the repository at this point in the history
[ upstream commit 048db4b ]

The rte_service_lcore_reset_all function stops execution of services
on all lcores and switches them back from ROLE_SERVICE to ROLE_RTE.
However the thread loop for slave lcores (eal_thread_loop) distincts these
roles to set lcore state after processing delegated function.
It sets WAIT state for ROLE_SERVICE, but FINISHED for ROLE_RTE.
So changing the role to RTE before stopping work in slave lcores
causes lcores to end in FINISHED state. That is why the rte_eal_lcore_wait
must be run after rte_service_lcore_reset_all to bring back lcores to
launchable (WAIT) state.
This has been fixed in test app and clarified in API documentation.

Setting the state to WAIT in rte_service_runner_func is premature
as the rte_service_runner_func function is still a part of the lcore
function delegated to slave lcore. The state is overwritten anyway in
slave lcore thread loop. This premature setting state to WAIT might
however cause rte_eal_lcore_wait, that was called by the application,
to return before slave lcore thread set the FINISHED state. That's
why it is removed from librte_eal rte_service_runner_func function.

Bugzilla ID: 464
Fixes: 2169835 ("service: introduce service cores concept")
Fixes: f038a81 ("service: add unit tests")

Reported-by: Sarosh Arif <sarosh.arif@emumba.com>
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
  • Loading branch information
lukaszwojciechowski authored and kevintraynor committed Aug 20, 2020
1 parent fc14e17 commit 369c282
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/librte_eal/common/include/rte_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ int32_t rte_service_lcore_count(void);
* from duty, just unmaps all services / cores, and stops() the service cores.
* The runstate of services is not modified.
*
* The cores that are stopped with this call, are in FINISHED state and
* the application must take care of bringing them back to a launchable state:
* e.g. call *rte_eal_lcore_wait* on the lcore_id.
*
* @retval 0 Success
*/
int32_t rte_service_lcore_reset_all(void);
Expand Down
2 changes: 0 additions & 2 deletions lib/librte_eal/common/rte_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ service_runner_func(void *arg)
rte_smp_rmb();
}

lcore_config[lcore].state = WAIT;

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions test/test/test_service_cores.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ unregister_all(void)
}

rte_service_lcore_reset_all();
rte_eal_mp_wait_lcore();

return TEST_SUCCESS;
}
Expand Down

0 comments on commit 369c282

Please sign in to comment.