get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44274,
    "url": "http://patches.dpdk.org/api/patches/44274/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/2d926d5508a98457acf7a4b2b004284bdbd22097.1536072550.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": "<2d926d5508a98457acf7a4b2b004284bdbd22097.1536072550.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/2d926d5508a98457acf7a4b2b004284bdbd22097.1536072550.git.anatoly.burakov@intel.com",
    "date": "2018-09-04T15:02:00",
    "name": "[v2,7/9] mem: add external API to retrieve page fd from EAL",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f0c1f41e3f5fa4676d243333e81ca6d6fb0bc812",
    "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/2d926d5508a98457acf7a4b2b004284bdbd22097.1536072550.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1176,
            "url": "http://patches.dpdk.org/api/series/1176/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1176",
            "date": "2018-09-04T15:01:53",
            "name": "Improve running DPDK without hugetlbfs mounpoint",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/1176/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44274/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44274/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 429092B92;\n\tTue,  4 Sep 2018 17:05:30 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 8B83B11A4\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 17:05:28 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 08:05:27 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga005.jf.intel.com with ESMTP; 04 Sep 2018 08:02:04 -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\tw84F23I6020015; Tue, 4 Sep 2018 16:02:03 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84F23th008588;\n\tTue, 4 Sep 2018 16:02:03 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84F23do008584;\n\tTue, 4 Sep 2018 16:02:03 +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=\"254412953\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Bruce Richardson <bruce.richardson@intel.com>, tiwei.bie@intel.com,\n\tray.kinsella@intel.com, zhihong.wang@intel.com,\n\tmaxime.coquelin@redhat.com, kuralamudhan.ramakrishnan@intel.com",
        "Date": "Tue,  4 Sep 2018 16:02:00 +0100",
        "Message-Id": "<2d926d5508a98457acf7a4b2b004284bdbd22097.1536072550.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1536072550.git.anatoly.burakov@intel.com>",
            "<cover.1536072550.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1536072550.git.anatoly.burakov@intel.com>",
            "<cover.1535041359.git.anatoly.burakov@intel.com>\n\t<cover.1536072550.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v2 7/9] mem: add external API to retrieve page fd\n\tfrom EAL",
        "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": "Now that we can retrieve page fd's internally, we can expose it\nas an external API. This will add two flavors of API - thread-safe\nand non-thread-safe. Fix up internal API's to return values we need\nwithout modifying rte_errno internally if called from within EAL.\n\nWe do not want calling code to accidentally close an internal fd, so\nwe make a duplicate of it before we return it to the user. Caller is\ntherefore responsible for closing this fd.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal_memalloc.c   |  5 ++-\n lib/librte_eal/common/eal_common_memory.c  | 49 ++++++++++++++++++++++\n lib/librte_eal/common/eal_memalloc.h       |  2 +\n lib/librte_eal/common/include/rte_memory.h | 48 +++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_memalloc.c | 21 ++++++----\n lib/librte_eal/rte_eal_version.map         |  2 +\n 6 files changed, 118 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_memalloc.c b/lib/librte_eal/bsdapp/eal/eal_memalloc.c\nindex a5fb09f71..80e4c3d4f 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_memalloc.c\n@@ -4,6 +4,7 @@\n \n #include <inttypes.h>\n \n+#include <rte_errno.h>\n #include <rte_log.h>\n #include <rte_memory.h>\n \n@@ -50,13 +51,13 @@ eal_memalloc_sync_with_primary(void)\n int\n eal_memalloc_get_seg_fd(int list_idx, int seg_idx)\n {\n-\treturn -1;\n+\treturn -ENOTSUP;\n }\n \n int\n eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)\n {\n-\treturn -1;\n+\treturn -ENOTSUP;\n }\n \n int\ndiff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex 034c2026a..4a80deaf5 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -550,6 +550,55 @@ rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)\n \treturn ret;\n }\n \n+int __rte_experimental\n+rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tstruct rte_memseg_list *msl;\n+\tstruct rte_fbarray *arr;\n+\tint msl_idx, seg_idx, ret;\n+\n+\tif (ms == NULL) {\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\n+\tmsl = rte_mem_virt2memseg_list(ms->addr);\n+\tif (msl == NULL) {\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\tarr = &msl->memseg_arr;\n+\n+\tmsl_idx = msl - mcfg->memsegs;\n+\tseg_idx = rte_fbarray_find_idx(arr, ms);\n+\n+\tif (!rte_fbarray_is_used(arr, seg_idx)) {\n+\t\trte_errno = ENOENT;\n+\t\treturn -1;\n+\t}\n+\n+\tret = eal_memalloc_get_seg_fd(msl_idx, seg_idx);\n+\tif (ret < 0) {\n+\t\trte_errno = -ret;\n+\t\tret = -1;\n+\t}\n+\treturn ret;\n+}\n+\n+int __rte_experimental\n+rte_memseg_get_fd(const struct rte_memseg *ms)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tint ret;\n+\n+\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n+\tret = rte_memseg_get_fd_thread_unsafe(ms);\n+\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n+\n+\treturn ret;\n+}\n+\n /* init memory subsystem */\n int\n rte_eal_memory_init(void)\ndiff --git a/lib/librte_eal/common/eal_memalloc.h b/lib/librte_eal/common/eal_memalloc.h\nindex a46c69c72..70a214de4 100644\n--- a/lib/librte_eal/common/eal_memalloc.h\n+++ b/lib/librte_eal/common/eal_memalloc.h\n@@ -76,9 +76,11 @@ eal_memalloc_mem_alloc_validator_unregister(const char *name, int socket_id);\n int\n eal_memalloc_mem_alloc_validate(int socket_id, size_t new_len);\n \n+/* returns fd or -errno */\n int\n eal_memalloc_get_seg_fd(int list_idx, int seg_idx);\n \n+/* returns 0 or -errno */\n int\n eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd);\n \ndiff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h\nindex c4b7f4cff..0d2a30056 100644\n--- a/lib/librte_eal/common/include/rte_memory.h\n+++ b/lib/librte_eal/common/include/rte_memory.h\n@@ -317,6 +317,54 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg);\n int __rte_experimental\n rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg);\n \n+/**\n+ * Return file descriptor associated with a particular memseg (if available).\n+ *\n+ * @note This function read-locks the memory hotplug subsystem, and thus cannot\n+ *       be used within memory-related callback functions.\n+ *\n+ * @note This returns an internal file descriptor. Performing any operations on\n+ *       this file descriptor is inherently dangerous, so it should be treated\n+ *       as read-only for all intents and purposes.\n+ *\n+ * @param ms\n+ *   A pointer to memseg for which to get file descriptor.\n+ *\n+ * @return\n+ *   Valid file descriptor in case of success.\n+ *   -1 in case of error, with ``rte_errno`` set to the following values:\n+ *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg\n+ *     - ENODEV  - ``ms`` fd is not available\n+ *     - ENOENT  - ``ms`` is an unused segment\n+ *     - ENOTSUP - segment fd's are not supported\n+ */\n+int __rte_experimental\n+rte_memseg_get_fd(const struct rte_memseg *ms);\n+\n+/**\n+ * Return file descriptor associated with a particular memseg (if available).\n+ *\n+ * @note This function does not perform any locking, and is only safe to call\n+ *       from within memory-related callback functions.\n+ *\n+ * @note This returns an internal file descriptor. Performing any operations on\n+ *       this file descriptor is inherently dangerous, so it should be treated\n+ *       as read-only for all intents and purposes.\n+ *\n+ * @param ms\n+ *   A pointer to memseg for which to get file descriptor.\n+ *\n+ * @return\n+ *   Valid file descriptor in case of success.\n+ *   -1 in case of error, with ``rte_errno`` set to the following values:\n+ *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg\n+ *     - ENODEV  - ``ms`` fd is not available\n+ *     - ENOENT  - ``ms`` is an unused segment\n+ *     - ENOTSUP - segment fd's are not supported\n+ */\n+int __rte_experimental\n+rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms);\n+\n /**\n  * Dump the physical memory layout to a file.\n  *\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\nindex b820989e9..21f842753 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n@@ -34,6 +34,7 @@\n #include <rte_log.h>\n #include <rte_eal_memconfig.h>\n #include <rte_eal.h>\n+#include <rte_errno.h>\n #include <rte_memory.h>\n #include <rte_spinlock.h>\n \n@@ -1381,7 +1382,7 @@ eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)\n \t\tint len = mcfg->memsegs[list_idx].memseg_arr.len;\n \n \t\tif (alloc_list(list_idx, len) < 0)\n-\t\t\treturn -1;\n+\t\t\treturn -ENOMEM;\n \t}\n \tfd_list[list_idx].fds[seg_idx] = fd;\n \n@@ -1391,12 +1392,18 @@ eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)\n int\n eal_memalloc_get_seg_fd(int list_idx, int seg_idx)\n {\n-\tif (internal_config.single_file_segments)\n-\t\treturn fd_list[list_idx].memseg_list_fd;\n-\t/* list not initialized */\n-\tif (fd_list[list_idx].len == 0)\n-\t\treturn -1;\n-\treturn fd_list[list_idx].fds[seg_idx];\n+\tint fd;\n+\tif (internal_config.single_file_segments) {\n+\t\tfd = fd_list[list_idx].memseg_list_fd;\n+\t} else if (fd_list[list_idx].len == 0) {\n+\t\t/* list not initialized */\n+\t\tfd = -1;\n+\t} else {\n+\t\tfd = fd_list[list_idx].fds[seg_idx];\n+\t}\n+\tif (fd < 0)\n+\t\treturn -ENODEV;\n+\treturn fd;\n }\n \n int\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 344a43d32..e659e19d6 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -320,6 +320,8 @@ EXPERIMENTAL {\n \trte_mem_virt2memseg_list;\n \trte_memseg_contig_walk;\n \trte_memseg_contig_walk_thread_unsafe;\n+\trte_memseg_get_fd;\n+\trte_memseg_get_fd_thread_unsafe;\n \trte_memseg_list_walk;\n \trte_memseg_list_walk_thread_unsafe;\n \trte_memseg_walk;\n",
    "prefixes": [
        "v2",
        "7/9"
    ]
}