get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 69008,
    "url": "https://patches.dpdk.org/api/patches/69008/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200421185320.16946-1-taox.zhu@intel.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": "<20200421185320.16946-1-taox.zhu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200421185320.16946-1-taox.zhu@intel.com",
    "date": "2020-04-21T18:53:20",
    "name": "[v5] net/ixgbe: fix resource leak after thread exits normally",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d550150bcdcd1891b62f5c8468005cbc6663fd86",
    "submitter": {
        "id": 1368,
        "url": "https://patches.dpdk.org/api/people/1368/?format=api",
        "name": "Zhu, TaoX",
        "email": "taox.zhu@intel.com"
    },
    "delegate": {
        "id": 31221,
        "url": "https://patches.dpdk.org/api/users/31221/?format=api",
        "username": "yexl",
        "first_name": "xiaolong",
        "last_name": "ye",
        "email": "xiaolong.ye@intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200421185320.16946-1-taox.zhu@intel.com/mbox/",
    "series": [
        {
            "id": 9541,
            "url": "https://patches.dpdk.org/api/series/9541/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9541",
            "date": "2020-04-21T18:53:20",
            "name": "[v5] net/ixgbe: fix resource leak after thread exits normally",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/9541/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/69008/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/69008/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 57516A0598;\n\tTue, 21 Apr 2020 12:11:51 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2FF631D5C0;\n\tTue, 21 Apr 2020 12:11:51 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by dpdk.org (Postfix) with ESMTP id E50FC1D57C;\n Tue, 21 Apr 2020 12:11:49 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 21 Apr 2020 03:11:48 -0700",
            "from unknown (HELO localhost.localdomain) ([10.240.183.95])\n by orsmga002.jf.intel.com with ESMTP; 21 Apr 2020 03:11:46 -0700"
        ],
        "IronPort-SDR": [
            "\n at/XgoSkqkyh/iGuAVTbZZxkrogKJN4n15ea6GBpheMEqX1RdT+2XWOFI08GEoIQ93Q1AmGd7j\n v9PMgy41fWOQ==",
            "\n zB5Rgt45jSvIrDXsb8NKexJBvzsflykaXC0YJWsNhJS2NKWqyaSh+J888jVqt5+Mj4xYC1E5Rw\n SwJNWLB5ofMg=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.72,410,1580803200\"; d=\"scan'208\";a=\"273475783\"",
        "From": "taox.zhu@intel.com",
        "To": "konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, xiaolong.ye@intel.com",
        "Cc": "dev@dpdk.org, martin.weiser@allegro-packets.com,\n Zhu Tao <taox.zhu@intel.com>, stable@dpdk.org",
        "Date": "Tue, 21 Apr 2020 18:53:20 +0000",
        "Message-Id": "<20200421185320.16946-1-taox.zhu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<1586495895-9610-1-git-send-email-taox.zhu@intel.com>",
        "References": "<1586495895-9610-1-git-send-email-taox.zhu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5] net/ixgbe: fix resource leak after thread\n\texits normally",
        "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>,\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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Zhu Tao <taox.zhu@intel.com>\n\nWhen the thread exits normally, pthread_join() is not called, which can\nresult in a resource leak. Therefore, the thread is set to separation\nmode using function pthread_detach(), so that no program call\npthread_join() is required to recycle, and when the thread exits,\nthe system automatically reclaims resources.\n\nWait for the thread to finish with timeout argument(0 means that it will\nnot return until link complete), wait until the thread finishes before\nreturning. Normally, the thread will finish in a shorter time, and give\na warning message if it hasn't finished in a longer time.\n\nFixes: 819d0d1d57f1 (\"net/ixgbe: fix blocking system events\")\nCc: stable@dpdk.org\n\nSigned-off-by: Zhu Tao <taox.zhu@intel.com>\n---\n drivers/net/ixgbe/ixgbe_ethdev.c | 57 +++++++++++++++++++---------------------\n 1 file changed, 27 insertions(+), 30 deletions(-)\n\nV5 changes:\n\tModify the definition of function ixgbe_dev_wait_setup_link_complete(),\n\t so that the caller can choose whether to block, etc.\n\nv4 changes:\n\tFormat codes.\n\nv3 changes:\n        1. Wait for the thread to finish without setting the timeout, and the\n           corresponding function name has also been modified.\n        2. Commit log.\n\nv2 changes:\n        Commit log.",
    "diff": "diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c\nindex 2c57976..92788ee 100644\n--- a/drivers/net/ixgbe/ixgbe_ethdev.c\n+++ b/drivers/net/ixgbe/ixgbe_ethdev.c\n@@ -230,7 +230,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,\n static void ixgbe_dev_interrupt_handler(void *param);\n static void ixgbe_dev_interrupt_delayed_handler(void *param);\n static void *ixgbe_dev_setup_link_thread_handler(void *param);\n-static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev);\n+static int ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms);\n \n static int ixgbe_add_rar(struct rte_eth_dev *dev,\n \t\t\tstruct rte_ether_addr *mac_addr,\n@@ -2601,7 +2601,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)\n \tPMD_INIT_FUNC_TRACE();\n \n \t/* Stop the link setup handler before resetting the HW. */\n-\tixgbe_dev_cancel_link_thread(dev);\n+\tixgbe_dev_wait_setup_link_complete(dev, 0);\n \n \t/* disable uio/vfio intr/eventfd mapping */\n \trte_intr_disable(intr_handle);\n@@ -2888,7 +2888,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)\n \n \tPMD_INIT_FUNC_TRACE();\n \n-\tixgbe_dev_cancel_link_thread(dev);\n+\tixgbe_dev_wait_setup_link_complete(dev, 0);\n \n \t/* disable interrupts */\n \tixgbe_disable_intr(hw);\n@@ -4143,36 +4143,32 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,\n \treturn ret_val;\n }\n \n-/* return 1: setup complete, return 0: setup not complete, and wait timeout*/\n+/*\n+ * If @timeout_ms was 0, it means that it will not return until link complete.\n+ * It returns 1 on complete, return 0 on timeout.\n+ */\n static int\n-ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev)\n+ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms)\n {\n-#define DELAY_INTERVAL 100 /* 100ms */\n-#define MAX_TIMEOUT    90 /* 9s (90 * 100ms) in total */\n+#define WARNING_TIMEOUT    9000 /* 9s  in total */\n \tstruct ixgbe_adapter *ad = dev->data->dev_private;\n-\tint timeout = MAX_TIMEOUT;\n+\tint timeout = timeout_ms ? WARNING_TIMEOUT : timeout_ms;\n \n-\twhile (rte_atomic32_read(&ad->link_thread_running) && timeout) {\n-\t\tmsec_delay(DELAY_INTERVAL);\n+\twhile (rte_atomic32_read(&ad->link_thread_running)) {\n+\t\tmsec_delay(1);\n \t\ttimeout--;\n-\t}\n-\n-\n-\treturn !!timeout;\n-}\n \n-static void\n-ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev)\n-{\n-\tstruct ixgbe_adapter *ad = dev->data->dev_private;\n-\tvoid *retval;\n-\n-\tif (!ixgbe_dev_wait_setup_link_complete(dev)) {\n-\t\tpthread_cancel(ad->link_thread_tid);\n-\t\tpthread_join(ad->link_thread_tid, &retval);\n-\t\trte_atomic32_clear(&ad->link_thread_running);\n-\t\tPMD_DRV_LOG(ERR, \"Link thread not complete, cancel it!\");\n+\t\tif (timeout_ms) {\n+\t\t\tif (!timeout)\n+\t\t\t\treturn 0;\n+\t\t} else if (!timeout) {\n+\t\t\t/* It will not return until link complete */\n+\t\t\ttimeout = WARNING_TIMEOUT;\n+\t\t\tPMD_DRV_LOG(ERR, \"IXGBE link thread not complete too long time!\");\n+\t\t}\n \t}\n+\n+\treturn 1;\n }\n \n static void *\n@@ -4186,6 +4182,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,\n \tu32 speed;\n \tbool autoneg = false;\n \n+\tpthread_detach(pthread_self());\n \tspeed = hw->phy.autoneg_advertised;\n \tif (!speed)\n \t\tixgbe_get_link_capabilities(hw, &speed, &autoneg);\n@@ -4282,8 +4279,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,\n \tif (link_up == 0) {\n \t\tif (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {\n \t\t\tintr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;\n-\t\t\tif (ixgbe_dev_wait_setup_link_complete(dev) &&\n-\t\t\t    rte_atomic32_test_and_set(&ad->link_thread_running)) {\n+\t\t\tixgbe_dev_wait_setup_link_complete(dev, 0);\n+\t\t\tif (rte_atomic32_test_and_set(&ad->link_thread_running)) {\n \t\t\t\tif (rte_ctrl_thread_create(&ad->link_thread_tid,\n \t\t\t\t\t\"ixgbe-link-handler\",\n \t\t\t\t\tNULL,\n@@ -5323,7 +5320,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,\n \tPMD_INIT_FUNC_TRACE();\n \n \t/* Stop the link setup handler before resetting the HW. */\n-\tixgbe_dev_cancel_link_thread(dev);\n+\tixgbe_dev_wait_setup_link_complete(dev, 0);\n \n \terr = hw->mac.ops.reset_hw(hw);\n \tif (err) {\n@@ -5421,7 +5418,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,\n \n \tPMD_INIT_FUNC_TRACE();\n \n-\tixgbe_dev_cancel_link_thread(dev);\n+\tixgbe_dev_wait_setup_link_complete(dev, 0);\n \n \tixgbevf_intr_disable(dev);\n \n",
    "prefixes": [
        "v5"
    ]
}