From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34920A0A0E; Wed, 3 Feb 2021 18:21:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FFFB24069F; Wed, 3 Feb 2021 18:21:43 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 01D87240688 for ; Wed, 3 Feb 2021 18:21:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612372901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uI/ErotX5yAlP82fNp86c4WTUsI6aJHz9PEJPczR/qc=; b=M75R1td0najGyqp3yqr55CQA/40c++JnFZumMR55ikZmr0jWkXh4AsP22YbwxggTlon44s cN9Uox+xqcvccPXb+zNi5mHpqZcACacgeNVjWK4WM+yTsgcwgR9NoQlsm2OlPx1qDjiWfw dptewHfmXI9QrE2p5FnqlNGFbFzLTpc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-U5VwQqByNYmLxs1OUhxXNw-1; Wed, 03 Feb 2021 12:21:38 -0500 X-MC-Unique: U5VwQqByNYmLxs1OUhxXNw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32F33100F347; Wed, 3 Feb 2021 17:21:37 +0000 (UTC) Received: from [10.36.110.4] (unknown [10.36.110.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4022850DE3; Wed, 3 Feb 2021 17:21:35 +0000 (UTC) To: Peng He , dev@dpdk.org, chenbo.xia@intel.com Cc: stable@dpdk.org References: <20210201084844.2434-1-hepeng.0320@bytedance.com> From: Maxime Coquelin Message-ID: <879b35dd-d571-cc15-3b1a-087c6b2539a1@redhat.com> Date: Wed, 3 Feb 2021 18:21:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210201084844.2434-1-hepeng.0320@bytedance.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] vhost: fix vid allocation race X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 2/1/21 9:48 AM, Peng He wrote: > vhost_new_device might be called in different threads at the same time. > thread 1(config thread) > rte_vhost_driver_start > ->vhost_user_start_client > ->vhost_user_add_connection > -> vhost_new_device > > thread 2(vhost-events) > vhost_user_read_cb > ->vhost_user_msg_handler (return value < 0) > -> vhost_user_start_client > -> vhost_new_device > > So there could be a case that a same vid has been allocated twice, or > some vid might be lost in DPDK lib however still held by the upper > applications. > > Another place where race would happen is at the func *vhost_destroy_device*, > but after a detailed investigation, the race does not exist as long as > no two devices have the same vid: Calling vhost_destroy_devices in > different threads with different vids is actually safe. > > Fixes: a277c715987 ("vhost: refactor code structure") > Reported-by: Peng He > Signed-off-by: Fei Chen > Reviewed-by: Zhihong Wang > --- > lib/librte_vhost/vhost.c | 6 ++++++ > 1 file changed, 6 insertions(+) Applied to dpdk-next-virtio/main. Thanks, Maxime