Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/128491/?format=api
http://patches.dpdk.org/api/patches/128491/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230609191245.252521-11-zhirun.yan@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": "<20230609191245.252521-11-zhirun.yan@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230609191245.252521-11-zhirun.yan@intel.com", "date": "2023-06-09T19:12:39", "name": "[v12,10/16] graph: introduce stream moving cross cores", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "7700fd4dfa0960778767a9e13765183b1f961849", "submitter": { "id": 1154, "url": "http://patches.dpdk.org/api/people/1154/?format=api", "name": "Yan, Zhirun", "email": "zhirun.yan@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/20230609191245.252521-11-zhirun.yan@intel.com/mbox/", "series": [ { "id": 28444, "url": "http://patches.dpdk.org/api/series/28444/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28444", "date": "2023-06-09T19:12:29", "name": "graph enhancement for multi-core dispatch", "version": 12, "mbox": "http://patches.dpdk.org/series/28444/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/128491/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/128491/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 10E2542C71;\n\tFri, 9 Jun 2023 21:21:08 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0BF7742D5E;\n\tFri, 9 Jun 2023 21:20:21 +0200 (CEST)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n by mails.dpdk.org (Postfix) with ESMTP id D3B3342D5D\n for <dev@dpdk.org>; Fri, 9 Jun 2023 21:20:18 +0200 (CEST)", "from fmsmga006.fm.intel.com ([10.253.24.20])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 09 Jun 2023 12:20:18 -0700", "from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94])\n by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2023 12:20:15 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1686338418; x=1717874418;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=LEUCKUP7up/Uc/vD00veRF3W1Nw0GJubk4khQlc5XI4=;\n b=ALKY8x5LSSXeUkjZxFRp5sEPxTv9HhjMYQs140jrEPFYEqVXgtDCzqXe\n MJyvRYXSRVT1kzlHgPxu1NmSWw9SVCDyfxSb/lDHMGfjWbtz4+etxVNpe\n ugrOj7AS62061zuULChwxrwkY9rb7wlNkLb3NFzvx30sOsPTvW6RO/z4W\n UR6Vw+BlUaiqRRWjJh3b1xA2OsmEiKtJ+/UiiYuvhGDFVTLqx6Hi1kM4U\n E//X2QSms2zF2n6J1v7y9K7AJV6STARWs9APhUe6jmU+LemGCyzSktJKv\n AAc+7wQaqphIYr5OaGqJuRo5QDV+hkfePr8jU3H1vQKCK7fmv7HWw1s6e w==;", "X-IronPort-AV": [ "E=McAfee;i=\"6600,9927,10736\"; a=\"360155072\"", "E=Sophos;i=\"6.00,230,1681196400\"; d=\"scan'208\";a=\"360155072\"", "E=McAfee;i=\"6600,9927,10736\"; a=\"957254680\"", "E=Sophos;i=\"6.00,230,1681196400\"; d=\"scan'208\";a=\"957254680\"" ], "X-ExtLoop1": "1", "From": "Zhirun Yan <zhirun.yan@intel.com>", "To": "dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com,\n ndabilpuram@marvell.com, stephen@networkplumber.org,\n pbhagavatula@marvell.com, jerinjacobk@gmail.com, david.marchand@redhat.com", "Cc": "cunming.liang@intel.com, haiyue.wang@intel.com,\n mattias.ronnblom@ericsson.com, Zhirun Yan <zhirun.yan@intel.com>", "Subject": "[PATCH v12 10/16] graph: introduce stream moving cross cores", "Date": "Sat, 10 Jun 2023 03:12:39 +0800", "Message-Id": "<20230609191245.252521-11-zhirun.yan@intel.com>", "X-Mailer": "git-send-email 2.37.2", "In-Reply-To": "<20230609191245.252521-1-zhirun.yan@intel.com>", "References": "<20230608151844.1823783-1-zhirun.yan@intel.com>\n <20230609191245.252521-1-zhirun.yan@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "This patch introduces key functions to allow a worker thread to\nenable enqueue and move streams of objects to the next nodes over\ndifferent cores for mcore dispatch model.\n\nSigned-off-by: Haiyue Wang <haiyue.wang@intel.com>\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\nSigned-off-by: Zhirun Yan <zhirun.yan@intel.com>\nAcked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>\n---\n lib/graph/graph.c | 6 +-\n lib/graph/graph_private.h | 31 ++++\n lib/graph/meson.build | 2 +-\n lib/graph/rte_graph.h | 15 +-\n lib/graph/rte_graph_model_mcore_dispatch.c | 158 +++++++++++++++++++++\n lib/graph/rte_graph_model_mcore_dispatch.h | 45 ++++++\n lib/graph/version.map | 3 +\n 7 files changed, 255 insertions(+), 5 deletions(-)", "diff": "diff --git a/lib/graph/graph.c b/lib/graph/graph.c\nindex 968cbbf86c..41251e3435 100644\n--- a/lib/graph/graph.c\n+++ b/lib/graph/graph.c\n@@ -473,7 +473,7 @@ rte_graph_destroy(rte_graph_t id)\n }\n \n static rte_graph_t\n-graph_clone(struct graph *parent_graph, const char *name)\n+graph_clone(struct graph *parent_graph, const char *name, struct rte_graph_param *prm)\n {\n \tstruct graph_node *graph_node;\n \tstruct graph *graph;\n@@ -547,14 +547,14 @@ graph_clone(struct graph *parent_graph, const char *name)\n }\n \n rte_graph_t\n-rte_graph_clone(rte_graph_t id, const char *name)\n+rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm)\n {\n \tstruct graph *graph;\n \n \tGRAPH_ID_CHECK(id);\n \tSTAILQ_FOREACH(graph, &graph_list, next)\n \t\tif (graph->id == id)\n-\t\t\treturn graph_clone(graph, name);\n+\t\t\treturn graph_clone(graph, name, prm);\n \n fail:\n \treturn RTE_GRAPH_ID_INVALID;\ndiff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h\nindex d84174b667..d0ef13b205 100644\n--- a/lib/graph/graph_private.h\n+++ b/lib/graph/graph_private.h\n@@ -414,4 +414,35 @@ void graph_dump(FILE *f, struct graph *g);\n */\n void node_dump(FILE *f, struct node *n);\n \n+/**\n+ * @internal\n+ *\n+ * Create the graph schedule work queue for mcore dispatch model.\n+ * All cloned graphs attached to the parent graph MUST be destroyed together\n+ * for fast schedule design limitation.\n+ *\n+ * @param _graph\n+ * The graph object\n+ * @param _parent_graph\n+ * The parent graph object which holds the run-queue head.\n+ * @param prm\n+ * Graph parameter, includes model-specific parameters in this graph.\n+ *\n+ * @return\n+ * - 0: Success.\n+ * - <0: Graph schedule work queue related error.\n+ */\n+int graph_sched_wq_create(struct graph *_graph, struct graph *_parent_graph,\n+\t\t\t struct rte_graph_param *prm);\n+\n+/**\n+ * @internal\n+ *\n+ * Destroy the graph schedule work queue for mcore dispatch model.\n+ *\n+ * @param _graph\n+ * The graph object\n+ */\n+void graph_sched_wq_destroy(struct graph *_graph);\n+\n #endif /* _RTE_GRAPH_PRIVATE_H_ */\ndiff --git a/lib/graph/meson.build b/lib/graph/meson.build\nindex 0685cf9e72..9d51eabe33 100644\n--- a/lib/graph/meson.build\n+++ b/lib/graph/meson.build\n@@ -20,4 +20,4 @@ sources = files(\n )\n headers = files('rte_graph.h', 'rte_graph_worker.h')\n \n-deps += ['eal', 'pcapng']\n+deps += ['eal', 'pcapng', 'mempool', 'ring']\ndiff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h\nindex 998cade200..2ffee520b1 100644\n--- a/lib/graph/rte_graph.h\n+++ b/lib/graph/rte_graph.h\n@@ -169,6 +169,17 @@ struct rte_graph_param {\n \tbool pcap_enable; /**< Pcap enable. */\n \tuint64_t num_pkt_to_capture; /**< Number of packets to capture. */\n \tchar *pcap_filename; /**< Filename in which packets to be captured.*/\n+\n+\tRTE_STD_C11\n+\tunion {\n+\t\tstruct {\n+\t\t\tuint64_t rsvd; /**< Reserved for rtc model. */\n+\t\t} rtc;\n+\t\tstruct {\n+\t\t\tuint32_t wq_size_max; /**< Maximum size of workqueue for dispatch model. */\n+\t\t\tuint32_t mp_capacity; /**< Capacity of memory pool for dispatch model. */\n+\t\t} dispatch;\n+\t};\n };\n \n /**\n@@ -260,12 +271,14 @@ int rte_graph_destroy(rte_graph_t id);\n * Name of the new graph. The library prepends the parent graph name to the\n * user-specified name. The final graph name will be,\n * \"parent graph name\" + \"-\" + name.\n+ * @param prm\n+ * Graph parameter, includes model-specific parameters in this graph.\n *\n * @return\n * Valid graph id on success, RTE_GRAPH_ID_INVALID otherwise.\n */\n __rte_experimental\n-rte_graph_t rte_graph_clone(rte_graph_t id, const char *name);\n+rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm);\n \n /**\n * Get graph id from graph name.\ndiff --git a/lib/graph/rte_graph_model_mcore_dispatch.c b/lib/graph/rte_graph_model_mcore_dispatch.c\nindex 9df2479a10..8f4bc860ab 100644\n--- a/lib/graph/rte_graph_model_mcore_dispatch.c\n+++ b/lib/graph/rte_graph_model_mcore_dispatch.c\n@@ -5,6 +5,164 @@\n #include \"graph_private.h\"\n #include \"rte_graph_model_mcore_dispatch.h\"\n \n+int\n+graph_sched_wq_create(struct graph *_graph, struct graph *_parent_graph,\n+\t\t struct rte_graph_param *prm)\n+{\n+\tstruct rte_graph *parent_graph = _parent_graph->graph;\n+\tstruct rte_graph *graph = _graph->graph;\n+\tunsigned int wq_size;\n+\tunsigned int flags = RING_F_SC_DEQ;\n+\n+\twq_size = GRAPH_SCHED_WQ_SIZE(graph->nb_nodes);\n+\twq_size = rte_align32pow2(wq_size + 1);\n+\n+\tif (prm->dispatch.wq_size_max > 0)\n+\t\twq_size = wq_size <= (prm->dispatch.wq_size_max) ? wq_size :\n+\t\t\tprm->dispatch.wq_size_max;\n+\n+\tif (!rte_is_power_of_2(wq_size))\n+\t\tflags |= RING_F_EXACT_SZ;\n+\n+\tgraph->dispatch.wq = rte_ring_create(graph->name, wq_size, graph->socket,\n+\t\t\t\t\t flags);\n+\tif (graph->dispatch.wq == NULL)\n+\t\tSET_ERR_JMP(EIO, fail, \"Failed to allocate graph WQ\");\n+\n+\tif (prm->dispatch.mp_capacity > 0)\n+\t\twq_size = (wq_size <= prm->dispatch.mp_capacity) ? wq_size :\n+\t\t\tprm->dispatch.mp_capacity;\n+\n+\tgraph->dispatch.mp = rte_mempool_create(graph->name, wq_size,\n+\t\t\t\t\t\tsizeof(struct graph_mcore_dispatch_wq_node),\n+\t\t\t\t\t\t0, 0, NULL, NULL, NULL, NULL,\n+\t\t\t\t\t\tgraph->socket, MEMPOOL_F_SP_PUT);\n+\tif (graph->dispatch.mp == NULL)\n+\t\tSET_ERR_JMP(EIO, fail_mp,\n+\t\t\t \"Failed to allocate graph WQ schedule entry\");\n+\n+\tgraph->dispatch.lcore_id = _graph->lcore_id;\n+\n+\tif (parent_graph->dispatch.rq == NULL) {\n+\t\tparent_graph->dispatch.rq = &parent_graph->dispatch.rq_head;\n+\t\tSLIST_INIT(parent_graph->dispatch.rq);\n+\t}\n+\n+\tgraph->dispatch.rq = parent_graph->dispatch.rq;\n+\tSLIST_INSERT_HEAD(graph->dispatch.rq, graph, next);\n+\n+\treturn 0;\n+\n+fail_mp:\n+\trte_ring_free(graph->dispatch.wq);\n+\tgraph->dispatch.wq = NULL;\n+fail:\n+\treturn -rte_errno;\n+}\n+\n+void\n+graph_sched_wq_destroy(struct graph *_graph)\n+{\n+\tstruct rte_graph *graph = _graph->graph;\n+\n+\tif (graph == NULL)\n+\t\treturn;\n+\n+\trte_ring_free(graph->dispatch.wq);\n+\tgraph->dispatch.wq = NULL;\n+\n+\trte_mempool_free(graph->dispatch.mp);\n+\tgraph->dispatch.mp = NULL;\n+}\n+\n+static __rte_always_inline bool\n+__graph_sched_node_enqueue(struct rte_node *node, struct rte_graph *graph)\n+{\n+\tstruct graph_mcore_dispatch_wq_node *wq_node;\n+\tuint16_t off = 0;\n+\tuint16_t size;\n+\n+submit_again:\n+\tif (rte_mempool_get(graph->dispatch.mp, (void **)&wq_node) < 0)\n+\t\tgoto fallback;\n+\n+\tsize = RTE_MIN(node->idx, RTE_DIM(wq_node->objs));\n+\twq_node->node_off = node->off;\n+\twq_node->nb_objs = size;\n+\trte_memcpy(wq_node->objs, &node->objs[off], size * sizeof(void *));\n+\n+\twhile (rte_ring_mp_enqueue_bulk_elem(graph->dispatch.wq, (void *)&wq_node,\n+\t\t\t\t\t sizeof(wq_node), 1, NULL) == 0)\n+\t\trte_pause();\n+\n+\toff += size;\n+\tnode->idx -= size;\n+\tif (node->idx > 0)\n+\t\tgoto submit_again;\n+\n+\treturn true;\n+\n+fallback:\n+\tif (off != 0)\n+\t\tmemmove(&node->objs[0], &node->objs[off],\n+\t\t\tnode->idx * sizeof(void *));\n+\n+\treturn false;\n+}\n+\n+bool __rte_noinline\n+__rte_graph_mcore_dispatch_sched_node_enqueue(struct rte_node *node,\n+\t\t\t\t\t struct rte_graph_rq_head *rq)\n+{\n+\tconst unsigned int lcore_id = node->dispatch.lcore_id;\n+\tstruct rte_graph *graph;\n+\n+\tSLIST_FOREACH(graph, rq, next)\n+\t\tif (graph->dispatch.lcore_id == lcore_id)\n+\t\t\tbreak;\n+\n+\treturn graph != NULL ? __graph_sched_node_enqueue(node, graph) : false;\n+}\n+\n+void\n+__rte_graph_mcore_dispatch_sched_wq_process(struct rte_graph *graph)\n+{\n+#define WQ_SZ 32\n+\tstruct graph_mcore_dispatch_wq_node *wq_node;\n+\tstruct rte_mempool *mp = graph->dispatch.mp;\n+\tstruct rte_ring *wq = graph->dispatch.wq;\n+\tuint16_t idx, free_space;\n+\tstruct rte_node *node;\n+\tunsigned int i, n;\n+\tstruct graph_mcore_dispatch_wq_node *wq_nodes[WQ_SZ];\n+\n+\tn = rte_ring_sc_dequeue_burst_elem(wq, wq_nodes, sizeof(wq_nodes[0]),\n+\t\t\t\t\t RTE_DIM(wq_nodes), NULL);\n+\tif (n == 0)\n+\t\treturn;\n+\n+\tfor (i = 0; i < n; i++) {\n+\t\twq_node = wq_nodes[i];\n+\t\tnode = RTE_PTR_ADD(graph, wq_node->node_off);\n+\t\tRTE_ASSERT(node->fence == RTE_GRAPH_FENCE);\n+\t\tidx = node->idx;\n+\t\tfree_space = node->size - idx;\n+\n+\t\tif (unlikely(free_space < wq_node->nb_objs))\n+\t\t\t__rte_node_stream_alloc_size(graph, node, node->size + wq_node->nb_objs);\n+\n+\t\tmemmove(&node->objs[idx], wq_node->objs, wq_node->nb_objs * sizeof(void *));\n+\t\tnode->idx = idx + wq_node->nb_objs;\n+\n+\t\t__rte_node_process(graph, node);\n+\n+\t\twq_node->nb_objs = 0;\n+\t\tnode->idx = 0;\n+\t}\n+\n+\trte_mempool_put_bulk(mp, (void **)wq_nodes, n);\n+}\n+\n int\n rte_graph_model_mcore_dispatch_node_lcore_affinity_set(const char *name, unsigned int lcore_id)\n {\ndiff --git a/lib/graph/rte_graph_model_mcore_dispatch.h b/lib/graph/rte_graph_model_mcore_dispatch.h\nindex 7da0483d13..6163f96c37 100644\n--- a/lib/graph/rte_graph_model_mcore_dispatch.h\n+++ b/lib/graph/rte_graph_model_mcore_dispatch.h\n@@ -20,8 +20,53 @@\n extern \"C\" {\n #endif\n \n+#include <rte_errno.h>\n+#include <rte_mempool.h>\n+#include <rte_memzone.h>\n+#include <rte_ring.h>\n+\n #include \"rte_graph_worker_common.h\"\n \n+#define GRAPH_SCHED_WQ_SIZE_MULTIPLIER 8\n+#define GRAPH_SCHED_WQ_SIZE(nb_nodes) \\\n+\t((typeof(nb_nodes))((nb_nodes) * GRAPH_SCHED_WQ_SIZE_MULTIPLIER))\n+\n+/**\n+ * @internal\n+ *\n+ * Schedule the node to the right graph's work queue for mcore dispatch model.\n+ *\n+ * @param node\n+ * Pointer to the scheduled node object.\n+ * @param rq\n+ * Pointer to the scheduled run-queue for all graphs.\n+ *\n+ * @return\n+ * True on success, false otherwise.\n+ *\n+ * @note\n+ * This implementation is used by mcore dispatch model only and user application\n+ * should not call it directly.\n+ */\n+__rte_experimental\n+bool __rte_noinline __rte_graph_mcore_dispatch_sched_node_enqueue(struct rte_node *node,\n+\t\t\t\t\t\t\t\t struct rte_graph_rq_head *rq);\n+\n+/**\n+ * @internal\n+ *\n+ * Process all nodes (streams) in the graph's work queue for mcore dispatch model.\n+ *\n+ * @param graph\n+ * Pointer to the graph object.\n+ *\n+ * @note\n+ * This implementation is used by mcore dispatch model only and user application\n+ * should not call it directly.\n+ */\n+__rte_experimental\n+void __rte_graph_mcore_dispatch_sched_wq_process(struct rte_graph *graph);\n+\n /**\n * Set lcore affinity with the node used for mcore dispatch model.\n *\ndiff --git a/lib/graph/version.map b/lib/graph/version.map\nindex 9e92b54ffa..7e985d6308 100644\n--- a/lib/graph/version.map\n+++ b/lib/graph/version.map\n@@ -1,6 +1,9 @@\n EXPERIMENTAL {\n \tglobal:\n \n+\t__rte_graph_mcore_dispatch_sched_node_enqueue;\n+\t__rte_graph_mcore_dispatch_sched_wq_process;\n+\n \t__rte_node_register;\n \t__rte_node_stream_alloc;\n \t__rte_node_stream_alloc_size;\n", "prefixes": [ "v12", "10/16" ] }{ "id": 128491, "url": "