Skip to contentSkip to conversation

graph: dispatch mode improvements

PATCH Applied Christophe Fontaine 3 participants 6 messages Jul 23, 2025 – Oct 15, 2025

lore
Share & tools
lore
#0 lore raw

cover graph: dispatch mode improvements

Small series to improve dispatch mode for lib/graph.
In order to run an instance of the graph in a control thread (slow path defined as nodes) in addition to the datapath thread, we need:
- the ability to run graph_walk on an non-eal thread
- a signaling mechanism to wake up the control thread

Christophe

Christophe Fontaine (2):
graph: allow non EAL Thread for pipeline mode
graph: add callback in dispatch mode

 lib/graph/graph.c                          | 23 +++++++++++++++-------
 lib/graph/rte_graph.h                      | 14 +++++++++++++
 lib/graph/rte_graph_model_mcore_dispatch.c |  2 ++
 lib/graph/rte_graph_worker_common.h        |  2 ++
 4 files changed, 34 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.5
#1 lore raw

PATCH 1/2 graph: allow non EAL Thread for pipeline mode

rte_graph_model_mcore_dispatch_core_bind relied on rte_lcore_is_enabled.
Yet, "rte_lcore_is_enabled" only checks for EAL threads, which forbids external threads (NON EAL) to run a part of the graph.

Verify if the lcore role is not "ROLE_OFF", and return relevant error code otherwise.

---
 lib/graph/graph.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
lib/graph/graph.c +9 -4
index 0975bd8d49..146d0a12b4 100644
@@ -340,17 +340,22 @@ rte_graph_model_mcore_dispatch_core_bind(rte_graph_t id, int lcore)
 {
 	struct graph *graph;
 
-	if (graph_from_id(id) == NULL)
+	if (graph_from_id(id) == NULL) {
+		rte_errno = ENOENT;
 		goto fail;
-	if (!rte_lcore_is_enabled(lcore))
-		SET_ERR_JMP(ENOLINK, fail, "lcore %d not enabled", lcore);
+	}
+
+	if (rte_lcore_has_role(lcore, ROLE_OFF))
+		SET_ERR_JMP(ENOLINK, fail, "lcore %d is invalid", lcore);
 
 	STAILQ_FOREACH(graph, &graph_list, next)
 		if (graph->id == id)
 			break;
 
-	if (graph->graph->model != RTE_GRAPH_MODEL_MCORE_DISPATCH)
+	if (graph->graph->model != RTE_GRAPH_MODEL_MCORE_DISPATCH) {
+		rte_errno = EPERM;
 		goto fail;
+	}
 
 	graph->lcore_id = lcore;
 	graph->graph->dispatch.lcore_id = graph->lcore_id;
Signature · 1 line
2.43.5
#2 lore raw

PATCH 2/2 graph: add callback in dispatch mode

In reply to Christophe Fontaine

In dispatch mode, the assumption is that the graphs will be polled continuously: there is no way to know when packets are transferred from one graph to another.

Introduce a callback to be notified when packets are enqueue in the work
queue: this can be useful if we want to wake up a thread. This sleep/wake up mechanism is deferred to the application.

---
 lib/graph/graph.c                          | 10 +++++++---
 lib/graph/rte_graph.h                      | 14 ++++++++++++++
 lib/graph/rte_graph_model_mcore_dispatch.c |  2 ++
 lib/graph/rte_graph_worker_common.h        |  2 ++
 4 files changed, 25 insertions(+), 3 deletions(-)
lib/graph/graph.c +7 -3
index 146d0a12b4..61159edc72 100644
@@ -600,9 +600,13 @@ graph_clone(struct graph *parent_graph, const char *name, struct rte_graph_param
 	graph->graph->model = parent_graph->graph->model;
 
 	/* Create the graph schedule work queue */
-	if (rte_graph_worker_model_get(graph->graph) == RTE_GRAPH_MODEL_MCORE_DISPATCH &&
-	    graph_sched_wq_create(graph, parent_graph, prm))
-		goto graph_mem_destroy;
+	if (rte_graph_worker_model_get(graph->graph) == RTE_GRAPH_MODEL_MCORE_DISPATCH) {
+		if (graph_sched_wq_create(graph, parent_graph, prm))
+			goto graph_mem_destroy;
+
+		graph->graph->dispatch.notify_cb = prm->dispatch.notify_cb;
+		graph->graph->dispatch.cb_priv = prm->dispatch.cb_priv;
+	}
 
 	/* Call init() of the all the nodes in the graph */
 	if (graph_node_init(graph))
lib/graph/rte_graph.h +14 -0
index 097d0dc9d5..16b1dbac3f 100644
@@ -150,6 +150,18 @@ typedef void (*rte_node_fini_t)(const struct rte_graph *graph,
 typedef int (*rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last,
 	     void *cookie, const struct rte_graph_cluster_node_stats *stats);
 
+
+/**
+ * Graph dispatch enqueue notification callback.
+ *
+ * @param graph
+ *   Current graph
+ * @param cb_priv
+ *   Opaque argument given to the callback.
+ *
+ */
+typedef void (*packets_enqueued_cb)(struct rte_graph *graph, uint64_t priv);
+
 /**
  * Structure to hold configuration parameters for creating the graph.
  *
@@ -172,6 +184,8 @@ struct rte_graph_param {
 		struct {
 			uint32_t wq_size_max; /**< Maximum size of workqueue for dispatch model. */
 			uint32_t mp_capacity; /**< Capacity of memory pool for dispatch model. */
+			packets_enqueued_cb notify_cb;
+			uint64_t cb_priv;
 		} dispatch;
 	};
 };
lib/graph/rte_graph_model_mcore_dispatch.c +2 -0
index 70f0069bc1..706b5469f0 100644
@@ -102,6 +102,8 @@ __graph_sched_node_enqueue(struct rte_node *node, struct rte_graph *graph)
 	if (node->idx > 0)
 		goto submit_again;
 
+	if (graph->dispatch.notify_cb)
+		graph->dispatch.notify_cb(graph, graph->dispatch.cb_priv);
 	return true;
 
 fallback:
lib/graph/rte_graph_worker_common.h +2 -0
index aef0f65673..221deceaee 100644
@@ -68,6 +68,8 @@ struct __rte_cache_aligned rte_graph {
 			unsigned int lcore_id;  /**< The graph running Lcore. */
 			struct rte_ring *wq;    /**< The work-queue for pending streams. */
 			struct rte_mempool *mp; /**< The mempool for scheduling streams. */
+			packets_enqueued_cb notify_cb; /**< callback when a packet crosses lcores */
+			uint64_t cb_priv; /**< Opaque parameter for notify_cb */
 		} dispatch; /** Only used by dispatch model */
 	};
 	SLIST_ENTRY(rte_graph) next;   /* The next for rte_graph list */
Signature · 1 line
2.43.5
#3 lore raw
In reply to Christophe Fontaine

23/07/2025 18:49, Christophe Fontaine:

Quoted 5 lines

Small series to improve dispatch mode for lib/graph.
In order to run an instance of the graph in a control thread (slow path defined as nodes) in addition to the datapath thread, we need:
- the ability to run graph_walk on an non-eal thread
- a signaling mechanism to wake up the control thread

Should I expect a review before merging? Someone?

#4 lore raw
Quoted 24 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, September 24, 2025 7:49 PM
To: Christophe Fontaine <[email protected]>
Cc: Jerin Jacob <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Zhirun Yan <[email protected]>; [email protected]; Guvenc Gulce <[email protected]>
Subject: [EXTERNAL] Re: [PATCH 0/2] graph: dispatch mode improvements

23/07/2025 18: 49, Christophe Fontaine: > Small series to improve dispatch mode for lib/graph. > In order to run an instance of the graph in a control thread (slow path > defined as nodes) in addition to the datapath thread, we
need: ZjQcmQRYFpfptBannerStart Prioritize security for external emails:
Confirm sender and content safety before clicking links or opening attachments
<https://us-phishalarm-
ewt.proofpoint.com/EWT/v1/CRVmXkqW!s03Z1P80YjX6F8USVpU1pEPnEL9aBV CDmZhTUwMWrUFrDQFePMFjzqQsmmFOvE8V7-Hk$>
Report Suspicious

ZjQcmQRYFpfptBannerEnd
23/07/2025 18:49, Christophe Fontaine:

Quoted 7 lines
Quoted 5 lines

Small series to improve dispatch mode for lib/graph.
In order to run an instance of the graph in a control thread (slow path defined as nodes) in addition to the datapath thread, we need:
- the ability to run graph_walk on an non-eal thread
- a signaling mechanism to wake up the control thread

Should I expect a review before merging? Someone?

@Zhirun Yan The changes are for mcore dispatch, please review.

In general, changes looks good to me.

Quoted 1 line
#5 lore raw

24/09/2025 16:30, Jerin Jacob:

Quoted 11 lines

From: Thomas Monjalon <[email protected]>

Quoted 8 lines

23/07/2025 18:49, Christophe Fontaine:

Quoted 5 lines

Small series to improve dispatch mode for lib/graph.
In order to run an instance of the graph in a control thread (slow path defined as nodes) in addition to the datapath thread, we need:
- the ability to run graph_walk on an non-eal thread
- a signaling mechanism to wake up the control thread

Should I expect a review before merging? Someone?

@Zhirun Yan The changes are for mcore dispatch, please review.

No news after 3 weeks.

Quoted 1 line

In general, changes looks good to me.

Applied, thanks.