* [PATCH 0/2] graph: dispatch mode improvements
@ 2025-07-23 16:49 Christophe Fontaine
2025-07-23 16:50 ` [PATCH 1/2] graph: allow non EAL Thread for pipeline mode Christophe Fontaine
2025-07-23 16:50 ` [PATCH 2/2] graph: add callback in dispatch mode Christophe Fontaine
0 siblings, 2 replies; 3+ messages in thread
From: Christophe Fontaine @ 2025-07-23 16:49 UTC (permalink / raw)
To: Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram, Zhirun Yan
Cc: dev, 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:
- 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(-)
--
2.43.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] graph: allow non EAL Thread for pipeline mode
2025-07-23 16:49 [PATCH 0/2] graph: dispatch mode improvements Christophe Fontaine
@ 2025-07-23 16:50 ` Christophe Fontaine
2025-07-23 16:50 ` [PATCH 2/2] graph: add callback in dispatch mode Christophe Fontaine
1 sibling, 0 replies; 3+ messages in thread
From: Christophe Fontaine @ 2025-07-23 16:50 UTC (permalink / raw)
To: Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram, Zhirun Yan
Cc: dev, Christophe Fontaine
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.
Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
---
lib/graph/graph.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index 0975bd8d49..146d0a12b4 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -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;
--
2.43.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] graph: add callback in dispatch mode
2025-07-23 16:49 [PATCH 0/2] graph: dispatch mode improvements Christophe Fontaine
2025-07-23 16:50 ` [PATCH 1/2] graph: allow non EAL Thread for pipeline mode Christophe Fontaine
@ 2025-07-23 16:50 ` Christophe Fontaine
1 sibling, 0 replies; 3+ messages in thread
From: Christophe Fontaine @ 2025-07-23 16:50 UTC (permalink / raw)
To: Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram, Zhirun Yan
Cc: dev, 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.
Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
---
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(-)
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index 146d0a12b4..61159edc72 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -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))
diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h
index 097d0dc9d5..16b1dbac3f 100644
--- a/lib/graph/rte_graph.h
+++ b/lib/graph/rte_graph.h
@@ -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;
};
};
diff --git a/lib/graph/rte_graph_model_mcore_dispatch.c b/lib/graph/rte_graph_model_mcore_dispatch.c
index 70f0069bc1..706b5469f0 100644
--- a/lib/graph/rte_graph_model_mcore_dispatch.c
+++ b/lib/graph/rte_graph_model_mcore_dispatch.c
@@ -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:
diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index aef0f65673..221deceaee 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -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 */
--
2.43.5
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-23 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-23 16:49 [PATCH 0/2] graph: dispatch mode improvements Christophe Fontaine
2025-07-23 16:50 ` [PATCH 1/2] graph: allow non EAL Thread for pipeline mode Christophe Fontaine
2025-07-23 16:50 ` [PATCH 2/2] graph: add callback in dispatch mode Christophe Fontaine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).