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: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466746 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
6bf57c7fd1
commit
8e68dfd99f
@ -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");
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user