Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/41004/?format=api
http://patches.dpdk.org/api/patches/41004/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/311a48e50a626b7a6e8a80b0da79e6c725b79b52.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": "<311a48e50a626b7a6e8a80b0da79e6c725b79b52.1528796062.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/311a48e50a626b7a6e8a80b0da79e6c725b79b52.1528796062.git.anatoly.burakov@intel.com", "date": "2018-06-12T09:46:15", "name": "[2/3] mem: provide thread-unsafe memseg walk variant", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "ebad66ae20d75a7c0956a7a07d7aa590da34b0c2", "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/311a48e50a626b7a6e8a80b0da79e6c725b79b52.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/41004/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/41004/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 EDF281E4BA;\n\tTue, 12 Jun 2018 11:46:20 +0200 (CEST)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id B9B411E495\n\tfor <dev@dpdk.org>; Tue, 12 Jun 2018 11:46:19 +0200 (CEST)", "from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Jun 2018 02:46:17 -0700", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga007.fm.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\tw5C9kG4s015120 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 w5C9kG60021127\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 w5C9kGui021123\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=\"46478797\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Date": "Tue, 12 Jun 2018 10:46:15 +0100", "Message-Id": "<311a48e50a626b7a6e8a80b0da79e6c725b79b52.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 2/3] mem: provide thread-unsafe memseg 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_walk() inside callbacks.\n\nAlso, remove existing reimplementation from sPAPR VFIO 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 | 28 ++++++++------\n lib/librte_eal/common/include/rte_memory.h | 18 +++++++++\n lib/librte_eal/linuxapp/eal/eal_vfio.c | 43 +++-------------------\n lib/librte_eal/rte_eal_version.map | 1 +\n 4 files changed, 40 insertions(+), 50 deletions(-)", "diff": "diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex e3320a746..afe0d5b57 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -841,14 +841,11 @@ rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)\n }\n \n int __rte_experimental\n-rte_memseg_walk(rte_memseg_walk_t func, void *arg)\n+rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tint i, ms_idx, 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 \t\tconst struct rte_memseg *ms;\n@@ -863,18 +860,25 @@ rte_memseg_walk(rte_memseg_walk_t func, void *arg)\n \t\twhile (ms_idx >= 0) {\n \t\t\tms = rte_fbarray_get(arr, ms_idx);\n \t\t\tret = func(msl, ms, arg);\n-\t\t\tif (ret < 0) {\n-\t\t\t\tret = -1;\n-\t\t\t\tgoto out;\n-\t\t\t} else if (ret > 0) {\n-\t\t\t\tret = 1;\n-\t\t\t\tgoto out;\n-\t\t\t}\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n \t\t\tms_idx = rte_fbarray_find_next_used(arr, ms_idx + 1);\n \t\t}\n \t}\n-out:\n+\treturn 0;\n+}\n+\n+int __rte_experimental\n+rte_memseg_walk(rte_memseg_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_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 aeba38bfa..c5a84c333 100644\n--- a/lib/librte_eal/common/include/rte_memory.h\n+++ b/lib/librte_eal/common/include/rte_memory.h\n@@ -263,6 +263,24 @@ rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg);\n int __rte_experimental\n rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg);\n \n+/**\n+ * Walk list of all memsegs 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_walk_thread_unsafe(rte_memseg_walk_t func, void *arg);\n+\n /**\n * Walk each VA-contiguous area without performing any locking.\n *\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex a2bbdfbf4..14c9332e9 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -87,42 +87,6 @@ static const struct vfio_iommu_type iommu_types[] = {\n \t},\n };\n \n-/* for sPAPR IOMMU, we will need to walk memseg list, but we cannot use\n- * rte_memseg_walk() because by the time we enter callback we will be holding a\n- * write lock, so regular rte-memseg_walk will deadlock. copying the same\n- * iteration code everywhere is not ideal as well. so, use a lockless copy of\n- * memseg walk here.\n- */\n-static int\n-memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)\n-{\n-\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n-\tint i, ms_idx, ret = 0;\n-\n-\tfor (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) {\n-\t\tstruct rte_memseg_list *msl = &mcfg->memsegs[i];\n-\t\tconst struct rte_memseg *ms;\n-\t\tstruct rte_fbarray *arr;\n-\n-\t\tif (msl->memseg_arr.count == 0)\n-\t\t\tcontinue;\n-\n-\t\tarr = &msl->memseg_arr;\n-\n-\t\tms_idx = rte_fbarray_find_next_used(arr, 0);\n-\t\twhile (ms_idx >= 0) {\n-\t\t\tms = rte_fbarray_get(arr, ms_idx);\n-\t\t\tret = func(msl, ms, arg);\n-\t\t\tif (ret < 0)\n-\t\t\t\treturn -1;\n-\t\t\tif (ret > 0)\n-\t\t\t\treturn 1;\n-\t\t\tms_idx = rte_fbarray_find_next_used(arr, ms_idx + 1);\n-\t\t}\n-\t}\n-\treturn 0;\n-}\n-\n static int\n is_null_map(const struct user_mem_map *map)\n {\n@@ -1357,7 +1321,8 @@ vfio_spapr_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,\n \t/* check if window size needs to be adjusted */\n \tmemset(¶m, 0, sizeof(param));\n \n-\tif (memseg_walk_thread_unsafe(vfio_spapr_window_size_walk,\n+\t/* we're inside a callback so use thread-unsafe version */\n+\tif (rte_memseg_walk_thread_unsafe(vfio_spapr_window_size_walk,\n \t\t\t\t¶m) < 0) {\n \t\tRTE_LOG(ERR, EAL, \"Could not get window size\\n\");\n \t\tret = -1;\n@@ -1386,7 +1351,9 @@ vfio_spapr_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,\n \t\t\t\tret = -1;\n \t\t\t\tgoto out;\n \t\t\t}\n-\t\t\tif (memseg_walk_thread_unsafe(vfio_spapr_map_walk,\n+\t\t\t/* we're inside a callback, so use thread-unsafe version\n+\t\t\t */\n+\t\t\tif (rte_memseg_walk_thread_unsafe(vfio_spapr_map_walk,\n \t\t\t\t\t&vfio_container_fd) < 0) {\n \t\t\t\tRTE_LOG(ERR, EAL, \"Could not recreate DMA maps\\n\");\n \t\t\t\tret = -1;\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 98bfbe796..72d32fc39 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -289,6 +289,7 @@ EXPERIMENTAL {\n \trte_memseg_contig_walk_thread_unsafe;\n \trte_memseg_list_walk;\n \trte_memseg_walk;\n+\trte_memseg_walk_thread_unsafe;\n \trte_mp_action_register;\n \trte_mp_action_unregister;\n \trte_mp_reply;\n", "prefixes": [ "2/3" ] }{ "id": 41004, "url": "