graph: expose node context as pointers

Message ID 20240320173217.311340-2-rjarry@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series graph: expose node context as pointers |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Robin Jarry March 20, 2024, 5:32 p.m. UTC
  In some cases, the node context data is used to store two pointers
because the data is larger than the reserved 16 bytes. Having to define
intermediate structures just to be able to cast is tedious. Add two
pointers that take the same space than ctx.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 lib/graph/rte_graph_worker_common.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

Jerin Jacob March 21, 2024, 8:13 a.m. UTC | #1
On Wed, Mar 20, 2024 at 11:02 PM Robin Jarry <rjarry@redhat.com> wrote:
>
> In some cases, the node context data is used to store two pointers
> because the data is larger than the reserved 16 bytes. Having to define
> intermediate structures just to be able to cast is tedious. Add two
> pointers that take the same space than ctx.
>
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---
>  lib/graph/rte_graph_worker_common.h | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
> index 36d864e2c14e..a7fcdf4893ea 100644
> --- a/lib/graph/rte_graph_worker_common.h
> +++ b/lib/graph/rte_graph_worker_common.h
> @@ -112,7 +112,14 @@ struct __rte_cache_aligned rte_node {
>         };
>         /* Fast path area  */
>  #define RTE_NODE_CTX_SZ 16
> -       alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */
> +       alignas(RTE_CACHE_LINE_SIZE) union {
> +               uint8_t ctx[RTE_NODE_CTX_SZ];
> +               /* Convenience aliases to store pointers without complex casting. */

1) Use _extension_ to not break this on windows build. See rte_mbuf.
2) Also add static assert to make sure the following struct is not
greater than RTE_NODE_CTX_SZ. To avoid accidentally adding something
in the future.


> +               struct {
> +                       void *ctx_ptr;
> +                       void *ctx_ptr2;
> +               };
> +       }; /**< Node Context. */
>         uint16_t size;          /**< Total number of objects available. */
>         uint16_t idx;           /**< Number of objects used. */
>         rte_graph_off_t off;    /**< Offset of node in the graph reel. */
> --
> 2.44.0
>
  

Patch

diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index 36d864e2c14e..a7fcdf4893ea 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -112,7 +112,14 @@  struct __rte_cache_aligned rte_node {
 	};
 	/* Fast path area  */
 #define RTE_NODE_CTX_SZ 16
-	alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */
+	alignas(RTE_CACHE_LINE_SIZE) union {
+		uint8_t ctx[RTE_NODE_CTX_SZ];
+		/* Convenience aliases to store pointers without complex casting. */
+		struct {
+			void *ctx_ptr;
+			void *ctx_ptr2;
+		};
+	}; /**< Node Context. */
 	uint16_t size;		/**< Total number of objects available. */
 	uint16_t idx;		/**< Number of objects used. */
 	rte_graph_off_t off;	/**< Offset of node in the graph reel. */