diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index f514e77fa..ec4dd3f2d 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -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, diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index 5faa3def6..36916f4f5 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -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; } diff --git a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c index c1847bffb..351404a37 100644 --- a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c @@ -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;