Show a patch.

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

{
    "id": 44237,
    "url": "http://patches.dpdk.org/api/patches/44237/",
    "web_url": "http://patches.dpdk.org/patch/44237/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<ca13ef6c4f295520abe9c7d23454a329a20e6450.1536064999.git.anatoly.burakov@intel.com>",
    "date": "2018-09-04T13:11:50",
    "name": "[15/16] malloc: allow detaching from external memory",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "117928d726160571bd6dedd6017e108ed3d438bb",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44237/mbox/",
    "series": [
        {
            "id": 1170,
            "url": "http://patches.dpdk.org/api/series/1170/",
            "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/44237/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44237/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 1.7.0.7",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 72D674CC0;\n\tTue,  4 Sep 2018 15:13:37 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id C46C14C9D\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 15:13:35 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 06:13:34 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga008.jf.intel.com with ESMTP; 04 Sep 2018 06:11:55 -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\tw84DBs8b023390; Tue, 4 Sep 2018 14:11:54 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84DBsgT024882;\n\tTue, 4 Sep 2018 14:11:54 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84DBsuY024873;\n\tTue, 4 Sep 2018 14:11:54 +0100"
        ],
        "References": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<ca13ef6c4f295520abe9c7d23454a329a20e6450.1536064999.git.anatoly.burakov@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,329,1531810800\"; d=\"scan'208\";a=\"70456121\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Tue,  4 Sep 2018 14:11:50 +0100",
        "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",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH 15/16] malloc: allow detaching from external\n\tmemory"
    },
    "content": "Add API to detach from existing chunk of external memory in a\nprocess.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/include/rte_malloc.h | 27 ++++++++++++++++++++++\n lib/librte_eal/common/rte_malloc.c         | 27 ++++++++++++++++++----\n lib/librte_eal/rte_eal_version.map         |  1 +\n 3 files changed, 50 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 37af0e481..0794f58e5 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -315,6 +315,9 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,\n  * @note Memory area must not contain any allocated elements to allow its\n  *   removal from the heap\n  *\n+ * @note All other processes must detach from the memory chunk prior to it being\n+ *   removed from the heap.\n+ *\n  * @param heap_name\n  *   Name of the heap to remove memory from\n  * @param va_addr\n@@ -357,6 +360,30 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len);\n int __rte_experimental\n rte_malloc_heap_memory_attach(const char *heap_name, void *va_addr, size_t len);\n \n+/**\n+ * Detach from a chunk of external memory in secondary process.\n+ *\n+ * @note This function must be called in before any attempt is made to remove\n+ *   external memory from the heap in another process. This function does *not*\n+ *   need to be called if a call to ``rte_malloc_heap_memory_remove`` will be\n+ *   called in current process.\n+ *\n+ * @param heap_name\n+ *   Heap name to which this chunk of memory belongs\n+ * @param va_addr\n+ *   Start address of memory chunk to attach to\n+ * @param len\n+ *   Length of memory chunk to attach to\n+ * @return\n+ *   0 on successful detach\n+ *   -1 on unsuccessful detach, with rte_errno set to indicate cause for error:\n+ *     EINVAL - one of the parameters was invalid\n+ *     EPERM  - attempted to detach memory from a reserved heap\n+ *     ENOENT - heap or memory chunk was not found\n+ */\n+int __rte_experimental\n+rte_malloc_heap_memory_detach(const char *heap_name, void *va_addr, size_t len);\n+\n /**\n  * Creates a new empty malloc heap with a specified name.\n  *\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex 2ed173466..08571e5a0 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -397,10 +397,11 @@ struct sync_mem_walk_arg {\n \tvoid *va_addr;\n \tsize_t len;\n \tint result;\n+\tbool attach;\n };\n \n static int\n-attach_mem_walk(const struct rte_memseg_list *msl, void *arg)\n+sync_mem_walk(const struct rte_memseg_list *msl, void *arg)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tstruct sync_mem_walk_arg *wa = arg;\n@@ -415,7 +416,10 @@ attach_mem_walk(const struct rte_memseg_list *msl, void *arg)\n \t\tmsl_idx = msl - mcfg->memsegs;\n \t\tfound_msl = &mcfg->memsegs[msl_idx];\n \n-\t\tret = rte_fbarray_attach(&found_msl->memseg_arr);\n+\t\tif (wa->attach)\n+\t\t\tret = rte_fbarray_attach(&found_msl->memseg_arr);\n+\t\telse\n+\t\t\tret = rte_fbarray_detach(&found_msl->memseg_arr);\n \n \t\tif (ret < 0)\n \t\t\twa->result = -rte_errno;\n@@ -426,8 +430,8 @@ attach_mem_walk(const struct rte_memseg_list *msl, void *arg)\n \treturn 0;\n }\n \n-int\n-rte_malloc_heap_memory_attach(const char *heap_name, void *va_addr, size_t len)\n+static int\n+sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tstruct malloc_heap *heap = NULL;\n@@ -461,9 +465,10 @@ rte_malloc_heap_memory_attach(const char *heap_name, void *va_addr, size_t len)\n \twa.va_addr = va_addr;\n \twa.len = len;\n \twa.result = -ENOENT; /* fail unless explicitly told to succeed */\n+\twa.attach = attach;\n \n \t/* we're already holding a read lock */\n-\trte_memseg_list_walk_thread_unsafe(attach_mem_walk, &wa);\n+\trte_memseg_list_walk_thread_unsafe(sync_mem_walk, &wa);\n \n \tif (wa.result < 0) {\n \t\trte_errno = -wa.result;\n@@ -476,6 +481,18 @@ rte_malloc_heap_memory_attach(const char *heap_name, void *va_addr, size_t len)\n \treturn ret;\n }\n \n+int\n+rte_malloc_heap_memory_attach(const char *heap_name, void *va_addr, size_t len)\n+{\n+\treturn sync_memory(heap_name, va_addr, len, true);\n+}\n+\n+int\n+rte_malloc_heap_memory_detach(const char *heap_name, void *va_addr, size_t len)\n+{\n+\treturn sync_memory(heap_name, va_addr, len, false);\n+}\n+\n int\n rte_malloc_heap_create(const char *heap_name)\n {\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 822c5693a..73fecb912 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -316,6 +316,7 @@ EXPERIMENTAL {\n \trte_malloc_heap_get_socket;\n \trte_malloc_heap_memory_add;\n \trte_malloc_heap_memory_attach;\n+\trte_malloc_heap_memory_detach;\n \trte_malloc_heap_memory_remove;\n \trte_mem_alloc_validator_register;\n \trte_mem_alloc_validator_unregister;\n",
    "prefixes": [
        "15/16"
    ]
}