[v4,38/39] graph: use C11 alignas
Checks
Commit Message
* Move __rte_aligned from the end of {struct,union} definitions to
be between {struct,union} and tag.
The placement between {struct,union} and the tag allows the desired
alignment to be imparted on the type regardless of the toolchain being
used for all of GCC, LLVM, MSVC compilers building both C and C++.
* Replace use of __rte_aligned(a) on variables/fields with alignas(a).
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/graph/graph_private.h | 4 ++--
lib/graph/graph_stats.c | 4 ++--
lib/graph/rte_graph.h | 4 ++--
lib/graph/rte_graph_worker_common.h | 17 ++++++++++-------
4 files changed, 16 insertions(+), 13 deletions(-)
@@ -71,11 +71,11 @@ struct node {
* Structure that holds the graph scheduling workqueue node stream.
* Used for mcore dispatch model.
*/
-struct graph_mcore_dispatch_wq_node {
+struct __rte_cache_aligned graph_mcore_dispatch_wq_node {
rte_graph_off_t node_off;
uint16_t nb_objs;
void *objs[RTE_GRAPH_BURST_SIZE];
-} __rte_cache_aligned;
+};
/**
* @internal
@@ -28,7 +28,7 @@ struct cluster_node {
struct rte_node *nodes[];
};
-struct rte_graph_cluster_stats {
+struct __rte_cache_aligned rte_graph_cluster_stats {
/* Header */
rte_graph_cluster_stats_cb_t fn;
uint32_t cluster_node_size; /* Size of struct cluster_node */
@@ -38,7 +38,7 @@ struct rte_graph_cluster_stats {
size_t sz;
struct cluster_node clusters[];
-} __rte_cache_aligned;
+};
#define boarder_model_dispatch() \
fprintf(f, "+-------------------------------+---------------+--------" \
@@ -200,7 +200,7 @@ struct rte_graph_cluster_stats_param {
*
* @see struct rte_graph_cluster_stats_param::fn
*/
-struct rte_graph_cluster_node_stats {
+struct __rte_cache_aligned rte_graph_cluster_node_stats {
uint64_t ts; /**< Current timestamp. */
uint64_t calls; /**< Current number of calls made. */
uint64_t objs; /**< Current number of objs processed. */
@@ -225,7 +225,7 @@ struct rte_graph_cluster_node_stats {
rte_node_t id; /**< Node identifier of stats. */
uint64_t hz; /**< Cycles per seconds. */
char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */
-} __rte_cache_aligned;
+};
/**
* Create Graph.
@@ -12,6 +12,8 @@
* process, enqueue and move streams of objects to the next nodes.
*/
+#include <stdalign.h>
+
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
@@ -43,7 +45,7 @@
*
* Data structure to hold graph data.
*/
-struct rte_graph {
+struct __rte_cache_aligned rte_graph {
/* Fast path area. */
uint32_t tail; /**< Tail of circular buffer. */
uint32_t head; /**< Head of circular buffer. */
@@ -57,7 +59,8 @@ struct rte_graph {
union {
/* Fast schedule area for mcore dispatch model */
struct {
- struct rte_graph_rq_head *rq __rte_cache_aligned; /* The run-queue */
+ alignas(RTE_CACHE_LINE_SIZE) struct rte_graph_rq_head *rq;
+ /* The run-queue */
struct rte_graph_rq_head rq_head; /* The head for run-queue list */
unsigned int lcore_id; /**< The graph running Lcore. */
@@ -77,14 +80,14 @@ struct rte_graph {
uint64_t nb_pkt_to_capture;
char pcap_filename[RTE_GRAPH_PCAP_FILE_SZ]; /**< Pcap filename. */
uint64_t fence; /**< Fence. */
-} __rte_cache_aligned;
+};
/**
* @internal
*
* Data structure to hold node data.
*/
-struct rte_node {
+struct __rte_cache_aligned rte_node {
/* Slow path area */
uint64_t fence; /**< Fence. */
rte_graph_off_t next; /**< Index to next node. */
@@ -109,7 +112,7 @@ struct rte_node {
};
/* Fast path area */
#define RTE_NODE_CTX_SZ 16
- uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */
+ alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< 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. */
@@ -124,8 +127,8 @@ struct rte_node {
rte_node_process_t process; /**< Process function. */
uint64_t process_u64;
};
- struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */
-} __rte_cache_aligned;
+ alignas(RTE_CACHE_LINE_MIN_SIZE) struct rte_node *nodes[]; /**< Next nodes. */
+};
/**
* @internal