get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 130510,
    "url": "http://patchwork.dpdk.org/api/patches/130510/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230818091321.2404089-3-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": "<20230818091321.2404089-3-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230818091321.2404089-3-david.marchand@redhat.com",
    "date": "2023-08-18T09:13:21",
    "name": "[2/2] ethdev: cleanup shared data with the last port",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f73d5f2c6f618acd75e8ab918c69b987be9f8502",
    "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/20230818091321.2404089-3-david.marchand@redhat.com/mbox/",
    "series": [
        {
            "id": 29275,
            "url": "http://patchwork.dpdk.org/api/series/29275/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29275",
            "date": "2023-08-18T09:13:19",
            "name": "Release ethdev shared memory on port cleanup",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29275/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/130510/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/130510/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 6D7D243095;\n\tFri, 18 Aug 2023 11:13:43 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2B4A64324E;\n\tFri, 18 Aug 2023 11:13:42 +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 C40BA43257\n for <dev@dpdk.org>; Fri, 18 Aug 2023 11:13:40 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-605-rRHN8scWOnmYZI_iEpSQQw-1; Fri, 18 Aug 2023 05:13:35 -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 E4A941C07264;\n Fri, 18 Aug 2023 09:13:34 +0000 (UTC)",
            "from dmarchan.redhat.com (unknown [10.45.226.19])\n by smtp.corp.redhat.com (Postfix) with ESMTP id BDF3540C207B;\n Fri, 18 Aug 2023 09:13:33 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1692350020;\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=g3h9SJN3dNdSVeWlOg4mc4F/9ieAp+Wdp3tXFou+qOk=;\n b=XUNYwheOJxbJyQcMqh/gG8SkNotplUhYQlYygL9ePYq/lNE5Z6mQGBrYTj6Itzk+GXEEEI\n y+i0YI7WeAvGyw01vM76g3qlQdko+1lp8wVuQErVKun78/hmR/S4QM6Z+1+PAXRTaXPJjo\n 2z5LiXR8xJo4MB7XdIrP+FfqRKpJFWk=",
        "X-MC-Unique": "rRHN8scWOnmYZI_iEpSQQw-1",
        "From": "David Marchand <david.marchand@redhat.com>",
        "To": "dev@dpdk.org",
        "Cc": "probb@iol.unh.edu, Thomas Monjalon <thomas@monjalon.net>,\n Ferruh Yigit <ferruh.yigit@amd.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Anatoly Burakov <anatoly.burakov@intel.com>",
        "Subject": "[PATCH 2/2] ethdev: cleanup shared data with the last port",
        "Date": "Fri, 18 Aug 2023 11:13:21 +0200",
        "Message-ID": "<20230818091321.2404089-3-david.marchand@redhat.com>",
        "In-Reply-To": "<20230818091321.2404089-1-david.marchand@redhat.com>",
        "References": "<20230818091321.2404089-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-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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, ethdev (from a primary process) can release the\nmemzone used to store port 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>\n---\n lib/ethdev/ethdev_driver.c  |  6 ++++++\n lib/ethdev/ethdev_private.c | 16 +++++++++++++++-\n lib/ethdev/ethdev_private.h |  3 +++\n 3 files changed, 24 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c\nindex 5bb9c3f97c..c650421c3a 100644\n--- a/lib/ethdev/ethdev_driver.c\n+++ b/lib/ethdev/ethdev_driver.c\n@@ -113,6 +113,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_count++;\n \n unlock:\n \trte_spinlock_unlock(rte_mcfg_ethdev_get_lock());\n@@ -253,6 +255,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+\n+\t\teth_dev_shared_data->allocated_count--;\n+\t\tif (eth_dev_shared_data->allocated_count == 0)\n+\t\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 6756625729..6fe2e37c56 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@@ -335,16 +336,29 @@ eth_dev_shared_data_prepare(void)\n \t\tif (mz == NULL)\n \t\t\trte_panic(\"Cannot allocate ethdev shared data\\n\");\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->next_owner_id =\n \t\t\t\t\tRTE_ETH_DEV_NO_OWNER + 1;\n+\t\t\teth_dev_shared_data->allocated_count = 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 \t}\n }\n \n+void\n+eth_dev_shared_data_release(void)\n+{\n+\tRTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);\n+\tif (eth_dev_shared_mz != NULL) {\n+\t\trte_memzone_free(eth_dev_shared_mz);\n+\t\teth_dev_shared_mz = NULL;\n+\t\teth_dev_shared_data = NULL;\n+\t}\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 f7706e6a95..c456ba9a50 100644\n--- a/lib/ethdev/ethdev_private.h\n+++ b/lib/ethdev/ethdev_private.h\n@@ -15,6 +15,7 @@\n \n struct eth_dev_shared {\n \tuint64_t next_owner_id;\n+\tuint64_t allocated_count;\n \tstruct rte_eth_dev_data data[RTE_MAX_ETHPORTS];\n };\n \n@@ -69,6 +70,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);\n",
    "prefixes": [
        "2/2"
    ]
}