From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 26B3A2C8 for ; Fri, 7 Jul 2017 09:31:31 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1B3285547; Fri, 7 Jul 2017 07:31:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E1B3285547 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=maxime.coquelin@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E1B3285547 Received: from [10.36.112.14] (unknown [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A09B702C5; Fri, 7 Jul 2017 07:31:25 +0000 (UTC) To: Jens Freimann Cc: dev@dpdk.org, Yuanhan Liu , mst@redhat.com, vkaplans@redhat.com, jasowang@redhat.com References: <20170704094922.11405-1-maxime.coquelin@redhat.com> <20170704094922.11405-2-maxime.coquelin@redhat.com> <20170705100758.2zmfgnek4wkqbio5@dhcp-192-218.str.redhat.com> From: Maxime Coquelin Message-ID: <4f81404a-f4f9-add5-c62f-03224bd32c4a@redhat.com> Date: Fri, 7 Jul 2017 09:31:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170705100758.2zmfgnek4wkqbio5@dhcp-192-218.str.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 07 Jul 2017 07:31:31 +0000 (UTC) Subject: Re: [dpdk-dev] [RFC 01/19] vhost: protect virtio_net device struct 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: , X-List-Received-Date: Fri, 07 Jul 2017 07:31:32 -0000 On 07/05/2017 12:07 PM, Jens Freimann wrote: > 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? Of course we should. This will be fixed in next release. Thanks, Maxime