[PATCH v10 03/16] graph: move node process into inline function
Zhirun Yan
zhirun.yan at intel.com
Thu Jun 8 11:57:46 CEST 2023
Node process is a single and reusable block, move the code into an inline
function.
Signed-off-by: Haiyue Wang <haiyue.wang at intel.com>
Signed-off-by: Cunming Liang <cunming.liang at intel.com>
Signed-off-by: Zhirun Yan <zhirun.yan at intel.com>
Acked-by: Jerin Jacob <jerinj at marvell.com>
---
lib/graph/rte_graph_model_rtc.h | 20 ++---------------
lib/graph/rte_graph_worker_common.h | 33 +++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/lib/graph/rte_graph_model_rtc.h b/lib/graph/rte_graph_model_rtc.h
index 10b359772f..4b6236e301 100644
--- a/lib/graph/rte_graph_model_rtc.h
+++ b/lib/graph/rte_graph_model_rtc.h
@@ -21,9 +21,6 @@ rte_graph_walk_rtc(struct rte_graph *graph)
const rte_node_t mask = graph->cir_mask;
uint32_t head = graph->head;
struct rte_node *node;
- uint64_t start;
- uint16_t rc;
- void **objs;
/*
* Walk on the source node(s) ((cir_start - head) -> cir_start) and then
@@ -42,21 +39,8 @@ rte_graph_walk_rtc(struct rte_graph *graph)
*/
while (likely(head != graph->tail)) {
node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
- RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
- objs = node->objs;
- rte_prefetch0(objs);
-
- if (rte_graph_has_stats_feature()) {
- start = rte_rdtsc();
- rc = node->process(graph, node, objs, node->idx);
- node->total_cycles += rte_rdtsc() - start;
- node->total_calls++;
- node->total_objs += rc;
- } else {
- node->process(graph, node, objs, node->idx);
- }
- node->idx = 0;
- head = likely((int32_t)head > 0) ? head & mask : head;
+ __rte_node_process(graph, node);
+ head = likely((int32_t)head > 0) ? head & mask : head;
}
graph->tail = 0;
}
diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index b58f8f6947..41428974db 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -130,6 +130,39 @@ void __rte_node_stream_alloc_size(struct rte_graph *graph,
/* Fast path helper functions */
+/**
+ * @internal
+ *
+ * Enqueue a given node to the tail of the graph reel.
+ *
+ * @param graph
+ * Pointer Graph object.
+ * @param node
+ * Pointer to node object to be enqueued.
+ */
+static __rte_always_inline void
+__rte_node_process(struct rte_graph *graph, struct rte_node *node)
+{
+ uint64_t start;
+ uint16_t rc;
+ void **objs;
+
+ RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
+ objs = node->objs;
+ rte_prefetch0(objs);
+
+ if (rte_graph_has_stats_feature()) {
+ start = rte_rdtsc();
+ rc = node->process(graph, node, objs, node->idx);
+ node->total_cycles += rte_rdtsc() - start;
+ node->total_calls++;
+ node->total_objs += rc;
+ } else {
+ node->process(graph, node, objs, node->idx);
+ }
+ node->idx = 0;
+}
+
/**
* @internal
*
--
2.37.2
More information about the dev
mailing list