env: export spdk_env_get_last_core function.

Also use this function in iscsi/conn.c

Change-Id: I25f6da175eddb12c4ac2624d695c2c43c871d8e8
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/392713
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ziye Yang 2017-12-22 08:21:35 +08:00 committed by Jim Harris
parent 08a7e4f4f8
commit 1b7ce80530
3 changed files with 26 additions and 5 deletions

View File

@ -227,6 +227,12 @@ uint32_t spdk_env_get_current_core(void);
*/
uint32_t spdk_env_get_first_core(void);
/**
* \brief Return the index of the last dedicated CPU core for
* this application.
*/
uint32_t spdk_env_get_last_core(void);
/**
* \brief Return the index of the next dedicated CPU core for
* this application.

View File

@ -54,6 +54,24 @@ spdk_env_get_first_core(void)
return rte_get_next_lcore(-1, 0, 0);
}
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;
}
SPDK_ENV_FOREACH_CORE(i) {
last_core = i;
}
return last_core;
}
uint32_t
spdk_env_get_next_core(uint32_t prev_core)
{

View File

@ -349,7 +349,7 @@ int spdk_initialize_iscsi_conns(void)
{
size_t conns_size;
int conns_array_fd, rc;
uint32_t i, last_core = 0;
uint32_t i, last_core;
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_init\n");
@ -383,10 +383,7 @@ int spdk_initialize_iscsi_conns(void)
g_conns_array[i].id = i;
}
SPDK_ENV_FOREACH_CORE(i) {
last_core = i;
}
last_core = spdk_env_get_last_core();
g_num_connections = calloc(last_core + 1, sizeof(uint32_t));
if (!g_num_connections) {
SPDK_ERRLOG("Could not allocate array size=%u for g_num_connections\n",