From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Freimann Subject: Re: [RFC 01/19] vhost: protect virtio_net device struct Date: Wed, 5 Jul 2017 12:07:58 +0200 Message-ID: <20170705100758.2zmfgnek4wkqbio5@dhcp-192-218.str.redhat.com> References: <20170704094922.11405-1-maxime.coquelin@redhat.com> <20170704094922.11405-2-maxime.coquelin@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Cc: dev@dpdk.org, Yuanhan Liu , mst@redhat.com, vkaplans@redhat.com, jasowang@redhat.com To: Maxime Coquelin Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 8F3892B96 for ; Wed, 5 Jul 2017 12:08:07 +0200 (CEST) Content-Disposition: inline In-Reply-To: <20170704094922.11405-2-maxime.coquelin@redhat.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Jul 04, 2017 at 11:49:04AM +0200, Maxime Coquelin wrote: >virtio_net device might be accessed while being reallocated >in case of NUMA awareness. This case might be theoretical, >but it will be needed anyway to protect vrings pages against >invalidation. > >The virtio_net devs are now protected with a readers/writers >lock, so that before reallocating the device, it is ensured >that it is not being referenced by the processing threads. > >Signed-off-by: Maxime Coquelin >--- > lib/librte_vhost/vhost.c | 223 +++++++++++++++++++++++++++++++++++------- > lib/librte_vhost/vhost.h | 3 +- > lib/librte_vhost/vhost_user.c | 73 +++++--------- > lib/librte_vhost/virtio_net.c | 17 +++- > 4 files changed, 228 insertions(+), 88 deletions(-) [...] >+int >+realloc_device(int vid, int vq_index, int node) >+{ >+ struct virtio_net *dev, *old_dev; >+ struct vhost_virtqueue *vq; >+ >+ dev = rte_malloc_socket(NULL, sizeof(*dev), 0, node); >+ if (!dev) >+ return -1; >+ >+ vq = rte_malloc_socket(NULL, sizeof(*vq), 0, node); >+ if (!vq) >+ return -1; >+ >+ old_dev = get_device_wr(vid); >+ if (!old_dev) >+ return -1; Should we free vq and dev here? regards, Jens