Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/35722/?format=api
http://patches.dpdk.org/api/patches/35722/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/457f67e415c6735654649dc899aefbcbdd5c43d6.1520428025.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": "<457f67e415c6735654649dc899aefbcbdd5c43d6.1520428025.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/457f67e415c6735654649dc899aefbcbdd5c43d6.1520428025.git.anatoly.burakov@intel.com", "date": "2018-03-07T16:56:30", "name": "[dpdk-dev,v2,02/41] eal: move all locking to heap", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "9063820e3ceb6121f64be49deea7623fbed06b65", "submitter": { "id": 4, "url": "http://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/457f67e415c6735654649dc899aefbcbdd5c43d6.1520428025.git.anatoly.burakov@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/35722/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/35722/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 4087D7CBA;\n\tWed, 7 Mar 2018 17:57:21 +0100 (CET)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 60BD45F18\n\tfor <dev@dpdk.org>; Wed, 7 Mar 2018 17:57:15 +0100 (CET)", "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Mar 2018 08:57:14 -0800", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga007.jf.intel.com with ESMTP; 07 Mar 2018 08:57:10 -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\tw27Gv9d7032346; Wed, 7 Mar 2018 16:57:09 GMT", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w27Gv9O5006624;\n\tWed, 7 Mar 2018 16:57:09 GMT", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w27Gv9nL006620;\n\tWed, 7 Mar 2018 16:57:09 GMT" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.47,436,1515484800\"; d=\"scan'208\";a=\"22774198\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "keith.wiles@intel.com, jianfeng.tan@intel.com, andras.kovacs@ericsson.com,\n\tlaszlo.vadkeri@ericsson.com, benjamin.walker@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net,\n\tkonstantin.ananyev@intel.com, kuralamudhan.ramakrishnan@intel.com,\n\tlouise.m.daly@intel.com, nelio.laranjeiro@6wind.com,\n\tyskoh@mellanox.com, pepperjo@japf.ch, jerin.jacob@caviumnetworks.com, \n\themant.agrawal@nxp.com, olivier.matz@6wind.com", "Date": "Wed, 7 Mar 2018 16:56:30 +0000", "Message-Id": "<457f67e415c6735654649dc899aefbcbdd5c43d6.1520428025.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1520428025.git.anatoly.burakov@intel.com>", "<cover.1520428025.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1520428025.git.anatoly.burakov@intel.com>", "<cover.1520083504.git.anatoly.burakov@intel.com>\n\t<cover.1520428025.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [PATCH v2 02/41] eal: move all locking to heap", "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://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Down the line, we will need to do everything from the heap as any\nalloc or free may trigger alloc/free OS memory, which would involve\ngrowing/shrinking heap.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/malloc_elem.c | 16 ++--------------\n lib/librte_eal/common/malloc_heap.c | 38 +++++++++++++++++++++++++++++++++++++\n lib/librte_eal/common/malloc_heap.h | 6 ++++++\n lib/librte_eal/common/rte_malloc.c | 4 ++--\n 4 files changed, 48 insertions(+), 16 deletions(-)", "diff": "diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c\nindex 0cadc8a..ea041e2 100644\n--- a/lib/librte_eal/common/malloc_elem.c\n+++ b/lib/librte_eal/common/malloc_elem.c\n@@ -243,10 +243,6 @@ join_elem(struct malloc_elem *elem1, struct malloc_elem *elem2)\n int\n malloc_elem_free(struct malloc_elem *elem)\n {\n-\tif (!malloc_elem_cookies_ok(elem) || elem->state != ELEM_BUSY)\n-\t\treturn -1;\n-\n-\trte_spinlock_lock(&(elem->heap->lock));\n \tsize_t sz = elem->size - sizeof(*elem) - MALLOC_ELEM_TRAILER_LEN;\n \tuint8_t *ptr = (uint8_t *)&elem[1];\n \tstruct malloc_elem *next = RTE_PTR_ADD(elem, elem->size);\n@@ -274,8 +270,6 @@ malloc_elem_free(struct malloc_elem *elem)\n \n \tmemset(ptr, 0, sz);\n \n-\trte_spinlock_unlock(&(elem->heap->lock));\n-\n \treturn 0;\n }\n \n@@ -292,11 +286,10 @@ malloc_elem_resize(struct malloc_elem *elem, size_t size)\n \t\treturn 0;\n \n \tstruct malloc_elem *next = RTE_PTR_ADD(elem, elem->size);\n-\trte_spinlock_lock(&elem->heap->lock);\n \tif (next ->state != ELEM_FREE)\n-\t\tgoto err_return;\n+\t\treturn -1;\n \tif (elem->size + next->size < new_size)\n-\t\tgoto err_return;\n+\t\treturn -1;\n \n \t/* we now know the element fits, so remove from free list,\n \t * join the two\n@@ -311,10 +304,5 @@ malloc_elem_resize(struct malloc_elem *elem, size_t size)\n \t\tsplit_elem(elem, split_pt);\n \t\tmalloc_elem_free_list_insert(split_pt);\n \t}\n-\trte_spinlock_unlock(&elem->heap->lock);\n \treturn 0;\n-\n-err_return:\n-\trte_spinlock_unlock(&elem->heap->lock);\n-\treturn -1;\n }\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex 7aafc88..7d8d70a 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -145,6 +145,44 @@ malloc_heap_alloc(struct malloc_heap *heap,\n \treturn elem == NULL ? NULL : (void *)(&elem[1]);\n }\n \n+int\n+malloc_heap_free(struct malloc_elem *elem)\n+{\n+\tstruct malloc_heap *heap;\n+\tint ret;\n+\n+\tif (!malloc_elem_cookies_ok(elem) || elem->state != ELEM_BUSY)\n+\t\treturn -1;\n+\n+\t/* elem may be merged with previous element, so keep heap address */\n+\theap = elem->heap;\n+\n+\trte_spinlock_lock(&(heap->lock));\n+\n+\tret = malloc_elem_free(elem);\n+\n+\trte_spinlock_unlock(&(heap->lock));\n+\n+\treturn ret;\n+}\n+\n+int\n+malloc_heap_resize(struct malloc_elem *elem, size_t size)\n+{\n+\tint ret;\n+\n+\tif (!malloc_elem_cookies_ok(elem) || elem->state != ELEM_BUSY)\n+\t\treturn -1;\n+\n+\trte_spinlock_lock(&(elem->heap->lock));\n+\n+\tret = malloc_elem_resize(elem, size);\n+\n+\trte_spinlock_unlock(&(elem->heap->lock));\n+\n+\treturn ret;\n+}\n+\n /*\n * Function to retrieve data for heap on given socket\n */\ndiff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h\nindex e0defa7..ab0005c 100644\n--- a/lib/librte_eal/common/malloc_heap.h\n+++ b/lib/librte_eal/common/malloc_heap.h\n@@ -28,6 +28,12 @@ malloc_heap_alloc(struct malloc_heap *heap,\tconst char *type, size_t size,\n \t\tunsigned flags, size_t align, size_t bound);\n \n int\n+malloc_heap_free(struct malloc_elem *elem);\n+\n+int\n+malloc_heap_resize(struct malloc_elem *elem, size_t size);\n+\n+int\n malloc_heap_get_stats(struct malloc_heap *heap,\n \t\tstruct rte_malloc_socket_stats *socket_stats);\n \ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex e0e0d0b..970813e 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -29,7 +29,7 @@\n void rte_free(void *addr)\n {\n \tif (addr == NULL) return;\n-\tif (malloc_elem_free(malloc_elem_from_data(addr)) < 0)\n+\tif (malloc_heap_free(malloc_elem_from_data(addr)) < 0)\n \t\trte_panic(\"Fatal error: Invalid memory\\n\");\n }\n \n@@ -140,7 +140,7 @@ rte_realloc(void *ptr, size_t size, unsigned align)\n \tsize = RTE_CACHE_LINE_ROUNDUP(size), align = RTE_CACHE_LINE_ROUNDUP(align);\n \t/* check alignment matches first, and if ok, see if we can resize block */\n \tif (RTE_PTR_ALIGN(ptr,align) == ptr &&\n-\t\t\tmalloc_elem_resize(elem, size) == 0)\n+\t\t\tmalloc_heap_resize(elem, size) == 0)\n \t\treturn ptr;\n \n \t/* either alignment is off, or we have no room to expand,\n", "prefixes": [ "dpdk-dev", "v2", "02/41" ] }{ "id": 35722, "url": "