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 0B8C1A04C9; Sun, 13 Sep 2020 11:16:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F52E1DB9; Sun, 13 Sep 2020 11:16:42 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 0881DFFA for ; Sun, 13 Sep 2020 11:16:39 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 816275C0138; Sun, 13 Sep 2020 05:16:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 05:16:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= 43gN11u7xhHhIfoYROzcT69K+zvvB6iVfohWYHilMDU=; b=iqZR5FjOkgN9bQ4/ uXFxz9lMBD41/QM8J8hm4YlnGGvAWOmGo1qliu6uUvetU/vdYNOtMWFO4H2w+k5+ EfykCbXedDSh5VtmY8HDrcFv1sYLoM56hTEZKw7QxojWugBxnjQ7iONKdO/lh9cZ RzRGjqEIKGbxnEbNG1fx5aamfUhwqMK0n2A7Ht/irl4PdGCOjzYTKjWkM7N1Lsxy syqEKxn14PTa+ET5HZwvyxjlYvOicZaTbE1aHFbfNRSxR7aCNk7NcdSf8wN32XBW OtEjTZqQetYOuqdz30zruSBpr7hBMmR2Nde6ugd6jblcz5QymE52iJJX1xZdhs5p I7JxkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=43gN11u7xhHhIfoYROzcT69K+zvvB6iVfohWYHilM DU=; b=P2ZN3kq75JK2S0B0yRPEZ6xBtbw4SgdX7JSSXA4+R2EFtygKF1dGUOW8q 1v73E5tMZ4YH8D6G5RqOpFVRMDCKdb/LxEbSfzNJwwj3xIBk0dBXOkf43vIXzNVk vLZP5BpS9YV2+R2vUihLgUXWhQZWJWboYOPSYbtvj77Xw4xMTESBXCiETQ+udiZG uMt/43Py/vHyvaDIusf7eo17RP9BSO6q2jYV//kwhOzOMcqIHlQ9dOAPpAXpLoCT 4T7ezsPWs6Ky7nW03vzwKiafVNUYfKyS9NotqPcu223JbYEam2xxHawPaWNCp3Yx W9VyveVghxTw7hWTRj9ACcntXmkvg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeifedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 4E20D328005A; Sun, 13 Sep 2020 05:16:37 -0400 (EDT) From: Thomas Monjalon To: Yunjian Wang Cc: dev@dpdk.org, ferruh.yigit@intel.com, jerry.lilijun@huawei.com, xudingke@huawei.com, keith.wiles@intel.com Date: Sun, 13 Sep 2020 11:16:36 +0200 Message-ID: <2500283.dqYlU2TMh5@thomas> In-Reply-To: <9a94f272bc7c1e5650295ddf3e02fb19b15e7951.1598596042.git.wangyunjian@huawei.com> References: <9a94f272bc7c1e5650295ddf3e02fb19b15e7951.1598596042.git.wangyunjian@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, 28/08/2020 14:37, wangyunjian: > @@ -1078,6 +1085,23 @@ tap_dev_close(struct rte_eth_dev *dev) > + > + /* mac_addrs must not be freed alone because part of dev_private */ > + dev->data->mac_addrs = NULL; > + > + internals = dev->data->dev_private; > + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", > + tuntap_types[internals->type], rte_socket_id()); > + > + if (internals->ioctl_sock != -1) { > + close(internals->ioctl_sock); > + internals->ioctl_sock = -1; > + } > + rte_free(dev->process_private); > + dev->process_private = NULL; > + if (tap_devices_count == 1) > + rte_mp_action_unregister(TAP_MP_KEY); > + tap_devices_count--; > } [...] > @@ -2446,12 +2466,11 @@ static int > rte_pmd_tap_remove(struct rte_vdev_device *dev) > { > > struct rte_eth_dev *eth_dev = NULL; > > - struct pmd_internals *internals; > > /* find the ethdev entry */ > eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); > if (!eth_dev) > > - return -ENODEV; > + return 0; > > /* mac_addrs must not be freed alone because part of dev_private */ > eth_dev->data->mac_addrs = NULL; The line above can be removed because mac_addrs is not freed in secondary process, and it is redundant with tap_dev_close(). > > if (rte_eal_process_type() != RTE_PROC_PRIMARY) > return rte_eth_dev_release_port(eth_dev); There is an inconsistency in secondary process if tap_dev_close() is not called from .remove (unplug) but can be called from .dev_close (rte_eth_dev_close). I think the process type check must be done inside tap_dev_close(), so the process private resources can be freed. > > tap_dev_close(eth_dev); > This blank line can be removed in my opinion. > - internals = eth_dev->data->dev_private; > - TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", > - tuntap_types[internals->type], rte_socket_id()); > - > - close(internals->ioctl_sock); > - rte_free(eth_dev->process_private); > - if (tap_devices_count == 1) > - rte_mp_action_unregister(TAP_MP_KEY); > - tap_devices_count--; > rte_eth_dev_release_port(eth_dev); > > return 0;