From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Jerin Jacob <jerinj@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Zhirun Yan <yanzhirun_163@163.com>
Subject: [PATCH dpdk 2/2] graph: allow enabling/disabling node visit cycles collection
Date: Tue, 9 Dec 2025 09:50:31 +0100 [thread overview]
Message-ID: <20251209085028.115203-6-rjarry@redhat.com> (raw)
In-Reply-To: <20251209085028.115203-4-rjarry@redhat.com>
Add a new rte_graph_cycle_stats_enable() function to control whether
rte_rdtsc() is called twice for each node visit in order to collect the
number of cycles spent in each node process callback.
The default value remains the same as before and is fixed by the compile
time value RTE_LIBRTE_GRAPH_STATS.
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
lib/graph/graph_populate.c | 1 +
lib/graph/rte_graph_worker_common.h | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c
index 026daecb2122..e51e3b39e24a 100644
--- a/lib/graph/graph_populate.c
+++ b/lib/graph/graph_populate.c
@@ -64,6 +64,7 @@ graph_header_popluate(struct graph *_graph)
graph->nb_nodes = _graph->node_count;
graph->cir_start = RTE_PTR_ADD(graph, _graph->cir_start);
graph->nodes_start = _graph->nodes_start;
+ graph->cycles_stats = rte_graph_has_stats_feature();
graph->socket = _graph->socket;
graph->id = _graph->id;
memcpy(graph->name, _graph->name, RTE_GRAPH_NAMESIZE);
diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index c87a6796a96e..4161fc4b02e7 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -56,7 +56,7 @@ struct __rte_cache_aligned rte_graph {
rte_graph_off_t *cir_start; /**< Pointer to circular buffer. */
rte_graph_off_t nodes_start; /**< Offset at which node memory starts. */
uint8_t model; /**< graph model */
- uint8_t reserved1; /**< Reserved for future use. */
+ uint8_t cycles_stats; /**< Reserved for future use. */
uint16_t reserved2; /**< Reserved for future use. */
union {
/* Fast schedule area for mcore dispatch model */
@@ -205,7 +205,7 @@ __rte_node_process(struct rte_graph *graph, struct rte_node *node)
objs = node->objs;
rte_prefetch0(objs);
- if (rte_graph_has_stats_feature()) {
+ if (graph->cycles_stats) {
start = rte_rdtsc();
rc = node->process(graph, node, objs, node->idx);
node->total_cycles += rte_rdtsc() - start;
@@ -560,6 +560,20 @@ rte_graph_model_is_valid(uint8_t model);
*/
int rte_graph_worker_model_set(uint8_t model);
+/**
+ * Enable/disable collecting of TSC cycles for each node visit. The default
+ * value for all new or cloned graphs is equal to rte_graph_has_stats_feature()
+ * which is set to the RTE_LIBRTE_GRAPH_STATS compile time constant.
+ *
+ * @param enabled
+ * Set to 1 to enable, 0 to disable.
+ */
+static inline void
+rte_graph_cycle_stats_enable(struct rte_graph *graph, uint8_t enabled)
+{
+ graph->cycles_stats = enabled;
+}
+
/**
* Get the graph worker model
*
--
2.52.0
prev parent reply other threads:[~2025-12-09 8:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 8:50 [PATCH dpdk 0/2] Flexible graph nodes stats collection Robin Jarry
2025-12-09 8:50 ` [PATCH dpdk 1/2] graph: always count objects and calls Robin Jarry
2025-12-09 9:09 ` Jerin Jacob
2025-12-09 9:12 ` Robin Jarry
2025-12-09 11:13 ` Morten Brørup
2025-12-09 11:47 ` Robin Jarry
2025-12-09 12:11 ` Morten Brørup
2025-12-09 12:45 ` Robin Jarry
2025-12-09 13:45 ` Morten Brørup
2025-12-09 14:47 ` Robin Jarry
2025-12-09 8:50 ` Robin Jarry [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251209085028.115203-6-rjarry@redhat.com \
--to=rjarry@redhat.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=yanzhirun_163@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).