get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 48519,
    "url": "http://patchwork.dpdk.org/api/patches/48519/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.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": "<884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com",
    "date": "2018-12-04T12:22:20",
    "name": "[18.11] malloc: fix deadlock when using malloc stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "487f1728fa2b7f16b194cb1dcc21c4b862ae39c2",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 2656,
            "url": "http://patchwork.dpdk.org/api/series/2656/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=2656",
            "date": "2018-12-04T12:22:20",
            "name": "[18.11] malloc: fix deadlock when using malloc stats",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/2656/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/48519/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/48519/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 9A3DB1B2B0;\n\tTue,  4 Dec 2018 13:22:29 +0100 (CET)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id ADB4B1B295;\n\tTue,  4 Dec 2018 13:22:27 +0100 (CET)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Dec 2018 04:22:26 -0800",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga003.jf.intel.com with ESMTP; 04 Dec 2018 04:22:25 -0800",
            "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\twB4CMORO029836; Tue, 4 Dec 2018 12:22:24 GMT",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id wB4CMOnK023590;\n\tTue, 4 Dec 2018 12:22:24 GMT",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id wB4CMKht023493;\n\tTue, 4 Dec 2018 12:22:20 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,314,1539673200\"; d=\"scan'208\";a=\"107164456\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net, stable@dpdk.org",
        "Date": "Tue,  4 Dec 2018 12:22:20 +0000",
        "Message-Id": "<884a355bde19652d57c253c6b36036571c4f46ee.1543926108.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "Subject": "[dpdk-dev] [PATCH 18.11] 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    IMO this is the best we can do for 18.11 without breaking ABI.\n    For 19.02, we can introduce a new global heap lock (something\n    i should've done in the first place...), so this patch is\n    not applicable to 19.02. For 19.02, we can fix this properly\n    by introducing another lock and breaking the EAL ABI.\n    \n    Not sure where to put docs update, feedback welcome.\n\n lib/librte_eal/common/include/rte_malloc.h |  9 +++++++++\n lib/librte_eal/common/rte_malloc.c         | 19 +++----------------\n 2 files changed, 12 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 7249e6aae..cde6232f9 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 0da5ad5e8..bc2b74d19 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": [
        "18.11"
    ]
}