Commit 475fadf3 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

examples/accel_perf: don't allocate channel just to get engine caps



Getting/putting the channel races with getting real IO channels
causing issues with an upcoming design. Avoid it entirely by using
the first worker channel to get the capabilties.

Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I750a8d59e294f4cda9f71f3327afc03e15342768
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8170


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent f31ad9b6
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ static enum accel_capability g_workload_selection;
static struct worker_thread *g_workers = NULL;
static int g_num_workers = 0;
static pthread_mutex_t g_workers_lock = PTHREAD_MUTEX_INITIALIZER;
uint64_t g_capabilites;

struct worker_thread;
static void accel_done(void *ref, int status);
@@ -731,6 +730,7 @@ _init_thread(void *arg1)
	struct accel_batch *tmp;
	struct accel_batch *worker_batch = NULL;
	struct display_info *display = arg1;
	uint64_t capabilities;

	worker = calloc(1, sizeof(*worker));
	if (worker == NULL) {
@@ -751,6 +751,15 @@ _init_thread(void *arg1)
	pthread_mutex_unlock(&g_workers_lock);
	worker->ch = spdk_accel_engine_get_io_channel();

	if (g_num_workers == 1) {
		capabilities = spdk_accel_get_capabilities(worker->ch);
		if ((capabilities & g_workload_selection) != g_workload_selection) {
			g_using_sw_engine = true;
			SPDK_WARNLOG("The selected workload is not natively supported by the current engine\n");
			SPDK_WARNLOG("The software engine will be used instead.\n\n");
		}
	}

	TAILQ_INIT(&worker->tasks_pool);

	if (g_ops_per_batch > 0) {
@@ -905,7 +914,6 @@ accel_done(void *cb_arg, int status)
static void
accel_perf_start(void *arg1)
{
	struct spdk_io_channel *accel_ch;
	struct spdk_cpuset tmp_cpumask = {};
	char thread_name[32];
	uint32_t i;
@@ -913,16 +921,6 @@ accel_perf_start(void *arg1)
	struct spdk_thread *thread;
	struct display_info *display;

	accel_ch = spdk_accel_engine_get_io_channel();
	g_capabilites = spdk_accel_get_capabilities(accel_ch);
	spdk_put_io_channel(accel_ch);

	if ((g_capabilites & g_workload_selection) != g_workload_selection) {
		g_using_sw_engine = true;
		SPDK_WARNLOG("The selected workload is not natively supported by the current engine\n");
		SPDK_WARNLOG("The software engine will be used instead.\n\n");
	}

	g_tsc_rate = spdk_get_ticks_hz();
	g_tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;