From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 319B2A046B for ; Mon, 19 Aug 2019 13:37:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6B0AA1BE9A; Mon, 19 Aug 2019 13:37:29 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 39CB91B96B; Mon, 19 Aug 2019 13:37:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Aug 2019 04:37:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,403,1559545200"; d="scan'208";a="177856866" Received: from dpdk-virtio-tbie-2.sh.intel.com ([10.67.104.71]) by fmsmga008.fm.intel.com with ESMTP; 19 Aug 2019 04:37:24 -0700 From: Tiwei Bie To: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com Cc: lvyilong.lyl@alibaba-inc.com, yinan.wang@intel.com, xnhp0320@icloud.com, stable@dpdk.org Date: Mon, 19 Aug 2019 19:34:55 +0800 Message-Id: <20190819113457.15569-2-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819113457.15569-1-tiwei.bie@intel.com> References: <20190819113457.15569-1-tiwei.bie@intel.com> Subject: [dpdk-dev] [PATCH 1/3] vhost: do not realloc device and queues during running X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When the device has been started, don't do the reallocation anymore. Otherwise the pointers used in application threads can be invalidated without proper protection. Instead of introducing a global lock to protect the change of device pointers which will hurt the performance, let's just do the reallocation during setup. Fixes: af295ad4698c ("vhost: realloc device and queues to same numa node as vring desc") Cc: stable@dpdk.org Reported-by: Yinan Wang Signed-off-by: Tiwei Bie --- lib/librte_vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 0b72648a5..ea43ab139 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -410,6 +410,9 @@ numa_realloc(struct virtio_net *dev, int index) struct batch_copy_elem *new_batch_copy_elems; int ret; + if (dev->flags & VIRTIO_DEV_RUNNING) + return dev; + old_dev = dev; vq = old_vq = dev->virtqueue[index]; -- 2.17.1