lib/bdev: Use not SPDK thread count but core count for mempool cache size

Cache size of mempool is not based on SPDK thread but DPDK thread,
i.e. CPU core. So replace spdk_thread_get_count() by
spdk_env_get_core_count() to determine cache size of mempool in
spdk_bdev_initialize().

Besides, allocate and free stub cores at the corresponding unit tests.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Icc4deae84c74820af4de61e991fa3f8683add058
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2767
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-06-04 13:38:38 +09:00 committed by Tomasz Zawadzki
parent 433223865e
commit 972b3ae3aa
3 changed files with 8 additions and 3 deletions

View File

@ -1168,10 +1168,10 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg)
/**
* Ensure no more than half of the total buffers end up local caches, by
* using spdk_thread_get_count() to determine how many local caches we need
* using spdk_env_get_core_count() to determine how many local caches we need
* to account for.
*/
cache_size = BUF_SMALL_POOL_SIZE / (2 * spdk_thread_get_count());
cache_size = BUF_SMALL_POOL_SIZE / (2 * spdk_env_get_core_count());
snprintf(mempool_name, sizeof(mempool_name), "buf_small_pool_%d", getpid());
g_bdev_mgr.buf_small_pool = spdk_mempool_create(mempool_name,
@ -1186,7 +1186,7 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg)
return;
}
cache_size = BUF_LARGE_POOL_SIZE / (2 * spdk_thread_get_count());
cache_size = BUF_LARGE_POOL_SIZE / (2 * spdk_env_get_core_count());
snprintf(mempool_name, sizeof(mempool_name), "buf_large_pool_%d", getpid());
g_bdev_mgr.buf_large_pool = spdk_mempool_create(mempool_name,

View File

@ -3401,6 +3401,7 @@ main(int argc, char **argv)
CU_ADD_TEST(suite, lock_lba_range_overlapped);
CU_ADD_TEST(suite, bdev_io_abort);
allocate_cores(1);
allocate_threads(1);
set_thread(0);
@ -3410,6 +3411,7 @@ main(int argc, char **argv)
CU_cleanup_registry();
free_threads();
free_cores();
return num_failures;
}

View File

@ -281,6 +281,7 @@ setup_test(void)
{
bool done = false;
allocate_cores(BDEV_UT_NUM_THREADS);
allocate_threads(BDEV_UT_NUM_THREADS);
set_thread(0);
spdk_bdev_initialize(bdev_init_cb, &done);
@ -311,6 +312,7 @@ teardown_test(void)
CU_ASSERT(g_teardown_done == true);
g_teardown_done = false;
free_threads();
free_cores();
}
static uint32_t
@ -1785,6 +1787,7 @@ bdev_set_io_timeout_mt(void)
CU_ASSERT(g_teardown_done == true);
g_teardown_done = false;
free_threads();
free_cores();
}
static bool g_io_done2;