get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131507,
    "url": "http://patches.dpdk.org/api/patches/131507/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230915131015.820160-1-bruce.richardson@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": "<20230915131015.820160-1-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230915131015.820160-1-bruce.richardson@intel.com",
    "date": "2023-09-15T13:10:15",
    "name": "[v2] eal: allow swapping of malloc heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "49ea64f8d3ea13e4e43cd640b83778dbf8ab75f5",
    "submitter": {
        "id": 20,
        "url": "http://patches.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230915131015.820160-1-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 29524,
            "url": "http://patches.dpdk.org/api/series/29524/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=29524",
            "date": "2023-09-15T13:10:15",
            "name": "[v2] eal: allow swapping of malloc heaps",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/29524/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/131507/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/131507/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 19FD8425A5;\n\tFri, 15 Sep 2023 15:10:25 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 9EA4440A6D;\n\tFri, 15 Sep 2023 15:10:24 +0200 (CEST)",
            "from mgamail.intel.com (mgamail.intel.com [192.55.52.136])\n by mails.dpdk.org (Postfix) with ESMTP id A9D4740041\n for <dev@dpdk.org>; Fri, 15 Sep 2023 15:10:22 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Sep 2023 06:10:21 -0700",
            "from silpixa00401385.ir.intel.com ([10.237.214.14])\n by fmsmga001.fm.intel.com with ESMTP; 15 Sep 2023 06:09:44 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1694783422; x=1726319422;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=GhEilwGUsnEzJza79mTNVHLaNZK8N7B3GONtm+CkcWY=;\n b=Zh0Xmd+JSuK5qjqAHN/Midv06bIrfD3njSfTgOtJ2EjuLTZReSmoHI1R\n VvBEYfDRptcZs6U22/HeO2JlAuq5Yxgm922DkhqnBQg0VEZsE84rssXAJ\n hlhuM8DznmbkMI2swGnUj8VFB80QrPY2J2k2WAVHvfZ3dTbhv1cmtK8oI\n fH9ou3e9/kywWVjdMIeoUV33xkANjLPOAKKrHzSX7XtyfiTs/ltjgGgV6\n FhGtmpNIKxEgi+aklK6/wZFXDjWXnbMxubfIh5aozjnyDm+LxNv617Dp1\n VZDjGDpNBHwXsEtkMaONHfyieNA/dQ+aeKetnEI8GHZ6TvvXw/c9DzwyI A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10834\"; a=\"358659702\"",
            "E=Sophos;i=\"6.02,149,1688454000\"; d=\"scan'208\";a=\"358659702\"",
            "E=McAfee;i=\"6600,9927,10834\"; a=\"888232946\"",
            "E=Sophos;i=\"6.02,149,1688454000\"; d=\"scan'208\";a=\"888232946\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Anatoly Burakov <anatoly.burakov@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[PATCH v2] eal: allow swapping of malloc heaps",
        "Date": "Fri, 15 Sep 2023 14:10:15 +0100",
        "Message-Id": "<20230915131015.820160-1-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230915122703.475834-1-bruce.richardson@intel.com>",
        "References": "<20230915122703.475834-1-bruce.richardson@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "The external memory functions in DPDK allow the addition of externally\naccess memory to malloc heaps, but with one major restriction - the\nmemory must be allocated to an application-created heap, not one of the\nstandard DPDK heaps for a NUMA node.\n\nThis restriction makes it difficult - if not impossible - to use\nexternally allocated memory for DPDK by default. However, even if the\nrestriction is relaxed, so we can add external memory to e.g. the socket\n0 heap, there would be no way to guarantee that the external memory\nwould be used in preference to the standard DPDK hugepage memory for a\ngiven allocation.\n\nTo give appropriately defined behaviour, a better solution is to allow\nthe application to explicitly swap a pair of heaps. With this one new\nAPI in place, it allows the user to configure a new malloc heap, add\nexternal memory to it, and then replace a standard socket heap with the\nnewly created one - thereby guaranteeing future allocations from the\nexternal memory.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\nV2: Fix doxygen comment issue on doc builds. Mark code snippet using\n    @code...@endcode to avoid issues with \"<\" symbols\n---\n lib/eal/common/malloc_heap.c | 18 ++++++++++++++++++\n lib/eal/include/rte_malloc.h | 28 ++++++++++++++++++++++++++++\n lib/eal/version.map          |  2 ++\n 3 files changed, 48 insertions(+)",
    "diff": "diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c\nindex 6b6cf9174c..e5d0ad6b52 100644\n--- a/lib/eal/common/malloc_heap.c\n+++ b/lib/eal/common/malloc_heap.c\n@@ -1320,6 +1320,24 @@ malloc_heap_add_external_memory(struct malloc_heap *heap,\n \treturn 0;\n }\n \n+int\n+rte_malloc_heap_swap_socket(int socket1, int socket2)\n+{\n+\tconst int h1 = malloc_socket_to_heap_id(socket1);\n+\tif (h1 < 0 || h1 > RTE_MAX_HEAPS)\n+\t\treturn -1;\n+\n+\tconst int h2 = malloc_socket_to_heap_id(socket2);\n+\tif (h2 < 0 || h2 > RTE_MAX_HEAPS)\n+\t\treturn -1;\n+\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tint tmp = mcfg->malloc_heaps[h1].socket_id;\n+\tmcfg->malloc_heaps[h1].socket_id = mcfg->malloc_heaps[h2].socket_id;\n+\tmcfg->malloc_heaps[h2].socket_id = tmp;\n+\treturn 0;\n+}\n+\n int\n malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr,\n \t\tsize_t len)\ndiff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h\nindex 54a8ac211e..410211aa44 100644\n--- a/lib/eal/include/rte_malloc.h\n+++ b/lib/eal/include/rte_malloc.h\n@@ -490,6 +490,34 @@ rte_malloc_heap_get_socket(const char *name);\n int\n rte_malloc_heap_socket_is_external(int socket_id);\n \n+/**\n+ * Swap the heaps for the given socket ids\n+ *\n+ * This causes the heaps for the given socket ids to be swapped, allowing\n+ * external memory registered as a malloc heap to become the new default memory\n+ * for a standard numa node. For example, to have allocations on socket 0 come\n+ * from external memory, the following sequence of API calls can be used:\n+ * @code\n+ *   rte_malloc_heap_create(<name>)\n+ *   rte_malloc_heap_memory_add(<name>,....)\n+ *   id = rte_malloc_heap_get_socket(<name>)\n+ *   rte_malloc_heap_swap_socket(0, id)\n+ * @endcode\n+ *\n+ * Following these calls, allocations for the old memory allocated on socket 0,\n+ * can be made by passing \"id\" as the socket_id parameter\n+ *\n+ * @param socket1\n+ *   The socket id of the first heap to swap\n+ * @param socket2\n+ *   The socket id of the second heap to swap\n+ * @return\n+ *   0 on success, -1 on error\n+ */\n+__rte_experimental\n+int\n+rte_malloc_heap_swap_socket(int socket1, int socket2);\n+\n /**\n  * Dump statistics.\n  *\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex 7940431e5a..b06ee7219e 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -417,6 +417,8 @@ EXPERIMENTAL {\n \t# added in 23.07\n \trte_memzone_max_get;\n \trte_memzone_max_set;\n+\n+\trte_malloc_heap_swap_socket;\n };\n \n INTERNAL {\n",
    "prefixes": [
        "v2"
    ]
}