From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 546FDA04B5;
	Wed, 16 Sep 2020 17:48:30 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 351B71C2FA;
	Wed, 16 Sep 2020 17:48:30 +0200 (CEST)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by dpdk.org (Postfix) with ESMTP id 84D2B1C2ED
 for <dev@dpdk.org>; Wed, 16 Sep 2020 17:48:28 +0200 (CEST)
IronPort-SDR: jSP6ultCvMkiZIt/jYzs5CFrvATh8FYCJJbuakzwzoqjGrieYYE2fmR5SxFkeH8FA+M+e8qFwX
 W8eVkiIXEb/A==
X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="159547007"
X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="159547007"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga005.jf.intel.com ([10.7.209.41])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 16 Sep 2020 08:48:26 -0700
IronPort-SDR: Xr5bQFhi+ilFqcrhp61qNwGw29JCfaBmC1mvGi4Gd19WECThYQhgaXeYJCTt6XuHjjr+wAxvA0
 V6D5gZGaQdNg==
X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="483358127"
Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.248.202])
 ([10.213.248.202])
 by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 16 Sep 2020 08:48:25 -0700
To: wangyunjian <wangyunjian@huawei.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "thomas@monjalon.net" <thomas@monjalon.net>,
 "Lilijun (Jerry)" <jerry.lilijun@huawei.com>, xudingke <xudingke@huawei.com>
References: <9a94f272bc7c1e5650295ddf3e02fb19b15e7951.1598596042.git.wangyunjian@huawei.com>
 <daa3327b-1559-c80c-dee4-d6833928af1c@intel.com>
 <34EFBCA9F01B0748BEB6B629CE643AE60DA4D4A1@DGGEMM533-MBX.china.huawei.com>
From: Ferruh Yigit <ferruh.yigit@intel.com>
Message-ID: <5b26d986-ffc3-9bac-ed4d-cbc1f0dd342b@intel.com>
Date: Wed, 16 Sep 2020 16:48:19 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.2.2
MIME-Version: 1.0
In-Reply-To: <34EFBCA9F01B0748BEB6B629CE643AE60DA4D4A1@DGGEMM533-MBX.china.huawei.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Subject: Re: [dpdk-dev] [PATCH] net/tap: release port upon close
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On 9/16/2020 8:20 AM, wangyunjian wrote:
>> -----Original Message-----
>> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
>> Sent: Tuesday, September 15, 2020 10:53 PM
>> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
>> Cc: thomas@monjalon.net; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
>> <xudingke@huawei.com>
>> Subject: Re: [dpdk-dev] [PATCH] net/tap: release port upon close
>>
>> On 8/28/2020 1:37 PM, wangyunjian wrote:
>>> From: Yunjian Wang <wangyunjian@huawei.com>
>>>
>>> Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private resources
>>> for the port can be freed by rte_eth_dev_close().
>>>
>>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>>
>> <...>
>>
>>> @@ -1040,6 +1044,9 @@ tap_dev_close(struct rte_eth_dev *dev)
>>>   	struct pmd_process_private *process_private = dev->process_private;
>>>   	struct rx_queue *rxq;
>>>
>>> +	if (process_private == NULL)
>>> +		return;
>>
>> Why this check is required?
> 
> When user first call 'close()' and later call 'remove()' the tap PMD, in this case,
> the tap_dev_close() will be called twice. The second call of tap_dev_close()
> shouldn't do any process, we can use this check to return immediately.
> 


When first call is 'close()', it memset the 'eth_dev->data', so the in 
the later 'remove()' call, 'rte_eth_dev_allocated()' will always return 
NULL and 'remove()' will exit without calling 'close()'.

Also multiple 'close()' calls look safe, because of 
'RTE_ETH_VALID_PORTID_OR_RET()' checks is 'rte_eth_dev_close()'.

So, as far as I can see this additional check is not needed, but please 
double check.