get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131579,
    "url": "http://patchwork.dpdk.org/api/patches/131579/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230918163206.1010611-2-bruce.richardson@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": "<20230918163206.1010611-2-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230918163206.1010611-2-bruce.richardson@intel.com",
    "date": "2023-09-18T16:32:05",
    "name": "[v3,1/2] eal: add flag to indicate non-EAL malloc heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "38219f2303f57990201dc8f85d87947eec40e117",
    "submitter": {
        "id": 20,
        "url": "http://patchwork.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230918163206.1010611-2-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 29538,
            "url": "http://patchwork.dpdk.org/api/series/29538/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29538",
            "date": "2023-09-18T16:32:04",
            "name": "Enable apps to use external memory as native",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/29538/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/131579/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/131579/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 08D0D425DC;\n\tMon, 18 Sep 2023 18:33:10 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C96A540E36;\n\tMon, 18 Sep 2023 18:32:22 +0200 (CEST)",
            "from mgamail.intel.com (mgamail.intel.com [134.134.136.31])\n by mails.dpdk.org (Postfix) with ESMTP id D273A40E36\n for <dev@dpdk.org>; Mon, 18 Sep 2023 18:32:20 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 18 Sep 2023 09:32:19 -0700",
            "from silpixa00401385.ir.intel.com ([10.237.214.14])\n by orsmga008.jf.intel.com with ESMTP; 18 Sep 2023 09:32:19 -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=1695054740; x=1726590740;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=+3XBw/EDcqYLFFjUEvlZWhoBDEj51AqVv3nbKl6ztHk=;\n b=YwJWr2x8VnzyD55oDMryySKx92iuKIvE35w6c0QR8meLbP/0zyCFLcKo\n LpgiK47kiF2uok8GWlq9cYBk1eZF77SnnOEaVQ9Dvf+5bk2O/KiPhjZBC\n uzhAe2h4pebeORKG7tJ74ahfEO8DfDS+84zJtUCQhlY8dfXO55dWpO5WR\n QL5twmYrS5zRlH1nInUyTz3TOkcVLAKLw2v15eEXa3dFz/DM6f3viCAnz\n WMoWH/mtMqeLd8RDnPPvkP97SIAU9WRk/L1F93XO23BxVGoWkswS67Fhv\n KyW0zNsDZ3O4z3n4SqMgrdjkhjSnakfxgB6VpVTyDJhatNWs/9Ne8C6BQ A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10837\"; a=\"443784646\"",
            "E=Sophos;i=\"6.02,156,1688454000\"; d=\"scan'208\";a=\"443784646\"",
            "E=McAfee;i=\"6600,9927,10837\"; a=\"775189365\"",
            "E=Sophos;i=\"6.02,156,1688454000\"; d=\"scan'208\";a=\"775189365\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Bruce Richardson <bruce.richardson@intel.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>",
        "Subject": "[PATCH v3 1/2] eal: add flag to indicate non-EAL malloc heaps",
        "Date": "Mon, 18 Sep 2023 17:32:05 +0100",
        "Message-Id": "<20230918163206.1010611-2-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230918163206.1010611-1-bruce.richardson@intel.com>",
        "References": "<20230915122703.475834-1-bruce.richardson@intel.com>\n <20230918163206.1010611-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": "Rather than relying implicitly on the socket_id value to identify\nexternal heaps vs internal ones that can be expanded on demand by adding\nmore hugepages, we add an \"is_external\" flag to the heap structure. As\nwe do so, we change the heap initialization to use designated\ninitializers to guarantee as we add new fields that they are properly\nzeroed on init. As it stands, many fields are not explicitly set on\nfirst init of the internal malloc heaps.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/eal/common/malloc_heap.c | 22 ++++++++++++----------\n lib/eal/common/malloc_heap.h |  1 +\n lib/eal/common/malloc_mp.c   |  5 ++---\n lib/eal/common/rte_malloc.c  | 14 ++++++++------\n 4 files changed, 23 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c\nindex 6b6cf9174c..4fa38fcd44 100644\n--- a/lib/eal/common/malloc_heap.c\n+++ b/lib/eal/common/malloc_heap.c\n@@ -668,7 +668,7 @@ malloc_heap_alloc_on_heap_id(const char *type, size_t size,\n \t * we just need to request more memory first.\n \t */\n \n-\tsocket_id = rte_socket_id_by_idx(heap_id);\n+\tsocket_id = heap->is_external ? -1 : rte_socket_id_by_idx(heap_id);\n \t/*\n \t * if socket ID is negative, we cannot find a socket ID for this heap -\n \t * which means it's an external heap. those can have unexpected page\n@@ -1362,19 +1362,17 @@ malloc_heap_create(struct malloc_heap *heap, const char *heap_name)\n \t}\n \n \t/* initialize empty heap */\n-\theap->alloc_count = 0;\n-\theap->first = NULL;\n-\theap->last = NULL;\n+\t*heap = (struct malloc_heap) {\n+\t\t.is_external = 1,\n+\t\t.socket_id = next_socket_id,\n+\t\t.lock = RTE_SPINLOCK_INITIALIZER,\n+\t};\n \tLIST_INIT(heap->free_head);\n-\trte_spinlock_init(&heap->lock);\n-\theap->total_size = 0;\n-\theap->socket_id = next_socket_id;\n+\tstrlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);\n \n \t/* we hold a global mem hotplug writelock, so it's safe to increment */\n \tmcfg->next_socket_id++;\n \n-\t/* set up name */\n-\tstrlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);\n \treturn 0;\n }\n \n@@ -1425,8 +1423,12 @@ rte_eal_malloc_heap_init(void)\n \n \t\t\tsnprintf(heap_name, sizeof(heap_name),\n \t\t\t\t\t\"socket_%i\", socket_id);\n+\n+\t\t\t*heap = (struct malloc_heap){\n+\t\t\t\t.lock = RTE_SPINLOCK_INITIALIZER,\n+\t\t\t\t.socket_id = socket_id,\n+\t\t\t};\n \t\t\tstrlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);\n-\t\t\theap->socket_id = socket_id;\n \t\t}\n \t}\n \ndiff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h\nindex 8f3ab57154..e23cc01fb3 100644\n--- a/lib/eal/common/malloc_heap.h\n+++ b/lib/eal/common/malloc_heap.h\n@@ -23,6 +23,7 @@ struct malloc_elem;\n  */\n struct malloc_heap {\n \trte_spinlock_t lock;\n+\tuint32_t is_external:1;\n \tLIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS];\n \tstruct malloc_elem *volatile first;\n \tstruct malloc_elem *volatile last;\ndiff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c\nindex 7270c2ec90..d5ab6d8351 100644\n--- a/lib/eal/common/malloc_mp.c\n+++ b/lib/eal/common/malloc_mp.c\n@@ -242,10 +242,9 @@ handle_alloc_request(const struct malloc_mp_req *m,\n \t/*\n \t * for allocations, we must only use internal heaps, but since the\n \t * rte_malloc_heap_socket_is_external() is thread-safe and we're already\n-\t * read-locked, we'll have to take advantage of the fact that internal\n-\t * socket ID's are always lower than RTE_MAX_NUMA_NODES.\n+\t * read-locked, we'll check directly here.\n \t */\n-\tif (heap->socket_id >= RTE_MAX_NUMA_NODES) {\n+\tif (heap->is_external == 1) {\n \t\tRTE_LOG(ERR, EAL, \"Attempting to allocate from external heap\\n\");\n \t\treturn -1;\n \t}\ndiff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c\nindex ebafef3f6c..5f40acabee 100644\n--- a/lib/eal/common/rte_malloc.c\n+++ b/lib/eal/common/rte_malloc.c\n@@ -314,7 +314,7 @@ rte_malloc_heap_socket_is_external(int socket_id)\n \n \t\tif ((int)tmp->socket_id == socket_id) {\n \t\t\t/* external memory always has large socket ID's */\n-\t\t\tret = tmp->socket_id >= RTE_MAX_NUMA_NODES;\n+\t\t\tret = tmp->is_external;\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -421,7 +421,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,\n \t\tret = -1;\n \t\tgoto unlock;\n \t}\n-\tif (heap->socket_id < RTE_MAX_NUMA_NODES) {\n+\tif (heap->is_external == 0) {\n \t\t/* cannot add memory to internal heaps */\n \t\trte_errno = EPERM;\n \t\tret = -1;\n@@ -469,7 +469,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)\n \t\tret = -1;\n \t\tgoto unlock;\n \t}\n-\tif (heap->socket_id < RTE_MAX_NUMA_NODES) {\n+\tif (heap->is_external == 0) {\n \t\t/* cannot remove memory from internal heaps */\n \t\trte_errno = EPERM;\n \t\tret = -1;\n@@ -520,7 +520,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)\n \t\tgoto unlock;\n \t}\n \t/* we shouldn't be able to sync to internal heaps */\n-\tif (heap->socket_id < RTE_MAX_NUMA_NODES) {\n+\tif (heap->is_external == 0) {\n \t\trte_errno = EPERM;\n \t\tret = -1;\n \t\tgoto unlock;\n@@ -648,8 +648,10 @@ rte_malloc_heap_destroy(const char *heap_name)\n \t\tret = -1;\n \t\tgoto unlock;\n \t}\n-\t/* we shouldn't be able to destroy internal heaps */\n-\tif (heap->socket_id < RTE_MAX_NUMA_NODES) {\n+\t/* we shouldn't be able to destroy internal heaps, or external heaps\n+\t * configured to have an internal numa socket id\n+\t */\n+\tif (heap->socket_id < RTE_MAX_NUMA_NODES || heap->is_external == 0) {\n \t\trte_errno = EPERM;\n \t\tret = -1;\n \t\tgoto unlock;\n",
    "prefixes": [
        "v3",
        "1/2"
    ]
}