get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45743,
    "url": "http://patches.dpdk.org/api/patches/45743/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/8871981d48e235a978f3a1b822de0baeee49e157.1538384304.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": "<8871981d48e235a978f3a1b822de0baeee49e157.1538384304.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/8871981d48e235a978f3a1b822de0baeee49e157.1538384304.git.anatoly.burakov@intel.com",
    "date": "2018-10-01T11:05:00",
    "name": "[v7,11/21] malloc: allow creating malloc heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "102497ffc3220186d09815fa7f0dd295d4f9dcd3",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@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/8871981d48e235a978f3a1b822de0baeee49e157.1538384304.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1613,
            "url": "http://patches.dpdk.org/api/series/1613/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1613",
            "date": "2018-10-01T11:04:49",
            "name": "Support externally allocated memory in DPDK",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/1613/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45743/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/45743/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 8A5F27CDC;\n\tMon,  1 Oct 2018 13:05:30 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 716615F12\n\tfor <dev@dpdk.org>; Mon,  1 Oct 2018 13:05:18 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t01 Oct 2018 04:05:16 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 01 Oct 2018 04:05:13 -0700",
            "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\tw91B5CMa028030; Mon, 1 Oct 2018 12:05:12 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w91B5C6U017855;\n\tMon, 1 Oct 2018 12:05:12 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w91B5CIG017851;\n\tMon, 1 Oct 2018 12:05:12 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,327,1534834800\"; d=\"scan'208\";a=\"268423255\"",
        "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>,\n\tlaszlo.madarassy@ericsson.com, laszlo.vadkerti@ericsson.com,\n\tandras.kovacs@ericsson.com, winnie.tian@ericsson.com,\n\tdaniel.andrasi@ericsson.com, janos.kobor@ericsson.com,\n\tgeza.koblo@ericsson.com, srinath.mannam@broadcom.com,\n\tscott.branden@broadcom.com, ajit.khaparde@broadcom.com,\n\tkeith.wiles@intel.com, bruce.richardson@intel.com, thomas@monjalon.net,\n\tshreyansh.jain@nxp.com, shahafs@mellanox.com,\n\tarybchenko@solarflare.com, alejandro.lucero@netronome.com",
        "Date": "Mon,  1 Oct 2018 12:05:00 +0100",
        "Message-Id": "<8871981d48e235a978f3a1b822de0baeee49e157.1538384304.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1538384304.git.anatoly.burakov@intel.com>",
            "<cover.1538384304.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1538384304.git.anatoly.burakov@intel.com>",
            "<cover.1538044725.git.anatoly.burakov@intel.com>\n\t<cover.1538384304.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v7 11/21] malloc: allow creating malloc heaps",
        "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": "Add API to allow creating new malloc heaps. They will be created\nwith socket ID's going above RTE_MAX_NUMA_NODES, to avoid clashing\nwith internal heaps.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n doc/guides/rel_notes/release_18_11.rst        |  2 +\n .../common/include/rte_eal_memconfig.h        |  3 ++\n lib/librte_eal/common/include/rte_malloc.h    | 19 +++++++\n lib/librte_eal/common/malloc_heap.c           | 37 +++++++++++++\n lib/librte_eal/common/malloc_heap.h           |  3 ++\n lib/librte_eal/common/rte_malloc.c            | 52 +++++++++++++++++++\n lib/librte_eal/rte_eal_version.map            |  1 +\n 7 files changed, 117 insertions(+)",
    "diff": "diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst\nindex 5a80e1122..5065ec1af 100644\n--- a/doc/guides/rel_notes/release_18_11.rst\n+++ b/doc/guides/rel_notes/release_18_11.rst\n@@ -125,6 +125,8 @@ ABI Changes\n        supporting external memory in DPDK. Structure ``rte_memseg_list`` now has\n        a new flag indicating whether the memseg list refers to external memory.\n        Structure ``rte_malloc_heap`` now has a ``heap_name`` string member.\n+       Structure ``rte_eal_memconfig`` has been extended to contain next socket\n+       ID for externally allocated memory segments.\n \n Removed Items\n -------------\ndiff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h\nindex d7920a4e0..98da58771 100644\n--- a/lib/librte_eal/common/include/rte_eal_memconfig.h\n+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h\n@@ -75,6 +75,9 @@ struct rte_mem_config {\n \t/* Heaps of Malloc */\n \tstruct malloc_heap malloc_heaps[RTE_MAX_HEAPS];\n \n+\t/* next socket ID for external malloc heap */\n+\tint next_socket_id;\n+\n \t/* address of mem_config in primary process. used to map shared config into\n \t * exact same address the primary process maps it.\n \t */\ndiff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 403271ddc..e326529d0 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -263,6 +263,25 @@ int\n rte_malloc_get_socket_stats(int socket,\n \t\tstruct rte_malloc_socket_stats *socket_stats);\n \n+/**\n+ * Creates a new empty malloc heap with a specified name.\n+ *\n+ * @note Heaps created via this call will automatically get assigned a unique\n+ *   socket ID, which can be found using ``rte_malloc_heap_get_socket()``\n+ *\n+ * @param heap_name\n+ *   Name of the heap to create.\n+ *\n+ * @return\n+ *   - 0 on successful creation\n+ *   - -1 in case of error, with rte_errno set to one of the following:\n+ *     EINVAL - ``heap_name`` was NULL, empty or too long\n+ *     EEXIST - heap by name of ``heap_name`` already exists\n+ *     ENOSPC - no more space in internal config to store a new heap\n+ */\n+int __rte_experimental\n+rte_malloc_heap_create(const char *heap_name);\n+\n /**\n  * Find socket ID corresponding to a named heap.\n  *\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex b28905817..00fdf54f7 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -29,6 +29,10 @@\n #include \"malloc_heap.h\"\n #include \"malloc_mp.h\"\n \n+/* start external socket ID's at a very high number */\n+#define CONST_MAX(a, b) (a > b ? a : b) /* RTE_MAX is not a constant */\n+#define EXTERNAL_HEAP_MIN_SOCKET_ID (CONST_MAX((1 << 8), RTE_MAX_NUMA_NODES))\n+\n static unsigned\n check_hugepage_sz(unsigned flags, uint64_t hugepage_sz)\n {\n@@ -1019,6 +1023,36 @@ malloc_heap_dump(struct malloc_heap *heap, FILE *f)\n \trte_spinlock_unlock(&heap->lock);\n }\n \n+int\n+malloc_heap_create(struct malloc_heap *heap, const char *heap_name)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tuint32_t next_socket_id = mcfg->next_socket_id;\n+\n+\t/* prevent overflow. did you really create 2 billion heaps??? */\n+\tif (next_socket_id > INT32_MAX) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot assign new socket ID's\\n\");\n+\t\trte_errno = ENOSPC;\n+\t\treturn -1;\n+\t}\n+\n+\t/* initialize empty heap */\n+\theap->alloc_count = 0;\n+\theap->first = NULL;\n+\theap->last = NULL;\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+\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 int\n rte_eal_malloc_heap_init(void)\n {\n@@ -1026,6 +1060,9 @@ rte_eal_malloc_heap_init(void)\n \tunsigned int i;\n \n \tif (rte_eal_process_type() == RTE_PROC_PRIMARY) {\n+\t\t/* assign min socket ID to external heaps */\n+\t\tmcfg->next_socket_id = EXTERNAL_HEAP_MIN_SOCKET_ID;\n+\n \t\t/* assign names to default DPDK heaps */\n \t\tfor (i = 0; i < rte_socket_count(); i++) {\n \t\t\tstruct malloc_heap *heap = &mcfg->malloc_heaps[i];\ndiff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h\nindex 61b844b6f..eebee16dc 100644\n--- a/lib/librte_eal/common/malloc_heap.h\n+++ b/lib/librte_eal/common/malloc_heap.h\n@@ -33,6 +33,9 @@ void *\n malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags,\n \t\tsize_t align, bool contig);\n \n+int\n+malloc_heap_create(struct malloc_heap *heap, const char *heap_name);\n+\n int\n malloc_heap_free(struct malloc_elem *elem);\n \ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex fa81d7862..25967a7cb 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -13,6 +13,7 @@\n #include <rte_memory.h>\n #include <rte_eal.h>\n #include <rte_eal_memconfig.h>\n+#include <rte_errno.h>\n #include <rte_branch_prediction.h>\n #include <rte_debug.h>\n #include <rte_launch.h>\n@@ -311,3 +312,54 @@ rte_malloc_virt2iova(const void *addr)\n \n \treturn ms->iova + RTE_PTR_DIFF(addr, ms->addr);\n }\n+\n+int\n+rte_malloc_heap_create(const char *heap_name)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tstruct malloc_heap *heap = NULL;\n+\tint i, ret;\n+\n+\tif (heap_name == NULL ||\n+\t\t\tstrnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 ||\n+\t\t\tstrnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) ==\n+\t\t\t\tRTE_HEAP_NAME_MAX_LEN) {\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\t/* check if there is space in the heap list, or if heap with this name\n+\t * already exists.\n+\t */\n+\trte_rwlock_write_lock(&mcfg->memory_hotplug_lock);\n+\n+\tfor (i = 0; i < RTE_MAX_HEAPS; i++) {\n+\t\tstruct malloc_heap *tmp = &mcfg->malloc_heaps[i];\n+\t\t/* existing heap */\n+\t\tif (strncmp(heap_name, tmp->name,\n+\t\t\t\tRTE_HEAP_NAME_MAX_LEN) == 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Heap %s already exists\\n\",\n+\t\t\t\theap_name);\n+\t\t\trte_errno = EEXIST;\n+\t\t\tret = -1;\n+\t\t\tgoto unlock;\n+\t\t}\n+\t\t/* empty heap */\n+\t\tif (strnlen(tmp->name, RTE_HEAP_NAME_MAX_LEN) == 0) {\n+\t\t\theap = tmp;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tif (heap == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot create new heap: no space\\n\");\n+\t\trte_errno = ENOSPC;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* we're sure that we can create a new heap, so do it */\n+\tret = malloc_heap_create(heap, heap_name);\n+unlock:\n+\trte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);\n+\n+\treturn ret;\n+}\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex bd60506af..376f33bbb 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -318,6 +318,7 @@ EXPERIMENTAL {\n \trte_fbarray_set_used;\n \trte_log_register_type_and_pick_level;\n \trte_malloc_dump_heaps;\n+\trte_malloc_heap_create;\n \trte_malloc_heap_get_socket;\n \trte_malloc_heap_socket_is_external;\n \trte_mem_alloc_validator_register;\n",
    "prefixes": [
        "v7",
        "11/21"
    ]
}