Commit 972b3ae3 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Icc4deae84c74820af4de61e991fa3f8683add058
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2767


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 43322386
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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,
+2 −0
Original line number Diff line number Diff line
@@ -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;
}
+3 −0
Original line number Diff line number Diff line
@@ -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;