Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/130553/?format=api
http://patchwork.dpdk.org/api/patches/130553/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230821085806.3062613-4-david.marchand@redhat.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230821085806.3062613-4-david.marchand@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230821085806.3062613-4-david.marchand@redhat.com", "date": "2023-08-21T08:58:06", "name": "[v3,3/3] ethdev: cleanup shared data with the last port", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "1e0065565716cb2a6ade8b98414d43c0d10f5469", "submitter": { "id": 1173, "url": "http://patchwork.dpdk.org/api/people/1173/?format=api", "name": "David Marchand", "email": "david.marchand@redhat.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230821085806.3062613-4-david.marchand@redhat.com/mbox/", "series": [ { "id": 29288, "url": "http://patchwork.dpdk.org/api/series/29288/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29288", "date": "2023-08-21T08:58:03", "name": "Release ethdev shared memory on port cleanup", "version": 3, "mbox": "http://patchwork.dpdk.org/series/29288/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/130553/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/130553/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 2DAD8430BE;\n\tMon, 21 Aug 2023 10:58:44 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id EB40743261;\n\tMon, 21 Aug 2023 10:58:28 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id EBA0143261\n for <dev@dpdk.org>; Mon, 21 Aug 2023 10:58:27 +0200 (CEST)", "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-362-LrVRYFb2PrKvSOGny7tPrw-1; Mon, 21 Aug 2023 04:58:21 -0400", "from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com\n [10.11.54.1])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA66D8DC666;\n Mon, 21 Aug 2023 08:58:20 +0000 (UTC)", "from dmarchan.redhat.com (unknown [10.45.226.19])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 9022D40C206F;\n Mon, 21 Aug 2023 08:58:19 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1692608307;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=BuRoWRx/+JZ/KAykQljd/VKs4dcF3gYcGjEgsRQRK7k=;\n b=WpMdqNqclg7tlNQMc9mLvNVY0UXO+Hy5VwycQGK14jdfCfx5PFsQ2HAymNDOtjAP5UiKzY\n MrTTn060ctmdtYAdDom/g0gFK01VcZR1MXtYIjhTfUFSpK1EFFMqLj7+U1HO5D8CMqYH+T\n oZzFUCHfOee4QWvKeHHFS1bxazZ6OFg=", "X-MC-Unique": "LrVRYFb2PrKvSOGny7tPrw-1", "From": "David Marchand <david.marchand@redhat.com>", "To": "dev@dpdk.org", "Cc": "probb@iol.unh.edu,\n =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>,\n Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@amd.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Anatoly Burakov <anatoly.burakov@intel.com>", "Subject": "[PATCH v3 3/3] ethdev: cleanup shared data with the last port", "Date": "Mon, 21 Aug 2023 10:58:06 +0200", "Message-ID": "<20230821085806.3062613-4-david.marchand@redhat.com>", "In-Reply-To": "<20230821085806.3062613-1-david.marchand@redhat.com>", "References": "<20230818091321.2404089-1-david.marchand@redhat.com>\n <20230821085806.3062613-1-david.marchand@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.1", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "If no port is allocated and no port owner is still registered,\nethdev from a primary process may release the memzone used to store\nport data.\nThis makes it possible for the DPDK memory allocator to release\nassociated resources back to the OS.\n\nSigned-off-by: David Marchand <david.marchand@redhat.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\nChanges since v2:\n- tracked owners count and and avoided releasing shared mem if some\n owner is still registered,\n\n---\n lib/ethdev/ethdev_driver.c | 6 ++++++\n lib/ethdev/ethdev_private.c | 21 ++++++++++++++++++++-\n lib/ethdev/ethdev_private.h | 4 ++++\n lib/ethdev/rte_ethdev.c | 3 +++\n 4 files changed, 33 insertions(+), 1 deletion(-)", "diff": "diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c\nindex f04666f3a2..c30cb33963 100644\n--- a/lib/ethdev/ethdev_driver.c\n+++ b/lib/ethdev/ethdev_driver.c\n@@ -114,6 +114,8 @@ rte_eth_dev_allocate(const char *name)\n \teth_dev->data->backer_port_id = RTE_MAX_ETHPORTS;\n \teth_dev->data->mtu = RTE_ETHER_MTU;\n \tpthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);\n+\tRTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);\n+\teth_dev_shared_data->allocated_ports++;\n \n unlock:\n \trte_spinlock_unlock(rte_mcfg_ethdev_get_lock());\n@@ -264,6 +266,10 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)\n \t\trte_free(eth_dev->data->dev_private);\n \t\tpthread_mutex_destroy(ð_dev->data->flow_ops_mutex);\n \t\tmemset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));\n+\t\teth_dev->data = NULL;\n+\n+\t\teth_dev_shared_data->allocated_ports--;\n+\t\teth_dev_shared_data_release();\n \t}\n \n \trte_spinlock_unlock(rte_mcfg_ethdev_get_lock());\ndiff --git a/lib/ethdev/ethdev_private.c b/lib/ethdev/ethdev_private.c\nindex 911de1e595..aea9112cc2 100644\n--- a/lib/ethdev/ethdev_private.c\n+++ b/lib/ethdev/ethdev_private.c\n@@ -11,6 +11,7 @@\n \n static const char *MZ_RTE_ETH_DEV_DATA = \"rte_eth_dev_data\";\n \n+static const struct rte_memzone *eth_dev_shared_mz;\n struct eth_dev_shared *eth_dev_shared_data;\n \n /* spinlock for eth device callbacks */\n@@ -324,7 +325,7 @@ eth_dev_shared_data_prepare(void)\n \tconst unsigned int flags = 0;\n \tconst struct rte_memzone *mz;\n \n-\tif (eth_dev_shared_data == NULL) {\n+\tif (eth_dev_shared_mz == NULL) {\n \t\tif (rte_eal_process_type() == RTE_PROC_PRIMARY) {\n \t\t\t/* Allocate port data and ownership shared memory. */\n \t\t\tmz = rte_memzone_reserve(MZ_RTE_ETH_DEV_DATA,\n@@ -337,10 +338,13 @@ eth_dev_shared_data_prepare(void)\n \t\t\tgoto out;\n \t\t}\n \n+\t\teth_dev_shared_mz = mz;\n \t\teth_dev_shared_data = mz->addr;\n \t\tif (rte_eal_process_type() == RTE_PROC_PRIMARY) {\n+\t\t\teth_dev_shared_data->allocated_owners = 0;\n \t\t\teth_dev_shared_data->next_owner_id =\n \t\t\t\t\tRTE_ETH_DEV_NO_OWNER + 1;\n+\t\t\teth_dev_shared_data->allocated_ports = 0;\n \t\t\tmemset(eth_dev_shared_data->data, 0,\n \t\t\t sizeof(eth_dev_shared_data->data));\n \t\t}\n@@ -349,6 +353,21 @@ eth_dev_shared_data_prepare(void)\n \treturn eth_dev_shared_data;\n }\n \n+void\n+eth_dev_shared_data_release(void)\n+{\n+\tRTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);\n+\n+\tif (eth_dev_shared_data->allocated_ports != 0)\n+\t\treturn;\n+\tif (eth_dev_shared_data->allocated_owners != 0)\n+\t\treturn;\n+\n+\trte_memzone_free(eth_dev_shared_mz);\n+\teth_dev_shared_mz = NULL;\n+\teth_dev_shared_data = NULL;\n+}\n+\n void\n eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid)\n {\ndiff --git a/lib/ethdev/ethdev_private.h b/lib/ethdev/ethdev_private.h\nindex 1572da7b48..0d36b9c30f 100644\n--- a/lib/ethdev/ethdev_private.h\n+++ b/lib/ethdev/ethdev_private.h\n@@ -14,7 +14,9 @@\n #include \"rte_ethdev.h\"\n \n struct eth_dev_shared {\n+\tuint64_t allocated_owners;\n \tuint64_t next_owner_id;\n+\tuint64_t allocated_ports;\n \tstruct rte_eth_dev_data data[RTE_MAX_ETHPORTS];\n };\n \n@@ -69,6 +71,8 @@ void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo,\n \n void *eth_dev_shared_data_prepare(void)\n \t__rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock());\n+void eth_dev_shared_data_release(void)\n+\t__rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock());\n \n void eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid);\n void eth_dev_txq_release(struct rte_eth_dev *dev, uint16_t qid);\ndiff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c\nindex ea430d8bab..35925a403a 100644\n--- a/lib/ethdev/rte_ethdev.c\n+++ b/lib/ethdev/rte_ethdev.c\n@@ -444,6 +444,7 @@ rte_eth_dev_owner_new(uint64_t *owner_id)\n \n \tif (eth_dev_shared_data_prepare() != NULL) {\n \t\t*owner_id = eth_dev_shared_data->next_owner_id++;\n+\t\teth_dev_shared_data->allocated_owners++;\n \t\tret = 0;\n \t} else {\n \t\tret = -ENOMEM;\n@@ -566,6 +567,8 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)\n \t\tRTE_ETHDEV_LOG(NOTICE,\n \t\t\t\"All port owners owned by %016\"PRIx64\" identifier have removed\\n\",\n \t\t\towner_id);\n+\t\teth_dev_shared_data->allocated_owners--;\n+\t\teth_dev_shared_data_release();\n \t} else {\n \t\tRTE_ETHDEV_LOG(ERR,\n \t\t\t \"Invalid owner ID=%016\"PRIx64\"\\n\",\n", "prefixes": [ "v3", "3/3" ] }{ "id": 130553, "url": "