get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44226,
    "url": "http://patches.dpdk.org/api/patches/44226/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/3b841d17bbe1d36954ac0d187221bcdad3e06e5c.1536064999.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": "<3b841d17bbe1d36954ac0d187221bcdad3e06e5c.1536064999.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/3b841d17bbe1d36954ac0d187221bcdad3e06e5c.1536064999.git.anatoly.burakov@intel.com",
    "date": "2018-09-04T13:11:45",
    "name": "[10/16] malloc: allow creating malloc heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2a0ecf53b2b74340e03c1b70cc46fddd0a1afa39",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "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/3b841d17bbe1d36954ac0d187221bcdad3e06e5c.1536064999.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1170,
            "url": "http://patches.dpdk.org/api/series/1170/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1170",
            "date": "2018-09-04T13:11:35",
            "name": "Support externally allocated memory in DPDK",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1170/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44226/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44226/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 7599B4CC3;\n\tTue,  4 Sep 2018 15:12:05 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 2C2562BA1\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 15:11:59 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 06:11:58 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga002.fm.intel.com with ESMTP; 04 Sep 2018 06:11:54 -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\tw84DBrgr023375; Tue, 4 Sep 2018 14:11:53 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84DBrVs024647;\n\tTue, 4 Sep 2018 14:11:53 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84DBrol024640;\n\tTue, 4 Sep 2018 14:11:53 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,329,1531810800\"; d=\"scan'208\";a=\"82876062\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "laszlo.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\tsrinath.mannam@broadcom.com, scott.branden@broadcom.com,\n\tajit.khaparde@broadcom.com, keith.wiles@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net",
        "Date": "Tue,  4 Sep 2018 14:11:45 +0100",
        "Message-Id": "<3b841d17bbe1d36954ac0d187221bcdad3e06e5c.1536064999.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH 10/16] 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 lib/librte_eal/common/include/rte_malloc.h | 19 ++++++++\n lib/librte_eal/common/malloc_heap.c        | 30 +++++++++++++\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 5 files changed, 105 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 8870732a6..182afab1c 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 813961f0c..2742f7b11 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@@ -1006,6 +1010,32 @@ 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+\tstatic uint32_t next_socket_id = EXTERNAL_HEAP_MIN_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/* 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 {\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 b789333b3..ade5af406 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@@ -286,3 +287,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 6fd729b8b..c93dcf1a3 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -311,6 +311,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_mem_alloc_validator_register;\n \trte_mem_alloc_validator_unregister;\n",
    "prefixes": [
        "10/16"
    ]
}