From: Kiran Kumar Kokkilagadda <kirankumark@marvell.com>
To: Kiran Kumar Kokkilagadda <kirankumark@marvell.com>,
Jerin Jacob <jerinj@marvell.com>,
Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>,
Zhirun Yan <yanzhirun_163@163.com>,
Thomas Monjalon <thomas@monjalon.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH v7 1/3] graph: avoid global node ID counter
Date: Fri, 30 May 2025 11:07:49 +0000 [thread overview]
Message-ID: <DM3PPF17CE793AB453C9313CD9B479463FDAC61A@DM3PPF17CE793AB.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20250505062422.588450-1-kirankumark@marvell.com>
Hi Thomas,
This series has been under review for a long time and has been acknowledged. Can we merge it for the next release?
> -----Original Message-----
> From: kirankumark@marvell.com <kirankumark@marvell.com>
> Sent: Monday, May 5, 2025 11:54 AM
> To: Jerin Jacob <jerinj@marvell.com>; Kiran Kumar Kokkilagadda
> <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Zhirun Yan <yanzhirun_163@163.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v7 1/3] graph: avoid global node ID counter
>
> From: Kiran Kumar K <kirankumark@marvell.com>
>
> The node id is determined based on a global variable that is incremented every
> time a node is created. Adding changes to remove the global counter. Make
> sure that the node list is always ordered by increasing node ids. When creating
> a new node, pick a free id which is not allocated.
>
> Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> ---
> * V7 Changes:
> - Updated Acked-by
> lib/graph/graph_populate.c | 11 +++--
> lib/graph/graph_private.h | 8 ----
> lib/graph/node.c | 86 ++++++++++++++++++++++++++++++++------
> 3 files changed, 82 insertions(+), 23 deletions(-)
>
> diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c index
> 1e6b08319e..026daecb21 100644
> --- a/lib/graph/graph_populate.c
> +++ b/lib/graph/graph_populate.c
> @@ -78,7 +78,6 @@ graph_nodes_populate(struct graph *_graph)
> struct rte_graph *graph = _graph->graph;
> struct graph_node *graph_node;
> rte_edge_t count, nb_edges;
> - const char *parent;
> rte_node_t pid;
>
> STAILQ_FOREACH(graph_node, &_graph->node_list, next) { @@ -
> 94,8 +93,14 @@ graph_nodes_populate(struct graph *_graph)
> memcpy(node->name, graph_node->node->name,
> RTE_GRAPH_NAMESIZE);
> pid = graph_node->node->parent_id;
> if (pid != RTE_NODE_ID_INVALID) { /* Cloned node */
> - parent = rte_node_id_to_name(pid);
> - memcpy(node->parent, parent,
> RTE_GRAPH_NAMESIZE);
> + struct node *pnode;
> +
> + STAILQ_FOREACH(pnode, node_list_head_get(), next)
> {
> + if (pnode->id == pid) {
> + memcpy(node->parent, pnode-
> >name, RTE_GRAPH_NAMESIZE);
> + break;
> + }
> + }
> }
> node->id = graph_node->node->id;
> node->parent_id = pid;
> diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index
> 813dd78b9d..3529640abf 100644
> --- a/lib/graph/graph_private.h
> +++ b/lib/graph/graph_private.h
> @@ -29,14 +29,6 @@ extern int rte_graph_logtype; #define graph_info(...)
> GRAPH_LOG(INFO, __VA_ARGS__) #define graph_dbg(...)
> GRAPH_LOG(DEBUG, __VA_ARGS__)
>
> -#define ID_CHECK(id, id_max) \
> - do { \
> - if ((id) >= (id_max)) { \
> - rte_errno = EINVAL; \
> - goto fail; \
> - } \
> - } while (0)
> -
> #define SET_ERR_JMP(err, where, fmt, ...) \
> do { \
> graph_err(fmt, ##__VA_ARGS__); \
> diff --git a/lib/graph/node.c b/lib/graph/node.c index
> 101981ec24..53a3f3f2d4 100644
> --- a/lib/graph/node.c
> +++ b/lib/graph/node.c
> @@ -16,9 +16,56 @@
> #include "graph_private.h"
>
> static struct node_head node_list = STAILQ_HEAD_INITIALIZER(node_list);
> -static rte_node_t node_id;
>
> -#define NODE_ID_CHECK(id) ID_CHECK(id, node_id)
> +static struct node *
> +node_from_id(rte_node_t id)
> +{
> + struct node *node = NULL;
> +
> + graph_spinlock_lock();
> + rte_errno = EINVAL;
> + STAILQ_FOREACH(node, &node_list, next) {
> + if (node->id == id) {
> + rte_errno = 0;
> + goto exit;
> + }
> + }
> +exit:
> + graph_spinlock_unlock();
> + return node;
> +}
> +
> +static rte_node_t
> +next_next_free_id(void)
> +{
> + struct node *node;
> + rte_node_t id = 0;
> +
> + STAILQ_FOREACH(node, &node_list, next) {
> + if (id < node->id)
> + break;
> + id = node->id + 1;
> + }
> + return id;
> +}
> +
> +static void
> +node_insert_ordered(struct node *node)
> +{
> + struct node *after, *g;
> +
> + after = NULL;
> + STAILQ_FOREACH(g, &node_list, next) {
> + if (g->id < node->id)
> + after = g;
> + else if (g->id > node->id)
> + break;
> + }
> + if (after == NULL)
> + STAILQ_INSERT_HEAD(&node_list, node, next);
> + else
> + STAILQ_INSERT_AFTER(&node_list, after, node, next); }
>
> /* Private functions */
> struct node_head *
> @@ -118,10 +165,10 @@ __rte_node_register(const struct
> rte_node_register *reg)
> }
>
> node->lcore_id = RTE_MAX_LCORE;
> - node->id = node_id++;
> + node->id = next_next_free_id();
>
> - /* Add the node at tail */
> - STAILQ_INSERT_TAIL(&node_list, node, next);
> + /* Add the node in ordered list */
> + node_insert_ordered(node);
> graph_spinlock_unlock();
>
> return node->id;
> @@ -197,7 +244,9 @@ rte_node_clone(rte_node_t id, const char *name) {
> struct node *node;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> +
> STAILQ_FOREACH(node, &node_list, next)
> if (node->id == id)
> return node_clone(node, name);
> @@ -225,7 +274,8 @@ rte_node_id_to_name(rte_node_t id) {
> struct node *node;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> STAILQ_FOREACH(node, &node_list, next)
> if (node->id == id)
> return node->name;
> @@ -240,7 +290,8 @@ rte_node_edge_count(rte_node_t id) {
> struct node *node;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> STAILQ_FOREACH(node, &node_list, next)
> if (node->id == id)
> return node->nb_edges;
> @@ -310,7 +361,8 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t
> size)
> rte_edge_t rc = RTE_EDGE_ID_INVALID;
> struct node *node;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> graph_spinlock_lock();
>
> STAILQ_FOREACH(node, &node_list, next) { @@ -338,7 +390,8 @@
> rte_node_edge_update(rte_node_t id, rte_edge_t from, const char
> **next_nodes,
> rte_edge_t rc = RTE_EDGE_ID_INVALID;
> struct node *n, *prev;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> graph_spinlock_lock();
>
> prev = NULL;
> @@ -373,7 +426,8 @@ rte_node_edge_get(rte_node_t id, char
> *next_nodes[])
> rte_node_t rc = RTE_NODE_ID_INVALID;
> struct node *node;
>
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
> graph_spinlock_lock();
>
> STAILQ_FOREACH(node, &node_list, next) { @@ -397,7 +451,8 @@
> node_scan_dump(FILE *f, rte_node_t id, bool all)
> struct node *node;
>
> RTE_ASSERT(f != NULL);
> - NODE_ID_CHECK(id);
> + if (node_from_id(id) == NULL)
> + goto fail;
>
> STAILQ_FOREACH(node, &node_list, next) {
> if (all == true) {
> @@ -429,5 +484,12 @@ RTE_EXPORT_SYMBOL(rte_node_max_count)
> rte_node_t
> rte_node_max_count(void)
> {
> + rte_node_t node_id = 0;
> + struct node *node;
> +
> + STAILQ_FOREACH(node, &node_list, next) {
> + if (node_id < node->id)
> + node_id = node->id;
> + }
> return node_id;
> }
> --
> 2.48.1
prev parent reply other threads:[~2025-05-30 11:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 7:04 [PATCH v3 " kirankumark
2024-11-14 7:04 ` [PATCH v3 2/3] graph: add support for node free API kirankumark
2024-11-14 7:04 ` [PATCH v3 3/3] test/graph: fix graph autotest second run test failure kirankumark
2024-11-14 9:08 ` [PATCH v4 1/3] graph: avoid global node ID counter kirankumark
2024-11-14 9:08 ` [PATCH v4 2/3] graph: add support for node free API kirankumark
2024-11-14 17:07 ` Stephen Hemminger
2024-11-14 9:08 ` [PATCH v4 3/3] test/graph: fix graph autotest second run test failure kirankumark
2024-11-14 17:09 ` Stephen Hemminger
2024-11-26 4:44 ` [PATCH v5 1/3] graph: avoid global node ID counter kirankumark
2024-11-26 4:44 ` [PATCH v5 2/3] graph: add support for node free API kirankumark
2025-02-10 16:49 ` Jerin Jacob
2024-11-26 4:44 ` [PATCH v5 3/3] test/graph: fix graph autotest second run test failure kirankumark
2025-02-10 16:47 ` Jerin Jacob
2025-05-05 6:20 ` [PATCH v6 1/3] graph: avoid global node ID counter kirankumark
2025-05-05 6:20 ` [PATCH v6 2/3] graph: add support for node free API kirankumark
2025-05-05 6:20 ` [PATCH v6 3/3] test/graph: fix graph autotest second run test failure kirankumark
2025-05-05 6:24 ` [PATCH v7 1/3] graph: avoid global node ID counter kirankumark
2025-05-05 6:24 ` [PATCH v7 2/3] graph: add support for node free API kirankumark
2025-05-05 6:24 ` [PATCH v7 3/3] test/graph: fix graph autotest second run test failure kirankumark
2025-05-30 11:07 ` Kiran Kumar Kokkilagadda [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=DM3PPF17CE793AB453C9313CD9B479463FDAC61A@DM3PPF17CE793AB.namprd18.prod.outlook.com \
--to=kirankumark@marvell.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=thomas@monjalon.net \
--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).