get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 68467,
    "url": "https://patches.dpdk.org/api/patches/68467/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200415122715.33368-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": "<20200415122715.33368-1-taox.zhu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200415122715.33368-1-taox.zhu@intel.com",
    "date": "2020-04-15T12:27:15",
    "name": "[v3] net/ixgbe: fix resource leak after thread exits normally",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cea439980839c6733669066bdd5ea465844e4eac",
    "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/20200415122715.33368-1-taox.zhu@intel.com/mbox/",
    "series": [
        {
            "id": 9380,
            "url": "https://patches.dpdk.org/api/series/9380/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9380",
            "date": "2020-04-15T12:27:15",
            "name": "[v3] net/ixgbe: fix resource leak after thread exits normally",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/9380/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/68467/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/68467/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 C208DA0577;\n\tWed, 15 Apr 2020 05:47:33 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 25C111D415;\n\tWed, 15 Apr 2020 05:47:33 +0200 (CEST)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n by dpdk.org (Postfix) with ESMTP id D86381D40F;\n Wed, 15 Apr 2020 05:47:31 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 14 Apr 2020 20:47:30 -0700",
            "from ubuntu.sh.intel.com ([10.240.183.59])\n by orsmga002.jf.intel.com with ESMTP; 14 Apr 2020 20:47:28 -0700"
        ],
        "IronPort-SDR": [
            "\n BHjaZ3X+Bdeojz9HQvBtvOS6odlSF2/RNuWgxzyEpdfjxRu2Hvmv0SRrnuAewozkJEwceVTFUA\n wfx+QhDbUn2Q==",
            "\n KcHwETDW1O9mnuMf2M+9d0OeWwYO6nZqujxHQr2LAN7AaBhpaTS8DZ9YT3xRiaS0jL/H6bl6J8\n N4/vvPNUyQjg=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.72,385,1580803200\"; d=\"scan'208\";a=\"271608884\"",
        "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": "Wed, 15 Apr 2020 08:27:15 -0400",
        "Message-Id": "<20200415122715.33368-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 v3] 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 without setting the timeout, wait until\nthe thread finishes before returning. Normally, the thread will finish\nin a shorter time, and give a warning message if it hasn't finished in\na longer time.\n\nFixes: 819d0d1d57f1 (\"net/ixgbe: fix blocking system events\")\n\nCc: stable@dpdk.org\n\nSigned-off-by: Zhu Tao <taox.zhu@intel.com>\n---\n drivers/net/ixgbe/ixgbe_ethdev.c | 46 +++++++++++++++-------------------------\n 1 file changed, 17 insertions(+), 29 deletions(-)\n\nv3 changes:\n\t1. Wait for the thread to finish without setting the timeout, and the \n\t   corresponding function name has also been modified.\n\t2. Commit log.\t\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..dac20a3 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 void ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev);\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);\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);\n \n \t/* disable interrupts */\n \tixgbe_disable_intr(hw);\n@@ -4143,35 +4143,22 @@ 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-static int\n+static void\n ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev)\n {\n-#define DELAY_INTERVAL 100 /* 100ms */\n-#define MAX_TIMEOUT    90 /* 9s (90 * 100ms) in total */\n+#define DELAY_INTERVAL 10 /* 10ms */\n+#define WARNING_TIMEOUT    900 /* 9s (900 * 10ms) in total */\n \tstruct ixgbe_adapter *ad = dev->data->dev_private;\n-\tint timeout = MAX_TIMEOUT;\n+\tint timeout = WARNING_TIMEOUT;\n \n-\twhile (rte_atomic32_read(&ad->link_thread_running) && timeout) {\n+\twhile (rte_atomic32_read(&ad->link_thread_running)) {\n \t\tmsec_delay(DELAY_INTERVAL);\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) {\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 \n@@ -4186,6 +4173,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 +4270,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+            ixgbe_dev_wait_setup_link_complete(dev);\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 +5311,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);\n \n \terr = hw->mac.ops.reset_hw(hw);\n \tif (err) {\n@@ -5421,7 +5409,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);\n \n \tixgbevf_intr_disable(dev);\n \n",
    "prefixes": [
        "v3"
    ]
}