get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41005,
    "url": "http://patches.dpdk.org/api/patches/41005/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/3d7db240745dd4ebb6dc254530dc476588f5981b.1528796062.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": "<3d7db240745dd4ebb6dc254530dc476588f5981b.1528796062.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/3d7db240745dd4ebb6dc254530dc476588f5981b.1528796062.git.anatoly.burakov@intel.com",
    "date": "2018-06-12T09:46:16",
    "name": "[3/3] mem: provide thread-unsafe memseg list walk variant",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "5ea77655485281bd2ad17069652b85098739ba72",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "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/3d7db240745dd4ebb6dc254530dc476588f5981b.1528796062.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 92,
            "url": "http://patches.dpdk.org/api/series/92/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=92",
            "date": "2018-06-12T09:46:15",
            "name": "[1/3] mem: provide thread-unsafe contig walk variant",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/92/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41005/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/41005/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 04F311E4F0;\n\tTue, 12 Jun 2018 11:46:23 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id D89DE1E496\n\tfor <dev@dpdk.org>; Tue, 12 Jun 2018 11:46:20 +0200 (CEST)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Jun 2018 02:46:18 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga001.jf.intel.com with ESMTP; 12 Jun 2018 02:46:17 -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\tw5C9kGeM015123 for <dev@dpdk.org>; Tue, 12 Jun 2018 10:46:16 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w5C9kGdU021134\n\tfor <dev@dpdk.org>; Tue, 12 Jun 2018 10:46:16 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w5C9kGlH021130\n\tfor dev@dpdk.org; Tue, 12 Jun 2018 10:46:16 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,214,1526367600\"; d=\"scan'208\";a=\"63861001\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 12 Jun 2018 10:46:16 +0100",
        "Message-Id": "<3d7db240745dd4ebb6dc254530dc476588f5981b.1528796062.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<a033d2f5109529a159d85c58d7b101b5a6dadacf.1528796062.git.anatoly.burakov@intel.com>",
            "<a033d2f5109529a159d85c58d7b101b5a6dadacf.1528796062.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<a033d2f5109529a159d85c58d7b101b5a6dadacf.1528796062.git.anatoly.burakov@intel.com>",
            "<a033d2f5109529a159d85c58d7b101b5a6dadacf.1528796062.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH 3/3] mem: provide thread-unsafe memseg list walk\n\tvariant",
        "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": "Sometimes, user code needs to walk memseg list while being inside\na memory-related callback. Rather than making everyone copy around\nthe same iteration code and depending on DPDK internals, provide an\nofficial way to do memseg_list_walk() inside callbacks.\n\nAlso, remove existing reimplementation from memalloc code and use\nthe new API instead.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/eal_common_memory.c  | 29 +++++++++--------\n lib/librte_eal/common/include/rte_memory.h | 18 +++++++++++\n lib/librte_eal/linuxapp/eal/eal_memalloc.c | 37 +++++-----------------\n lib/librte_eal/rte_eal_version.map         |  1 +\n 4 files changed, 43 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex afe0d5b57..6c4a8d40b 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -883,14 +883,11 @@ rte_memseg_walk(rte_memseg_walk_t func, void *arg)\n }\n \n int __rte_experimental\n-rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)\n+rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tint i, ret = 0;\n \n-\t/* do not allow allocations/frees/init while we iterate */\n-\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n-\n \tfor (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) {\n \t\tstruct rte_memseg_list *msl = &mcfg->memsegs[i];\n \n@@ -898,17 +895,23 @@ rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)\n \t\t\tcontinue;\n \n \t\tret = func(msl, arg);\n-\t\tif (ret < 0) {\n-\t\t\tret = -1;\n-\t\t\tgoto out;\n-\t\t}\n-\t\tif (ret > 0) {\n-\t\t\tret = 1;\n-\t\t\tgoto out;\n-\t\t}\n+\t\tif (ret)\n+\t\t\treturn ret;\n \t}\n-out:\n+\treturn 0;\n+}\n+\n+int __rte_experimental\n+rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tint ret = 0;\n+\n+\t/* do not allow allocations/frees/init while we iterate */\n+\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n+\tret = rte_memseg_list_walk_thread_unsafe(func, arg);\n \trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n+\n \treturn ret;\n }\n \ndiff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h\nindex c5a84c333..c4b7f4cff 100644\n--- a/lib/librte_eal/common/include/rte_memory.h\n+++ b/lib/librte_eal/common/include/rte_memory.h\n@@ -299,6 +299,24 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg);\n int __rte_experimental\n rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg);\n \n+/**\n+ * Walk each allocated memseg list without performing any locking.\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+ * @param func\n+ *   Iterator function\n+ * @param arg\n+ *   Argument passed to iterator\n+ * @return\n+ *   0 if walked over the entire list\n+ *   1 if stopped by the user\n+ *   -1 if user function reported error\n+ */\n+int __rte_experimental\n+rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg);\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 8c11f98c9..1ebc4b571 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n@@ -171,32 +171,6 @@ get_file_size(int fd)\n \treturn st.st_size;\n }\n \n-/* we cannot use rte_memseg_list_walk() here because we will be holding a\n- * write lock whenever we enter every function in this file, however copying\n- * the same iteration code everywhere is not ideal as well. so, use a lockless\n- * copy of memseg list walk here.\n- */\n-static int\n-memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)\n-{\n-\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n-\tint i, ret = 0;\n-\n-\tfor (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) {\n-\t\tstruct rte_memseg_list *msl = &mcfg->memsegs[i];\n-\n-\t\tif (msl->base_va == NULL)\n-\t\t\tcontinue;\n-\n-\t\tret = func(msl, arg);\n-\t\tif (ret < 0)\n-\t\t\treturn -1;\n-\t\tif (ret > 0)\n-\t\t\treturn 1;\n-\t}\n-\treturn 0;\n-}\n-\n /* returns 1 on successful lock, 0 on unsuccessful lock, -1 on error */\n static int lock(int fd, int type)\n {\n@@ -878,7 +852,8 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,\n \twa.socket = socket;\n \twa.segs_allocated = 0;\n \n-\tret = memseg_list_walk_thread_unsafe(alloc_seg_walk, &wa);\n+\t/* memalloc is locked, so it's safe to use thread-unsafe version */\n+\tret = rte_memseg_list_walk_thread_unsafe(alloc_seg_walk, &wa);\n \tif (ret == 0) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): couldn't find suitable memseg_list\\n\",\n \t\t\t__func__);\n@@ -943,7 +918,10 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)\n \t\twa.ms = cur;\n \t\twa.hi = hi;\n \n-\t\twalk_res = memseg_list_walk_thread_unsafe(free_seg_walk, &wa);\n+\t\t/* memalloc is locked, so it's safe to use thread-unsafe version\n+\t\t */\n+\t\twalk_res = rte_memseg_list_walk_thread_unsafe(free_seg_walk,\n+\t\t\t\t&wa);\n \t\tif (walk_res == 1)\n \t\t\tcontinue;\n \t\tif (walk_res == 0)\n@@ -1230,7 +1208,8 @@ eal_memalloc_sync_with_primary(void)\n \tif (rte_eal_process_type() == RTE_PROC_PRIMARY)\n \t\treturn 0;\n \n-\tif (memseg_list_walk_thread_unsafe(sync_walk, NULL))\n+\t/* memalloc is locked, so it's safe to call thread-unsafe version */\n+\tif (rte_memseg_list_walk_thread_unsafe(sync_walk, NULL))\n \t\treturn -1;\n \treturn 0;\n }\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 72d32fc39..592ffb867 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -288,6 +288,7 @@ EXPERIMENTAL {\n \trte_memseg_contig_walk;\n \trte_memseg_contig_walk_thread_unsafe;\n \trte_memseg_list_walk;\n+\trte_memseg_list_walk_thread_unsafe;\n \trte_memseg_walk;\n \trte_memseg_walk_thread_unsafe;\n \trte_mp_action_register;\n",
    "prefixes": [
        "3/3"
    ]
}