get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45382,
    "url": "http://patchwork.dpdk.org/api/patches/45382/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/e8ba3183892869b08f81a919b569cd25345333bc.1537960448.git.anatoly.burakov@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": "<e8ba3183892869b08f81a919b569cd25345333bc.1537960448.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/e8ba3183892869b08f81a919b569cd25345333bc.1537960448.git.anatoly.burakov@intel.com",
    "date": "2018-09-26T11:22:09",
    "name": "[v5,10/21] malloc: add function to check if socket is external",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2298086ef3cb1f21c121058dc01a205d9934fa43",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@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/e8ba3183892869b08f81a919b569cd25345333bc.1537960448.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1516,
            "url": "http://patchwork.dpdk.org/api/series/1516/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=1516",
            "date": "2018-09-26T11:22:00",
            "name": "Support externally allocated memory in DPDK",
            "version": 5,
            "mbox": "http://patchwork.dpdk.org/series/1516/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/45382/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/45382/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 9739D1B3A1;\n\tWed, 26 Sep 2018 13:22:51 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 7AE3A1B1C6\n\tfor <dev@dpdk.org>; Wed, 26 Sep 2018 13:22:30 +0200 (CEST)",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t26 Sep 2018 04:22:28 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga006.jf.intel.com with ESMTP; 26 Sep 2018 04:22:24 -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\tw8QBMOZX011648; Wed, 26 Sep 2018 12:22:24 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8QBMOtA029278;\n\tWed, 26 Sep 2018 12:22:24 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8QBMOgg029273;\n\tWed, 26 Sep 2018 12:22:24 +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,306,1534834800\"; d=\"scan'208\";a=\"77407422\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Olivier Matz <olivier.matz@6wind.com>,\n\tAndrew Rybchenko <arybchenko@solarflare.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",
        "Date": "Wed, 26 Sep 2018 12:22:09 +0100",
        "Message-Id": "<e8ba3183892869b08f81a919b569cd25345333bc.1537960448.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1537960448.git.anatoly.burakov@intel.com>",
            "<cover.1537960448.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1537960448.git.anatoly.burakov@intel.com>",
            "<cover.1537546029.git.anatoly.burakov@intel.com>\n\t<cover.1537960448.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v5 10/21] malloc: add function to check if socket\n\tis external",
        "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": "An API is needed to check whether a particular socket ID belongs\nto an internal or external heap. Prime user of this would be\nmempool allocator, because normal assumptions of IOVA\ncontiguousness in IOVA as VA mode do not hold in case of\nexternally allocated memory.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/include/rte_malloc.h | 15 +++++++++++++\n lib/librte_eal/common/rte_malloc.c         | 25 ++++++++++++++++++++++\n lib/librte_eal/rte_eal_version.map         |  1 +\n lib/librte_mempool/rte_mempool.c           | 22 ++++++++++++++++---\n 4 files changed, 60 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 8870732a6..403271ddc 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -277,6 +277,21 @@ rte_malloc_get_socket_stats(int socket,\n int __rte_experimental\n rte_malloc_heap_get_socket(const char *name);\n \n+/**\n+ * Check if a given socket ID refers to externally allocated memory.\n+ *\n+ * @note Passing SOCKET_ID_ANY will return 0.\n+ *\n+ * @param socket_id\n+ *   Socket ID to check\n+ * @return\n+ *   1 if socket ID refers to externally allocated memory\n+ *   0 if socket ID refers to internal DPDK memory\n+ *   -1 if socket ID is invalid\n+ */\n+int __rte_experimental\n+rte_malloc_heap_socket_is_external(int socket_id);\n+\n /**\n  * Dump statistics.\n  *\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex b807dfe09..fa81d7862 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -220,6 +220,31 @@ rte_malloc_heap_get_socket(const char *name)\n \treturn ret;\n }\n \n+int\n+rte_malloc_heap_socket_is_external(int socket_id)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tunsigned int idx;\n+\tint ret = -1;\n+\n+\tif (socket_id == SOCKET_ID_ANY)\n+\t\treturn 0;\n+\n+\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n+\tfor (idx = 0; idx < RTE_MAX_HEAPS; idx++) {\n+\t\tstruct malloc_heap *tmp = &mcfg->malloc_heaps[idx];\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\tbreak;\n+\t\t}\n+\t}\n+\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n+\n+\treturn ret;\n+}\n+\n /*\n  * Print stats on memory type. If type is NULL, info on all types is printed\n  */\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex d8f9665b8..bd60506af 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -319,6 +319,7 @@ EXPERIMENTAL {\n \trte_log_register_type_and_pick_level;\n \trte_malloc_dump_heaps;\n \trte_malloc_heap_get_socket;\n+\trte_malloc_heap_socket_is_external;\n \trte_mem_alloc_validator_register;\n \trte_mem_alloc_validator_unregister;\n \trte_mem_event_callback_register;\ndiff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex 2ed539f01..683b216f9 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -428,12 +428,18 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \trte_iova_t iova;\n \tunsigned mz_id, n;\n \tint ret;\n-\tbool no_contig, try_contig, no_pageshift;\n+\tbool no_contig, try_contig, no_pageshift, external;\n \n \tret = mempool_ops_alloc_once(mp);\n \tif (ret != 0)\n \t\treturn ret;\n \n+\t/* check if we can retrieve a valid socket ID */\n+\tret = rte_malloc_heap_socket_is_external(mp->socket_id);\n+\tif (ret < 0)\n+\t\treturn -EINVAL;\n+\texternal = ret;\n+\n \t/* mempool must not be populated */\n \tif (mp->nb_mem_chunks != 0)\n \t\treturn -EEXIST;\n@@ -481,9 +487,19 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \t * in one contiguous chunk as well (otherwise we might end up wasting a\n \t * 1G page on a 10MB memzone). If we fail to get enough contiguous\n \t * memory, then we'll go and reserve space page-by-page.\n+\t *\n+\t * We also have to take into account the fact that memory that we're\n+\t * going to allocate from can belong to an externally allocated memory\n+\t * area, in which case the assumption of IOVA as VA mode being\n+\t * synonymous with IOVA contiguousness will not hold. We should also try\n+\t * to go for contiguous memory even if we're in no-huge mode, because\n+\t * external memory may in fact be IOVA-contiguous.\n \t */\n-\tno_pageshift = no_contig || rte_eal_iova_mode() == RTE_IOVA_VA;\n-\ttry_contig = !no_contig && !no_pageshift && rte_eal_has_hugepages();\n+\texternal = rte_malloc_heap_socket_is_external(mp->socket_id) == 1;\n+\tno_pageshift = no_contig ||\n+\t\t\t(!external && rte_eal_iova_mode() == RTE_IOVA_VA);\n+\ttry_contig = !no_contig && !no_pageshift &&\n+\t\t\t(rte_eal_has_hugepages() || external);\n \n \tif (no_pageshift) {\n \t\tpg_sz = 0;\n",
    "prefixes": [
        "v5",
        "10/21"
    ]
}