env: make spdk_env_get_last_core() thread safe
Previously, the maximum core value was cached in a static variable, but this isn't safe if multiple threads are calling at the same time. Iterating over all core numbers is not very expensive, so just recalculate the value for every call. Change-Id: I4fab072f4a96ecc8801e1db293b3921a6f1534f9 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/399930 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
ff3d53f74e
commit
2b8c23c7b8
@ -58,12 +58,7 @@ uint32_t
|
||||
spdk_env_get_last_core(void)
|
||||
{
|
||||
uint32_t i;
|
||||
static uint32_t last_core = UINT32_MAX;
|
||||
|
||||
/* Already know the last_core, just return */
|
||||
if (last_core != UINT32_MAX) {
|
||||
return last_core;
|
||||
}
|
||||
uint32_t last_core = UINT32_MAX;
|
||||
|
||||
SPDK_ENV_FOREACH_CORE(i) {
|
||||
last_core = i;
|
||||
|
Loading…
Reference in New Issue
Block a user