get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/132002/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 132002,
    "url": "https://patches.dpdk.org/api/patches/132002/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230927114515.1245213-4-david.marchand@redhat.com/",
    "project": {
        "id": 1,
        "url": "https://patches.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": "<20230927114515.1245213-4-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230927114515.1245213-4-david.marchand@redhat.com",
    "date": "2023-09-27T11:45:15",
    "name": "[v4,3/3] ethdev: cleanup shared data with the last port",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "1e0065565716cb2a6ade8b98414d43c0d10f5469",
    "submitter": {
        "id": 1173,
        "url": "https://patches.dpdk.org/api/people/1173/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@redhat.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230927114515.1245213-4-david.marchand@redhat.com/mbox/",
    "series": [
        {
            "id": 29654,
            "url": "https://patches.dpdk.org/api/series/29654/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=29654",
            "date": "2023-09-27T11:45:12",
            "name": "Release ethdev shared memory on port cleanup",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/29654/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/132002/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/132002/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 9D69542651;\n\tWed, 27 Sep 2023 13:45:43 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E5C1240A77;\n\tWed, 27 Sep 2023 13:45:33 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id C69A6402D3\n for <dev@dpdk.org>; Wed, 27 Sep 2023 13:45:32 +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-219-dCDp7TGNM4-0VPOZO8zC0w-1; Wed, 27 Sep 2023 07:45:29 -0400",
            "from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com\n [10.11.54.10])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7062B8032F6;\n Wed, 27 Sep 2023 11:45:28 +0000 (UTC)",
            "from dmarchan.redhat.com (unknown [10.45.224.48])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 186B8492C37;\n Wed, 27 Sep 2023 11:45:26 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1695815132;\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=7FFBDXEwdl2KJTlmVks+gN6W2Btkmts3wnu5w1aBpPM=;\n b=U3e7cGRNcSJSAgH6HO0kvs8iFGeoKnONOzzD6/awRLWZcdnmuPOQ3VKZnWslTT769zQQLo\n R/echb7RAjSF/qH0mI7a8WDMBoT/2cLkvLIw/K8k9RHfHK3IAt/YyYj4ZtmZaXMC6aazJg\n Esyt1iKP2xnlEPtuehc7BvZMcshkY6w=",
        "X-MC-Unique": "dCDp7TGNM4-0VPOZO8zC0w-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 v4 3/3] ethdev: cleanup shared data with the last port",
        "Date": "Wed, 27 Sep 2023 13:45:15 +0200",
        "Message-ID": "<20230927114515.1245213-4-david.marchand@redhat.com>",
        "In-Reply-To": "<20230927114515.1245213-1-david.marchand@redhat.com>",
        "References": "<20230818091321.2404089-1-david.marchand@redhat.com>\n <20230927114515.1245213-1-david.marchand@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.10",
        "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 b339e325a0..fff4b7b4cd 100644\n--- a/lib/ethdev/ethdev_driver.c\n+++ b/lib/ethdev/ethdev_driver.c\n@@ -115,6 +115,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(&eth_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@@ -265,6 +267,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(&eth_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 5c9495ecfe..61572d0cd1 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": [
        "v4",
        "3/3"
    ]
}