get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49237,
    "url": "http://patches.dpdk.org/api/patches/49237/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/517a31eda38a8334a9a9dbc941f0e2bcc067073c.1545395127.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<517a31eda38a8334a9a9dbc941f0e2bcc067073c.1545395127.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/517a31eda38a8334a9a9dbc941f0e2bcc067073c.1545395127.git.anatoly.burakov@intel.com",
    "date": "2018-12-21T12:26:05",
    "name": "[19.02,v2] malloc: fix deadlock when using malloc stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "4e337a264732ff61969334a1431a88189e813d86",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/517a31eda38a8334a9a9dbc941f0e2bcc067073c.1545395127.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 2923,
            "url": "http://patches.dpdk.org/api/series/2923/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2923",
            "date": "2018-12-21T12:26:05",
            "name": "[19.02,v2] malloc: fix deadlock when using malloc stats",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/2923/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/49237/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/49237/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id ADF5A1BE1D;\n\tFri, 21 Dec 2018 13:26:09 +0100 (CET)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 50C7B1BE19;\n\tFri, 21 Dec 2018 13:26:08 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Dec 2018 04:26:07 -0800",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 21 Dec 2018 04:26:06 -0800",
            "from sivswdev05.ir.intel.com (sivswdev05.ir.intel.com\n\t[10.243.17.64])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\twBLCQ5Ko007711; Fri, 21 Dec 2018 12:26:05 GMT",
            "from sivswdev05.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev05.ir.intel.com with ESMTP id wBLCQ5wN015972;\n\tFri, 21 Dec 2018 12:26:05 GMT",
            "(from aburakov@localhost)\n\tby sivswdev05.ir.intel.com with LOCAL id wBLCQ5rw015968;\n\tFri, 21 Dec 2018 12:26:05 GMT"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,381,1539673200\"; d=\"scan'208\";a=\"304069006\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "John McNamara <john.mcnamara@intel.com>,\n\tMarko Kovacevic <marko.kovacevic@intel.com>, thomas@monjalon.net,\n\tstable@dpdk.org",
        "Date": "Fri, 21 Dec 2018 12:26:05 +0000",
        "Message-Id": "<517a31eda38a8334a9a9dbc941f0e2bcc067073c.1545395127.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com>",
        "References": "<884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 19.02 v2] malloc: fix deadlock when using malloc\n\tstats",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Currently, malloc statistics and external heap creation code\nuse memory hotplug lock as a way to synchronize accesses to\nheaps (as in, locking the hotplug lock to prevent list of heaps\nfrom changing under our feet). At the same time, malloc\nstatistics code will also lock the heap because it needs to\naccess heap data and does not want any other thread to allocate\nanything from that heap.\n\nIn such scheme, it is possible to enter a deadlock with the\nfollowing sequence of events:\n\nthread 1\t\tthread 2\nrte_malloc()\n\t\t\trte_malloc_dump_stats()\ntake heap lock\n\t\t\ttake hotplug lock\nfailed to allocate,\nattempt to take\nhotplug lock\n\t\t\tattempt to take heap lock\n\nNeither thread will be able to continue, as both of them are\nwaiting for the other one to drop the lock. Adding an\nadditional lock will require an ABI change, so instead of\nthat, make malloc statistics calls thread-unsafe with\nrespect to creating/destroying heaps.\n\nFixes: 72cf92b31855 (\"malloc: index heaps using heap ID rather than NUMA node\")\nCc: stable@dpdk.org\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n    This is the best we can do for 19.02 without breaking ABI.\n\n doc/guides/rel_notes/release_19_02.rst     |  4 ++++\n lib/librte_eal/common/include/rte_malloc.h |  9 +++++++++\n lib/librte_eal/common/rte_malloc.c         | 19 +++----------------\n 3 files changed, 16 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/doc/guides/rel_notes/release_19_02.rst b/doc/guides/rel_notes/release_19_02.rst\nindex 47768288a..0b248d55d 100644\n--- a/doc/guides/rel_notes/release_19_02.rst\n+++ b/doc/guides/rel_notes/release_19_02.rst\n@@ -126,6 +126,10 @@ API Changes\n   - In cases where memfd support would have been required to provide segment\n     fd's (such as in-memory or no-huge mode)\n \n+* eal: Functions ``rte_malloc_dump_stats()``, ``rte_malloc_dump_heaps()`` and\n+  ``rte_malloc_get_socket_stats()`` are no longer safe to call concurrently with\n+  ``rte_malloc_heap_create()`` or ``rte_malloc_heap_destroy()`` function calls.\n+\n * pdump: The ``rte_pdump_set_socket_dir()``, the parameter ``path`` of\n   ``rte_pdump_init()`` and enum ``rte_pdump_socktype`` were deprecated\n   since 18.05 and are removed in this release.\ndiff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex a5290b074..54a12467a 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -251,6 +251,9 @@ rte_malloc_validate(const void *ptr, size_t *size);\n /**\n  * Get heap statistics for the specified heap.\n  *\n+ * @note This function is not thread-safe with respect to\n+ *    ``rte_malloc_heap_create()``/``rte_malloc_heap_destroy()`` functions.\n+ *\n  * @param socket\n  *   An unsigned integer specifying the socket to get heap statistics for\n  * @param socket_stats\n@@ -461,6 +464,9 @@ rte_malloc_heap_socket_is_external(int socket_id);\n  * Dump for the specified type to a file. If the type argument is\n  * NULL, all memory types will be dumped.\n  *\n+ * @note This function is not thread-safe with respect to\n+ *    ``rte_malloc_heap_create()``/``rte_malloc_heap_destroy()`` functions.\n+ *\n  * @param f\n  *   A pointer to a file for output\n  * @param type\n@@ -473,6 +479,9 @@ rte_malloc_dump_stats(FILE *f, const char *type);\n /**\n  * Dump contents of all malloc heaps to a file.\n  *\n+ * @note This function is not thread-safe with respect to\n+ *    ``rte_malloc_heap_create()``/``rte_malloc_heap_destroy()`` functions.\n+ *\n  * @param f\n  *   A pointer to a file for output\n  */\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex 09051c236..b39de3c99 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -156,20 +156,14 @@ rte_malloc_get_socket_stats(int socket,\n \t\tstruct rte_malloc_socket_stats *socket_stats)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n-\tint heap_idx, ret = -1;\n-\n-\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n+\tint heap_idx;\n \n \theap_idx = malloc_socket_to_heap_id(socket);\n \tif (heap_idx < 0)\n-\t\tgoto unlock;\n+\t\treturn -1;\n \n-\tret = malloc_heap_get_stats(&mcfg->malloc_heaps[heap_idx],\n+\treturn malloc_heap_get_stats(&mcfg->malloc_heaps[heap_idx],\n \t\t\tsocket_stats);\n-unlock:\n-\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n-\n-\treturn ret;\n }\n \n /*\n@@ -181,14 +175,10 @@ rte_malloc_dump_heaps(FILE *f)\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tunsigned int idx;\n \n-\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n-\n \tfor (idx = 0; idx < RTE_MAX_HEAPS; idx++) {\n \t\tfprintf(f, \"Heap id: %u\\n\", idx);\n \t\tmalloc_heap_dump(&mcfg->malloc_heaps[idx], f);\n \t}\n-\n-\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n }\n \n int\n@@ -262,8 +252,6 @@ rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)\n \tunsigned int heap_id;\n \tstruct rte_malloc_socket_stats sock_stats;\n \n-\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n-\n \t/* Iterate through all initialised heaps */\n \tfor (heap_id = 0; heap_id < RTE_MAX_HEAPS; heap_id++) {\n \t\tstruct malloc_heap *heap = &mcfg->malloc_heaps[heap_id];\n@@ -280,7 +268,6 @@ rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)\n \t\tfprintf(f, \"\\tAlloc_count:%u,\\n\",sock_stats.alloc_count);\n \t\tfprintf(f, \"\\tFree_count:%u,\\n\", sock_stats.free_count);\n \t}\n-\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n \treturn;\n }\n \n",
    "prefixes": [
        "19.02",
        "v2"
    ]
}