[76/83] app/test: move alignment attribute on types

Message ID 1710949096-5786-77-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series move alignment attribute on types |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff March 20, 2024, 3:38 p.m. UTC
  Move location of __rte_aligned(a) to new conventional location. The new
placement between {struct,union} and the tag allows the desired
alignment to be imparted on the type regardless of the toolchain being
used for both C and C++. Additionally, it avoids confusion by Doxygen
when generating documentation.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_cryptodev_aead_test_vectors.h            |  6 +++---
 app/test/test_cryptodev_blockcipher.h                  |  2 +-
 app/test/test_cryptodev_kasumi_test_vectors.h          |  2 +-
 app/test/test_cryptodev_mixed_test_vectors.h           |  2 +-
 app/test/test_cryptodev_security_docsis_test_vectors.h |  2 +-
 app/test/test_cryptodev_snow3g_test_vectors.h          |  2 +-
 app/test/test_cryptodev_zuc_test_vectors.h             |  2 +-
 app/test/test_distributor.c                            | 12 ++++++------
 app/test/test_distributor_perf.c                       |  6 +++---
 app/test/test_mempool_perf.c                           |  6 +++---
 app/test/test_pmd_perf.c                               |  4 ++--
 app/test/test_ring_stress_impl.h                       | 10 +++++-----
 app/test/test_rwlock.c                                 |  8 ++++----
 app/test/test_seqlock.c                                |  8 ++++----
 app/test/test_ticketlock.c                             |  4 ++--
 app/test/test_trace_perf.c                             |  8 ++++----
 16 files changed, 42 insertions(+), 42 deletions(-)
  

Patch

diff --git a/app/test/test_cryptodev_aead_test_vectors.h b/app/test/test_cryptodev_aead_test_vectors.h
index 35ae64c..e9b0590 100644
--- a/app/test/test_cryptodev_aead_test_vectors.h
+++ b/app/test/test_cryptodev_aead_test_vectors.h
@@ -47,7 +47,7 @@  struct aead_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned len;
 	} iv;
 
@@ -79,7 +79,7 @@  struct gmac_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned len;
 	} iv;
 
@@ -2025,7 +2025,7 @@  struct cryptodev_perf_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned len;
 	} iv;
 
diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h
index e6f6c18..a73bee0 100644
--- a/app/test/test_cryptodev_blockcipher.h
+++ b/app/test/test_cryptodev_blockcipher.h
@@ -72,7 +72,7 @@  struct blockcipher_test_data {
 	} cipher_key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned int len;
 	} iv;
 
diff --git a/app/test/test_cryptodev_kasumi_test_vectors.h b/app/test/test_cryptodev_kasumi_test_vectors.h
index f0a6d55..3b51704 100644
--- a/app/test/test_cryptodev_kasumi_test_vectors.h
+++ b/app/test/test_cryptodev_kasumi_test_vectors.h
@@ -12,7 +12,7 @@  struct kasumi_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned int len;
 	} cipher_iv;
 
diff --git a/app/test/test_cryptodev_mixed_test_vectors.h b/app/test/test_cryptodev_mixed_test_vectors.h
index 9c43131..25c4a48 100644
--- a/app/test/test_cryptodev_mixed_test_vectors.h
+++ b/app/test/test_cryptodev_mixed_test_vectors.h
@@ -32,7 +32,7 @@  struct mixed_cipher_auth_test_data {
 	} cipher_key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned int len; /* length must be in Bytes */
 	} cipher_iv;
 
diff --git a/app/test/test_cryptodev_security_docsis_test_vectors.h b/app/test/test_cryptodev_security_docsis_test_vectors.h
index aa7f56a..7e9909b 100644
--- a/app/test/test_cryptodev_security_docsis_test_vectors.h
+++ b/app/test/test_cryptodev_security_docsis_test_vectors.h
@@ -21,7 +21,7 @@  struct docsis_test_data {
 	} key;
 
 	struct {
-		uint8_t data[16] __rte_aligned(16);
+		alignas(16) uint8_t data[16];
 		unsigned int len;
 	} iv;
 
diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h b/app/test/test_cryptodev_snow3g_test_vectors.h
index 3b7e442..10db4f6 100644
--- a/app/test/test_cryptodev_snow3g_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_test_vectors.h
@@ -12,7 +12,7 @@  struct snow3g_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned len;
 	} cipher_iv;
 
diff --git a/app/test/test_cryptodev_zuc_test_vectors.h b/app/test/test_cryptodev_zuc_test_vectors.h
index cb1b51e..714d681 100644
--- a/app/test/test_cryptodev_zuc_test_vectors.h
+++ b/app/test/test_cryptodev_zuc_test_vectors.h
@@ -12,7 +12,7 @@  struct wireless_test_data {
 	} key;
 
 	struct {
-		uint8_t data[64] __rte_aligned(16);
+		alignas(16) uint8_t data[64];
 		unsigned len;
 	} cipher_iv;
 
diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c
index d2037b7..13357b9 100644
--- a/app/test/test_distributor.c
+++ b/app/test/test_distributor.c
@@ -53,9 +53,9 @@  struct worker_params {
 static volatile unsigned worker_idx;
 static volatile unsigned zero_idx;
 
-struct worker_stats {
+struct __rte_cache_aligned worker_stats {
 	volatile unsigned handled_packets;
-} __rte_cache_aligned;
+};
 struct worker_stats worker_stats[RTE_MAX_LCORE];
 
 /* returns the total count of the number of packets handled by the worker
@@ -87,7 +87,7 @@  struct worker_stats {
 static int
 handle_work(void *arg)
 {
-	struct rte_mbuf *buf[8] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 	struct worker_params *wp = arg;
 	struct rte_distributor *db = wp->dist;
 	unsigned int num;
@@ -306,7 +306,7 @@  struct worker_stats {
 static int
 handle_work_with_free_mbufs(void *arg)
 {
-	struct rte_mbuf *buf[8] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 	struct worker_params *wp = arg;
 	struct rte_distributor *d = wp->dist;
 	unsigned int i;
@@ -375,7 +375,7 @@  struct worker_stats {
 static int
 handle_work_for_shutdown_test(void *arg)
 {
-	struct rte_mbuf *buf[8] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 	struct worker_params *wp = arg;
 	struct rte_distributor *d = wp->dist;
 	unsigned int num;
@@ -592,7 +592,7 @@  struct worker_stats {
 static int
 handle_and_mark_work(void *arg)
 {
-	struct rte_mbuf *buf[8] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 	struct worker_params *wp = arg;
 	struct rte_distributor *db = wp->dist;
 	unsigned int num, i;
diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor_perf.c
index ca86845..c0ad39d 100644
--- a/app/test/test_distributor_perf.c
+++ b/app/test/test_distributor_perf.c
@@ -33,9 +33,9 @@ 
 static volatile int quit;
 static volatile unsigned worker_idx;
 
-struct worker_stats {
+struct __rte_cache_aligned worker_stats {
 	volatile unsigned handled_packets;
-} __rte_cache_aligned;
+};
 static struct worker_stats worker_stats[RTE_MAX_LCORE];
 
 /*
@@ -122,7 +122,7 @@  struct worker_stats {
 	unsigned int num = 0;
 	int i;
 	unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED);
-	struct rte_mbuf *buf[8] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 
 	for (i = 0; i < 8; i++)
 		buf[i] = NULL;
diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index 96de347..a42a772 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -101,9 +101,9 @@ 
 static int use_constant_values;
 
 /* number of enqueues / dequeues */
-struct mempool_test_stats {
+struct __rte_cache_aligned mempool_test_stats {
 	uint64_t enq_count;
-} __rte_cache_aligned;
+};
 
 static struct mempool_test_stats stats[RTE_MAX_LCORE];
 
@@ -124,7 +124,7 @@  struct mempool_test_stats {
 test_loop(struct rte_mempool *mp, struct rte_mempool_cache *cache,
 	  unsigned int x_keep, unsigned int x_get_bulk, unsigned int x_put_bulk)
 {
-	void *obj_table[MAX_KEEP] __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) void *obj_table[MAX_KEEP];
 	unsigned int idx;
 	unsigned int i;
 	int ret;
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index f6d97f2..35fa068 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -94,12 +94,12 @@  enum {
 	LCORE_USED,
 };
 
-struct lcore_conf {
+struct __rte_cache_aligned lcore_conf {
 	uint8_t status;
 	uint8_t socketid;
 	uint16_t nb_ports;
 	uint16_t portlist[RTE_MAX_ETHPORTS];
-} __rte_cache_aligned;
+};
 
 struct lcore_conf lcore_conf[RTE_MAX_LCORE];
 
diff --git a/app/test/test_ring_stress_impl.h b/app/test/test_ring_stress_impl.h
index 2dec897..202d47d 100644
--- a/app/test/test_ring_stress_impl.h
+++ b/app/test/test_ring_stress_impl.h
@@ -24,7 +24,7 @@  enum {
 	WRK_CMD_RUN,
 };
 
-static uint32_t wrk_cmd __rte_cache_aligned = WRK_CMD_STOP;
+static alignas(RTE_CACHE_LINE_SIZE) uint32_t wrk_cmd = WRK_CMD_STOP;
 
 /* test run-time in seconds */
 static const uint32_t run_time = 60;
@@ -41,14 +41,14 @@  struct lcore_stat {
 	} op;
 };
 
-struct lcore_arg {
+struct __rte_cache_aligned lcore_arg {
 	struct rte_ring *rng;
 	struct lcore_stat stats;
-} __rte_cache_aligned;
+};
 
-struct ring_elem {
+struct __rte_cache_aligned ring_elem {
 	uint32_t cnt[RTE_CACHE_LINE_SIZE / sizeof(uint32_t)];
-} __rte_cache_aligned;
+};
 
 /*
  * redefinable functions
diff --git a/app/test/test_rwlock.c b/app/test/test_rwlock.c
index 5079895..e8767da 100644
--- a/app/test/test_rwlock.c
+++ b/app/test/test_rwlock.c
@@ -42,7 +42,7 @@  enum {
 	LC_TYPE_WRLOCK,
 };
 
-static struct {
+static alignas(RTE_CACHE_LINE_SIZE) struct {
 	rte_rwlock_t lock;
 	uint64_t tick;
 
@@ -50,9 +50,9 @@  enum {
 		uint8_t u8[RTE_CACHE_LINE_SIZE];
 		uint64_t u64[RTE_CACHE_LINE_SIZE / sizeof(uint64_t)];
 	} data;
-} __rte_cache_aligned try_rwlock_data;
+} try_rwlock_data;
 
-struct try_rwlock_lcore {
+struct __rte_cache_aligned try_rwlock_lcore {
 	int32_t rc;
 	int32_t type;
 	struct {
@@ -60,7 +60,7 @@  struct try_rwlock_lcore {
 		uint64_t fail;
 		uint64_t success;
 	} stat;
-} __rte_cache_aligned;
+};
 
 static struct try_rwlock_lcore try_lcore_data[RTE_MAX_LCORE];
 
diff --git a/app/test/test_seqlock.c b/app/test/test_seqlock.c
index 873bd60..bab8b0f 100644
--- a/app/test/test_seqlock.c
+++ b/app/test/test_seqlock.c
@@ -12,13 +12,13 @@ 
 
 #include "test.h"
 
-struct data {
+struct __rte_cache_aligned data {
 	rte_seqlock_t lock;
 
 	uint64_t a;
-	uint64_t b __rte_cache_aligned;
-	uint64_t c __rte_cache_aligned;
-} __rte_cache_aligned;
+	alignas(RTE_CACHE_LINE_SIZE) uint64_t b;
+	alignas(RTE_CACHE_LINE_SIZE) uint64_t c;
+};
 
 struct reader {
 	struct data *data;
diff --git a/app/test/test_ticketlock.c b/app/test/test_ticketlock.c
index 1fbbedb..7a6cb4c 100644
--- a/app/test/test_ticketlock.c
+++ b/app/test/test_ticketlock.c
@@ -95,8 +95,8 @@ 
 }
 
 static rte_ticketlock_t lk = RTE_TICKETLOCK_INITIALIZER;
-static uint64_t lcount __rte_cache_aligned;
-static uint64_t lcore_count[RTE_MAX_LCORE] __rte_cache_aligned;
+static alignas(RTE_CACHE_LINE_SIZE) uint64_t lcount;
+static alignas(RTE_CACHE_LINE_SIZE) uint64_t lcore_count[RTE_MAX_LCORE];
 static uint64_t time_cost[RTE_MAX_LCORE];
 
 #define MAX_LOOP 10000
diff --git a/app/test/test_trace_perf.c b/app/test/test_trace_perf.c
index a6dd075..8257cc0 100644
--- a/app/test/test_trace_perf.c
+++ b/app/test/test_trace_perf.c
@@ -14,17 +14,17 @@ 
 
 struct test_data;
 
-struct lcore_data {
+struct __rte_cache_aligned lcore_data {
 	volatile bool done;
 	volatile bool started;
 	uint64_t total_cycles;
 	uint64_t total_calls;
-} __rte_cache_aligned;
+};
 
-struct test_data {
+struct __rte_cache_aligned test_data {
 	unsigned int nb_workers;
 	struct lcore_data ldata[];
-} __rte_cache_aligned;
+};
 
 #define STEP 100
 #define CENT_OPS(OP) do {     \