Commit 8e68dfd9 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Tomasz Zawadzki
Browse files

rte_vhost: unaffinitize the thread inside rte_vhost API function



We used to call rte_vhost_driver_start() under
spdk_call_unaffinitized() because that function could
spawn a new pthread and we didn't want to to be pinned
to the one single cpu of the current SPDK reactor.

New DPDK versions (>= 19.05) already unaffinitize the
pthread by themselves, so our spdk_call_unaffinitized()
was only required for the legacy, internal rte_vhost fork
in SPDK. To clean up SPDK code, move the un-affinitization
down to the rte_vhost fork.

Change-Id: I53836517e9ec2ff366b509f00e1403845e3c3172
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466746


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 6bf57c7f
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -809,8 +809,23 @@ rte_vhost_driver_start(const char *path)
		return -1;

	if (fdset_tid == 0) {
		int ret = pthread_create(&fdset_tid, NULL, fdset_event_dispatch,
		rte_cpuset_t orig_cpuset;
		rte_cpuset_t tmp_cpuset;
		long num_cores, i;
		int ret;

		CPU_ZERO(&tmp_cpuset);
		num_cores = sysconf(_SC_NPROCESSORS_CONF);
		/* Create a mask containing all CPUs */
		for (i = 0; i < num_cores; i++) {
			CPU_SET(i, &tmp_cpuset);
		}

		rte_thread_get_affinity(&orig_cpuset);
		rte_thread_set_affinity(&tmp_cpuset);
		ret = pthread_create(&fdset_tid, NULL, fdset_event_dispatch,
				     &vhost_user.fdset);
		rte_thread_set_affinity(&orig_cpuset);
		if (ret < 0)
			RTE_LOG(ERR, VHOST_CONFIG,
				"failed to create fdset handling thread");
+1 −18
Original line number Diff line number Diff line
@@ -670,18 +670,6 @@ vhost_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask)
	return 0;
}

static void *
_start_rte_driver(void *arg)
{
	char *path = arg;

	if (rte_vhost_driver_start(path) != 0) {
		return NULL;
	}

	return path;
}

int
vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str,
		   const struct spdk_vhost_dev_backend *backend)
@@ -783,12 +771,7 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma

	vhost_dev_install_rte_compat_hooks(vdev);

	/* The following might start a POSIX thread that polls for incoming
	 * socket connections and calls backend->start/stop_device. These backend
	 * callbacks are also protected by the global SPDK vhost mutex, so we're
	 * safe with not initializing the vdev just yet.
	 */
	if (spdk_call_unaffinitized(_start_rte_driver, path) == NULL) {
	if (rte_vhost_driver_start(path) != 0) {
		SPDK_ERRLOG("Failed to start vhost driver for controller %s (%d): %s\n",
			    name, errno, spdk_strerror(errno));
		rte_vhost_driver_unregister(path);