use C11 alignas and normalize type alignment
PATCH v7 18/39 reorder: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/reorder/rte_reorder.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/reorder/rte_reorder.c +4 -4
@@ -37,16 +37,16 @@int rte_reorder_seqn_dynfield_offset =-1 ;/* A generic circular buffer */ -struct cir_buffer { +struct __rte_cache_aligned cir_buffer {unsigned int size;/**< Number of entries that can be stored */ unsigned int mask;/**< [buffer_size - 1]: used for wrap-around */ unsigned int head;/**< insertion point in buffer */ unsigned int tail;/**< extraction point in buffer */ struct rte_mbuf **entries; -} __rte_cache_aligned; +};/* The reorder buffer data structure itself */ -struct rte_reorder_buffer { +struct __rte_cache_aligned rte_reorder_buffer {char name[RTE_REORDER_NAMESIZE ];uint32_t min_seqn;/**< Lowest seq. number that can be in the buffer */ unsigned int memsize;/**< memory area size of reorder buffer */
@@ -54,7 +54,7 @@ struct rte_reorder_buffer {struct cir_buffer ready_buf;/**< temp buffer for dequeued entries */ struct cir_buffer order_buf;/**< buffer used to reorder entries */ -} __rte_cache_aligned; +};static void rte_reorder_free_mbufs (struct rte_reorder_buffer *b);
Signature · 1 line
1.8.3.1
PATCH v7 19/39 regexdev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/regexdev/rte_regexdev_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/regexdev/rte_regexdev_core.h +4 -4
@@ -144,13 +144,13 @@ enum rte_regexdev_state {* This structure is safe to place in shared memory to be common among different * processes in a multi-process configuration. */ -struct rte_regexdev_data { +struct __rte_cache_aligned rte_regexdev_data {void *dev_private;/**< PMD-specific private data. */ char dev_name[RTE_REGEXDEV_NAME_MAX_LEN ];/**< Unique identifier name */ uint16_t dev_id;/**< Device [external] identifier. */ struct rte_regexdev_config dev_conf;/**< RegEx configuration. */ uint8_t dev_started : 1; /**< Device started to work. */ -} __rte_cache_aligned; +};/** * @internal
@@ -162,7 +162,7 @@ struct rte_regexdev_data {* memory. This split allows the function pointer and driver data to be per- * process, while the actual configuration data for the device is shared. */ -struct rte_regexdev { +struct __rte_cache_aligned rte_regexdev {regexdev_enqueue_t enqueue;regexdev_dequeue_t dequeue;const struct rte_regexdev_ops *dev_ops;
@@ -170,7 +170,7 @@ struct rte_regexdev {struct rte_device *device;/**< Backing device */ enum rte_regexdev_state state;/**< The device state. */ struct rte_regexdev_data *data;/**< Pointer to device data. */ -} __rte_cache_aligned; +};/** * @internal
Signature · 1 line
1.8.3.1
PATCH v7 20/39 rcu: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/rcu/rte_rcu_qsbr.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
lib/rcu/rte_rcu_qsbr.h +9 -7
@@ -21,6 +21,8 @@* entered quiescent state. */ +#include <stdalign.h> +#ifdef __cplusplusextern "C" {#endif
@@ -69,7 +71,7 @@#define RTE_QSBR_THRID_INVALID 0xffffffff/* Worker thread counter */ -struct rte_rcu_qsbr_cnt { +struct __rte_cache_aligned rte_rcu_qsbr_cnt {RTE_ATOMIC (uint64_t ) cnt;/**< Quiescent state counter. Value 0 indicates the thread is offline * 64b counter is used to avoid adding more code to address
@@ -78,7 +80,7 @@ struct rte_rcu_qsbr_cnt {*/ RTE_ATOMIC (uint32_t ) lock_cnt;/**< Lock counter. Used when RTE_LIBRTE_RCU_DEBUG is enabled */ -} __rte_cache_aligned; +};#define __RTE_QSBR_CNT_THR_OFFLINE 0#define __RTE_QSBR_CNT_INIT 1
@@ -91,28 +93,28 @@ struct rte_rcu_qsbr_cnt {* 1) Quiescent state counter array * 2) Register thread ID array */ -struct rte_rcu_qsbr { - RTE_ATOMIC(uint64_t) token __rte_cache_aligned; +struct __rte_cache_aligned rte_rcu_qsbr { + alignas(RTE_CACHE_LINE_SIZE )RTE_ATOMIC (uint64_t ) token;/**< Counter to allow for multiple concurrent quiescent state queries */ RTE_ATOMIC (uint64_t ) acked_token;/**< Least token acked by all the threads in the last call to * rte_rcu_qsbr_check API. */ - uint32_t num_elems __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE )uint32_t num_elems;/**< Number of elements in the thread ID array */ RTE_ATOMIC (uint32_t ) num_threads;/**< Number of threads currently using this QS variable */ uint32_t max_threads;/**< Maximum number of threads using this QS variable */ - struct rte_rcu_qsbr_cnt qsbr_cnt[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE )struct rte_rcu_qsbr_cnt qsbr_cnt[0 ];/**< Quiescent state counter array of 'max_threads' elements */ /**< Registered thread IDs are stored in a bitmap array, * after the quiescent state counter array. */ -} __rte_cache_aligned; +};/** * Call back function called to free the resources.
Signature · 1 line
1.8.3.1
PATCH v7 21/39 power: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/power/power_acpi_cpufreq.c | 4 ++-- lib/power/power_amd_pstate_cpufreq.c | 4 ++-- lib/power/power_cppc_cpufreq.c | 4 ++-- lib/power/power_intel_uncore.c | 4 ++-- lib/power/power_pstate_cpufreq.c | 4 ++-- lib/power/rte_power_pmd_mgmt.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-)
lib/power/power_acpi_cpufreq.c +2 -2
@@ -41,7 +41,7 @@ enum power_state {/** * Power info per lcore. */ -struct acpi_power_info { +struct __rte_cache_aligned acpi_power_info {unsigned int lcore_id;/**< Logical core id */ uint32_t freqs[RTE_MAX_LCORE_FREQS ];/**< Frequency array */ uint32_t nb_freqs;/**< number of available freqs */
@@ -51,7 +51,7 @@ struct acpi_power_info {RTE_ATOMIC (uint32_t ) state;/**< Power in use state */ uint16_t turbo_available;/**< Turbo Boost available */ uint16_t turbo_enable;/**< Turbo Boost enable/disable */ -} __rte_cache_aligned; +};static struct acpi_power_info lcore_power_info[RTE_MAX_LCORE ];
lib/power/power_amd_pstate_cpufreq.c +2 -2
@@ -45,7 +45,7 @@ enum power_state {/** * Power info per lcore. */ -struct amd_pstate_power_info { +struct __rte_cache_aligned amd_pstate_power_info {uint32_t lcore_id;/**< Logical core id */ RTE_ATOMIC (uint32_t ) state;/**< Power in use state */ FILE *f;/**< FD of scaling_setspeed */
@@ -58,7 +58,7 @@ struct amd_pstate_power_info {uint16_t turbo_enable;/**< Turbo Boost enable/disable */ uint32_t nb_freqs;/**< number of available freqs */ uint32_t freqs[RTE_MAX_LCORE_FREQS ];/**< Frequency array */ -} __rte_cache_aligned; +};static struct amd_pstate_power_info lcore_power_info[RTE_MAX_LCORE ];
lib/power/power_cppc_cpufreq.c +2 -2
@@ -49,7 +49,7 @@ enum power_state {/** * Power info per lcore. */ -struct cppc_power_info { +struct __rte_cache_aligned cppc_power_info {unsigned int lcore_id;/**< Logical core id */ RTE_ATOMIC (uint32_t ) state;/**< Power in use state */ FILE *f;/**< FD of scaling_setspeed */
@@ -61,7 +61,7 @@ struct cppc_power_info {uint16_t turbo_enable;/**< Turbo Boost enable/disable */ uint32_t nb_freqs;/**< number of available freqs */ uint32_t freqs[RTE_MAX_LCORE_FREQS ];/**< Frequency array */ -} __rte_cache_aligned; +};static struct cppc_power_info lcore_power_info[RTE_MAX_LCORE ];
lib/power/power_intel_uncore.c +2 -2
@@ -29,7 +29,7 @@"/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/initial_min_freq_khz" -struct uncore_power_info { +struct __rte_cache_aligned uncore_power_info {unsigned int die;/* Core die id */ unsigned int pkg;/* Package id */ uint32_t freqs[MAX_UNCORE_FREQS ];/* Frequency array */
@@ -41,7 +41,7 @@ struct uncore_power_info {uint32_t org_max_freq;/* Original max freq of uncore */ uint32_t init_max_freq;/* System max uncore freq */ uint32_t init_min_freq;/* System min uncore freq */ -} __rte_cache_aligned; +};static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ];
lib/power/power_pstate_cpufreq.c +2 -2
@@ -49,7 +49,7 @@ enum power_state { POWER_UNKNOWN }; -struct pstate_power_info { +struct __rte_cache_aligned pstate_power_info {unsigned int lcore_id;/**< Logical core id */ uint32_t freqs[RTE_MAX_LCORE_FREQS ];/**< Frequency array */ uint32_t nb_freqs;/**< number of available freqs */
@@ -64,7 +64,7 @@ struct pstate_power_info {uint16_t turbo_available;/**< Turbo Boost available */ uint16_t turbo_enable;/**< Turbo Boost enable/disable */ uint16_t priority_core;/**< High Performance core */ -} __rte_cache_aligned; +};static struct pstate_power_info lcore_power_info[RTE_MAX_LCORE ];
lib/power/rte_power_pmd_mgmt.c +2 -2
@@ -55,7 +55,7 @@ struct queue_list_entry {const struct rte_eth_rxtx_callback *cb; }; -struct pmd_core_cfg { +struct __rte_cache_aligned pmd_core_cfg { TAILQ_HEAD(queue_list_head, queue_list_entry) head;/**< List of queues associated with this lcore */ size_t n_queues;
@@ -68,7 +68,7 @@ struct pmd_core_cfg {/**< Number of queues ready to enter power optimized state */ uint64_t sleep_target;/**< Prevent a queue from triggering sleep multiple times */ -} __rte_cache_aligned; +};static struct pmd_core_cfg lcore_cfgs[RTE_MAX_LCORE ]; static inline bool
Signature · 1 line
1.8.3.1
PATCH v7 22/39 rawdev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/rawdev/rte_rawdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/rawdev/rte_rawdev.h +2 -2
@@ -279,7 +279,7 @@* It is a placeholder for PMD specific data, encapsulating only information * related to framework. */ -struct rte_rawdev { +struct __rte_cache_aligned rte_rawdev {/**< Socket ID where memory is allocated */ int socket_id;/**< Device ID for this instance */
@@ -300,7 +300,7 @@ struct rte_rawdev {rte_rawdev_obj_t dev_private;/**< Device name */ char name[RTE_RAWDEV_NAME_MAX_LEN ]; -} __rte_cache_aligned; +};/** @internal The pool of rte_rawdev structures. */ extern struct rte_rawdev *rte_rawdevs;
Signature · 1 line
1.8.3.1
PATCH v7 23/39 port: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/port/rte_port_frag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/port/rte_port_frag.c +2 -2
@@ -34,7 +34,7 @@struct rte_mempool *pool_direct, struct rte_mempool *pool_indirect); -struct rte_port_ring_reader_frag { +struct __rte_cache_aligned rte_port_ring_reader_frag {struct rte_port_in_stats stats;/* Input parameters */
@@ -53,7 +53,7 @@ struct rte_port_ring_reader_frag {uint32_t pos_frags;frag_op f_frag; -} __rte_cache_aligned; +};static void *rte_port_ring_reader_frag_create (void *params,int socket_id,int is_ipv4)
Signature · 1 line
1.8.3.1
PATCH v7 24/39 pdcp: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/pdcp/rte_pdcp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdcp/rte_pdcp.h +2 -2
@@ -49,7 +49,7 @@ typedef uint16_t (*rte_pdcp_post_p_t)(const struct rte_pdcp_entity *entity,* A PDCP entity is associated either to the control plane or the user plane * depending on which radio bearer it is carrying data for. */ -struct rte_pdcp_entity { +struct __rte_cache_aligned rte_pdcp_entity {/** Entity specific pre-process handle. */ rte_pdcp_pre_p_t pre_process;/** Entity specific post-process handle. */
@@ -66,7 +66,7 @@ struct rte_pdcp_entity {* hold additionally 'max_pkt_cache' number of packets. */ uint32_t max_pkt_cache; -} __rte_cache_aligned; +};/** * Callback function type for t-Reordering timer start, set during PDCP entity establish.
Signature · 1 line
1.8.3.1
PATCH v7 25/39 node: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/node/node_private.h | 4 ++-- lib/node/pkt_cls.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
lib/node/node_private.h +2 -2
@@ -50,9 +50,9 @@ struct node_mbuf_priv1 {/** * Node mbuf private area 2. */ -struct node_mbuf_priv2 { +struct __rte_cache_aligned node_mbuf_priv2 {uint64_t priv_data; -} __rte_cache_aligned; +};#define NODE_MBUF_PRIV2_SIZE sizeof(struct node_mbuf_priv2)
lib/node/pkt_cls.c +3 -1
@@ -2,6 +2,8 @@* Copyright (C) 2020 Marvell. */ +#include <stdalign.h> +#include <rte_graph.h> #include <rte_graph_worker.h>
@@ -9,7 +11,7 @@#include "node_private.h" /* Next node for each ptype, default is '0' is "pkt_drop" */ -static const uint8_t p_nxt[256] __rte_cache_aligned = { +static const alignas(RTE_CACHE_LINE_SIZE )uint8_t p_nxt[256 ] = { [RTE_PTYPE_L3_IPV4 ] =PKT_CLS_NEXT_IP4_LOOKUP , [RTE_PTYPE_L3_IPV4_EXT ] =PKT_CLS_NEXT_IP4_LOOKUP ,
Signature · 1 line
1.8.3.1
PATCH v7 26/39 mldev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/mldev/rte_mldev.h | 4 ++-- lib/mldev/rte_mldev_core.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -421,7 +421,7 @@ struct rte_ml_buff_seg {* This structure contains data related to performing an ML operation on the buffers using * the model specified through model_id. */ -struct rte_ml_op { +struct __rte_cache_aligned rte_ml_op {uint16_t model_id;/**< Model ID to be used for the operation. */ uint16_t nb_batches;
@@ -469,7 +469,7 @@ struct rte_ml_op {* dequeue and enqueue operation. * The application should not modify this field. */ -} __rte_cache_aligned; +};/* Enqueue/Dequeue operations */
lib/mldev/rte_mldev_core.h +2 -2
@@ -626,7 +626,7 @@ struct rte_ml_dev_data {* * The data structure associated with each ML device. */ -struct rte_ml_dev { +struct __rte_cache_aligned rte_ml_dev {/** Pointer to PMD enqueue function. */ mldev_enqueue_t enqueue_burst;
@@ -647,7 +647,7 @@ struct rte_ml_dev {/** Flag indicating the device is attached. */ __extension__ uint8_t attached : 1; -} __rte_cache_aligned; +};/** * @internal
Signature · 1 line
1.8.3.1
PATCH v7 27/39 mempool: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/mempool/rte_mempool.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
lib/mempool/rte_mempool.h +14 -13
@@ -34,6 +34,7 @@* user cache created with rte_mempool_cache_create(). */ +#include <stdalign.h> #include <stdio.h> #include <stdint.h> #include <inttypes.h>
@@ -66,7 +67,7 @@* captured since they can be calculated from other stats. * For example: put_cache_objs = put_objs - put_common_pool_objs. */ -struct rte_mempool_debug_stats { +struct __rte_cache_aligned rte_mempool_debug_stats {uint64_t put_bulk;/**< Number of puts. */ uint64_t put_objs;/**< Number of objects successfully put. */ uint64_t put_common_pool_bulk;/**< Number of bulks enqueued in common pool. */
@@ -80,13 +81,13 @@ struct rte_mempool_debug_stats {uint64_t get_success_blks;/**< Successful allocation number of contiguous blocks. */ uint64_t get_fail_blks;/**< Failed allocation number of contiguous blocks. */ RTE_CACHE_GUARD; -} __rte_cache_aligned; +};#endif /** * A structure that stores a per-core object cache. */ -struct rte_mempool_cache { +struct __rte_cache_aligned rte_mempool_cache {uint32_t size;/**< Size of the cache */ uint32_t flushthresh;/**< Threshold before we flush excess elements */ uint32_t len;/**< Current cache count */
@@ -109,8 +110,8 @@ struct rte_mempool_cache {* Cache is allocated to this size to allow it to overflow in certain * cases to avoid needless emptying of cache. */ - void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 2] __rte_cache_aligned; -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE )void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE *2 ]; +};/** * A structure that stores the size of mempool elements.
@@ -218,15 +219,15 @@ struct rte_mempool_memhdr {* The structure is cache-line aligned to avoid ABI breakages in * a number of cases when something small is added. */ -struct rte_mempool_info { +struct __rte_cache_aligned rte_mempool_info {/** Number of objects in the contiguous block */ unsigned int contig_block_size; -} __rte_cache_aligned; +};/** * The RTE mempool structure. */ -struct rte_mempool { +struct __rte_cache_aligned rte_mempool {char name[RTE_MEMPOOL_NAMESIZE ];/**< Name of mempool. */ union {void *pool_data;/**< Ring or pool to store objects. */
@@ -268,7 +269,7 @@ struct rte_mempool {*/ struct rte_mempool_debug_stats stats[RTE_MAX_LCORE +1 ];#endif -} __rte_cache_aligned; +};/** Spreading among memory channels not required. */ #define RTE_MEMPOOL_F_NO_SPREAD 0x0001
@@ -688,7 +689,7 @@ typedef int (*rte_mempool_get_info_t)(const struct rte_mempool *mp,/** Structure defining mempool operations structure */ -struct rte_mempool_ops { +struct __rte_cache_aligned rte_mempool_ops {char name[RTE_MEMPOOL_OPS_NAMESIZE ];/**< Name of mempool ops struct. */ rte_mempool_alloc_t alloc;/**< Allocate private data. */ rte_mempool_free_t free;/**< Free the external pool. */
@@ -713,7 +714,7 @@ struct rte_mempool_ops {* Dequeue a number of contiguous object blocks. */ rte_mempool_dequeue_contig_blocks_t dequeue_contig_blocks; -} __rte_cache_aligned; +};#define RTE_MEMPOOL_MAX_OPS_IDX 16/**< Max registered ops structs */
@@ -726,14 +727,14 @@ struct rte_mempool_ops {* any function pointers stored directly in the mempool struct would not be. * This results in us simply having "ops_index" in the mempool struct. */ -struct rte_mempool_ops_table { +struct __rte_cache_aligned rte_mempool_ops_table {rte_spinlock_t sl;/**< Spinlock for add/delete. */ uint32_t num_ops;/**< Number of used ops structs in the table. */ /** * Storage for all possible ops structs. */ struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX ]; -} __rte_cache_aligned; +};/** Array of registered ops structs. */ extern struct rte_mempool_ops_table rte_mempool_ops_table;
Signature · 1 line
1.8.3.1
PATCH v7 28/39 member: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/member/rte_member.h | 8 ++++---- lib/member/rte_member_ht.h | 4 ++-- lib/member/rte_member_sketch.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
lib/member/rte_member.h +4 -4
@@ -139,7 +139,7 @@ typedef void (*sketch_delete_fn_t)(const struct rte_member_setsum *ss, const void *key);/** @internal setsummary structure. */ -struct rte_member_setsum { +struct __rte_cache_aligned rte_member_setsum {enum rte_member_setsum_type type;/* Type of the set summary. */ uint32_t key_len;/* Length of key. */ uint32_t prim_hash_seed;/* Primary hash function seed. */
@@ -185,14 +185,14 @@ struct rte_member_setsum {#ifdef RTE_ARCH_X86 bool use_avx512;#endif -} __rte_cache_aligned; +};/** * Parameters used when create the set summary table. Currently user can * specify two types of setsummary: HT based and vBF. For HT based, user can * specify cache or non-cache mode. Here is a table to describe some differences */ -struct rte_member_parameters { +struct __rte_cache_aligned rte_member_parameters {const char *name;/**< Name of the hash. */ /**
@@ -326,7 +326,7 @@ struct rte_member_parameters {uint32_t extra_flag;int socket_id;/**< NUMA Socket ID for memory. */ -} __rte_cache_aligned; +};/** * Find an existing set-summary and return a pointer to it.
lib/member/rte_member_ht.h +2 -2
@@ -15,10 +15,10 @@typedef uint16_t member_sig_t ;/* signature size is 16 bit */ /* The bucket struct for ht setsum */ -struct member_ht_bucket { +struct __rte_cache_aligned member_ht_bucket {member_sig_t sigs[RTE_MEMBER_BUCKET_ENTRIES ];/* 2-byte signature */ member_set_t sets[RTE_MEMBER_BUCKET_ENTRIES ];/* 2-byte set */ -} __rte_cache_aligned; +}; int rte_member_create_ht(struct rte_member_setsum *ss,
lib/member/rte_member_sketch.c +2 -2
@@ -23,7 +23,7 @@#include "rte_member_sketch_avx512.h" #endif /* CC_AVX512_SUPPORT */ -struct sketch_runtime { +struct __rte_cache_aligned sketch_runtime {uint64_t pkt_cnt;uint32_t until_next;int converged;
@@ -31,7 +31,7 @@ struct sketch_runtime {struct node *report_array;void *key_slots;struct rte_ring *free_key_slots; -} __rte_cache_aligned; +};/* * Geometric sampling to calculate how many packets needs to be
Signature · 1 line
1.8.3.1
PATCH v7 29/39 lpm: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/lpm/rte_lpm.h | 5 +++-- lib/lpm/rte_lpm6.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-)
lib/lpm/rte_lpm.h +3 -2
@@ -11,6 +11,7 @@* RTE Longest Prefix Match (LPM) */ +#include <stdalign.h> #include <errno.h> #include <stdint.h>
@@ -118,8 +119,8 @@ struct rte_lpm_config {/** @internal LPM structure. */ struct rte_lpm {/* LPM Tables. */ - struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] -__rte_cache_aligned ;/**< LPM tbl24 table. */ + alignas(RTE_CACHE_LINE_SIZE )struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES ]; +/**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8;/**< LPM tbl8 table. */ };
lib/lpm/rte_lpm6.c +4 -4
@@ -98,16 +98,16 @@ struct rte_lpm6 {/* LPM Tables. */ struct rte_hash *rules_tbl;/**< LPM rules. */ - struct rte_lpm6_tbl_entry tbl24[RTE_LPM6_TBL24_NUM_ENTRIES] - __rte_cache_aligned;/**< LPM tbl24 table. */ + alignas(RTE_CACHE_LINE_SIZE )struct rte_lpm6_tbl_entry tbl24[RTE_LPM6_TBL24_NUM_ENTRIES ]; +/**< LPM tbl24 table. */ uint32_t *tbl8_pool;/**< pool of indexes of free tbl8s */ uint32_t tbl8_pool_pos;/**< current position in the tbl8 pool */ struct rte_lpm_tbl8_hdr *tbl8_hdrs;/* array of tbl8 headers */ - struct rte_lpm6_tbl_entry tbl8[0] - __rte_cache_aligned;/**< LPM tbl8 table. */ + alignas(RTE_CACHE_LINE_SIZE )struct rte_lpm6_tbl_entry tbl8[0 ]; +/**< LPM tbl8 table. */ };/*
Signature · 1 line
1.8.3.1
PATCH v7 30/39 ipsec: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/ipsec/rte_ipsec.h | 4 ++-- lib/ipsec/sa.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
lib/ipsec/rte_ipsec.h +2 -2
@@ -55,7 +55,7 @@ struct rte_ipsec_sa_pkt_func {* - pointer to security/crypto session, plus other related data * - session/device specific functions to prepare/process IPsec packets. */ -struct rte_ipsec_session { +struct __rte_cache_aligned rte_ipsec_session {/** * SA that session belongs to. * Note that multiple sessions can belong to the same SA.
@@ -77,7 +77,7 @@ struct rte_ipsec_session { };/** functions to prepare/process IPsec packets */ struct rte_ipsec_sa_pkt_func pkt_func; -} __rte_cache_aligned; +};/** * Checks that inside given rte_ipsec_session crypto/security fields
lib/ipsec/sa.h +2 -2
@@ -75,7 +75,7 @@ enum sa_algo_type { ALGO_TYPE_MAX }; -struct rte_ipsec_sa { +struct __rte_cache_aligned rte_ipsec_sa {uint64_t type;/* type of given SA */ uint64_t udata;/* user defined */
@@ -141,7 +141,7 @@ struct rte_ipsec_sa { } errors; } statistics; -} __rte_cache_aligned; +}; int ipsec_sa_pkt_func_select(const struct rte_ipsec_session *ss,
Signature · 1 line
1.8.3.1
PATCH v7 31/39 jobstats: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/jobstats/rte_jobstats.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/jobstats/rte_jobstats.h +4 -4
@@ -32,7 +32,7 @@typedef void (*rte_job_update_period_cb_t )(struct rte_jobstats *job,int64_t job_result); -struct rte_jobstats { +struct __rte_cache_aligned rte_jobstats {uint64_t period;/**< Estimated period of execution. */
@@ -65,9 +65,9 @@ struct rte_jobstats {struct rte_jobstats_context *context;/**< Job stats context object that is executing this job. */ -} __rte_cache_aligned; +}; -struct rte_jobstats_context { +struct __rte_cache_aligned rte_jobstats_context {/** Variable holding time at different points: * -# loop start time if loop was started but no job executed yet. * -# job start time if job is currently executing.
@@ -111,7 +111,7 @@ struct rte_jobstats_context {uint64_t loop_cnt;/**< Total count of executed loops with at least one executed job. */ -} __rte_cache_aligned; +};/** * Initialize given context object with default values.
Signature · 1 line
1.8.3.1
PATCH v7 32/39 bpf: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/bpf/bpf_pkt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_pkt.c +2 -2
@@ -23,7 +23,7 @@* information about installed BPF rx/tx callback */ -struct bpf_eth_cbi { +struct __rte_cache_aligned bpf_eth_cbi {/* used by both data & control path */ RTE_ATOMIC (uint32_t ) use;/*usage counter */ const struct rte_eth_rxtx_callback *cb;/* callback handle */
@@ -33,7 +33,7 @@ struct bpf_eth_cbi {LIST_ENTRY (bpf_eth_cbi) link;uint16_t port;uint16_t queue; -} __rte_cache_aligned; +};/* * Odd number means that callback is used by datapath.
Signature · 1 line
1.8.3.1
PATCH v7 33/39 compressdev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/compressdev/rte_comp.h | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
lib/compressdev/rte_comp.h +2 -2
@@ -356,7 +356,7 @@ struct rte_comp_xform {* Comp operations are enqueued and dequeued in comp PMDs using the * rte_compressdev_enqueue_burst() / rte_compressdev_dequeue_burst() APIs */ -struct rte_comp_op { +struct __rte_cache_aligned rte_comp_op {enum rte_comp_op_type op_type;union {void *private_xform;
@@ -478,7 +478,7 @@ struct rte_comp_op {* will be set to RTE_COMP_OP_STATUS_SUCCESS after operation * is successfully processed by a PMD */ -} __rte_cache_aligned; +};/** * Creates an operation pool
lib/compressdev/rte_compressdev_internal.h +4 -4
@@ -69,7 +69,7 @@ typedef uint16_t (*compressdev_enqueue_pkt_burst_t)(void *qp, struct rte_comp_op **ops, uint16_t nb_ops);/** The data structure associated with each comp device. */ -struct rte_compressdev { +struct __rte_cache_aligned rte_compressdev {compressdev_dequeue_pkt_burst_t dequeue_burst;/**< Pointer to PMD receive function */ compressdev_enqueue_pkt_burst_t enqueue_burst;
@@ -87,7 +87,7 @@ struct rte_compressdev { __extension__ uint8_t attached : 1;/**< Flag indicating the device is attached */ -} __rte_cache_aligned; +};/** *
@@ -96,7 +96,7 @@ struct rte_compressdev {* This structure is safe to place in shared memory to be common among * different processes in a multi-process configuration. */ -struct rte_compressdev_data { +struct __rte_cache_aligned rte_compressdev_data {uint8_t dev_id;/**< Compress device identifier */ int socket_id;
@@ -115,7 +115,7 @@ struct rte_compressdev_data {void *dev_private;/**< PMD-specific private data */ -} __rte_cache_aligned; +}; #ifdef __cplusplus }
Signature · 1 line
1.8.3.1
PATCH v7 34/39 cryptodev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/cryptodev/cryptodev_pmd.h | 8 ++++---- lib/cryptodev/rte_cryptodev_core.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
lib/cryptodev/cryptodev_pmd.h +4 -4
@@ -61,7 +61,7 @@ struct rte_cryptodev_pmd_init_params {* This structure is safe to place in shared memory to be common among * different processes in a multi-process configuration. */ -struct rte_cryptodev_data { +struct __rte_cache_aligned rte_cryptodev_data {/** Device ID for this instance */ uint8_t dev_id;/** Socket ID where memory is allocated */
@@ -82,10 +82,10 @@ struct rte_cryptodev_data {/** PMD-specific private data */ void *dev_private; -} __rte_cache_aligned; +};/** @internal The data structure associated with each crypto device. */ -struct rte_cryptodev { +struct __rte_cache_aligned rte_cryptodev {/** Pointer to PMD dequeue function. */ dequeue_pkt_burst_t dequeue_burst;/** Pointer to PMD enqueue function. */
@@ -117,7 +117,7 @@ struct rte_cryptodev {struct rte_cryptodev_cb_rcu *enq_cbs;/** User application callback for post dequeue processing */ struct rte_cryptodev_cb_rcu *deq_cbs; -} __rte_cache_aligned; +};/** Global structure used for maintaining state of allocated crypto devices */ struct rte_cryptodev_global {
lib/cryptodev/rte_cryptodev_core.h +2 -2
@@ -40,7 +40,7 @@ struct rte_cryptodev_qpdata {struct rte_cryptodev_cb_rcu *deq_cb; }; -struct rte_crypto_fp_ops { +struct __rte_cache_aligned rte_crypto_fp_ops {/** PMD enqueue burst function. */ enqueue_pkt_burst_t enqueue_burst;/** PMD dequeue burst function. */
@@ -49,7 +49,7 @@ struct rte_crypto_fp_ops {struct rte_cryptodev_qpdata qp;/** Reserved for future ops. */ uintptr_t reserved[3 ]; -} __rte_cache_aligned; +};extern struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS ];
Signature · 1 line
1.8.3.1
PATCH v7 35/39 dispatcher: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/dispatcher/rte_dispatcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/dispatcher/rte_dispatcher.c +2 -2
@@ -41,7 +41,7 @@ struct rte_dispatcher_finalizer {void *finalize_data; }; -struct rte_dispatcher_lcore { +struct __rte_cache_aligned rte_dispatcher_lcore {uint8_t num_ports;uint16_t num_handlers;int32_t prio_count;
@@ -49,7 +49,7 @@ struct rte_dispatcher_lcore {struct rte_dispatcher_handler handlers[EVD_MAX_HANDLERS ];struct rte_dispatcher_stats stats;RTE_CACHE_GUARD ; -} __rte_cache_aligned; +};struct rte_dispatcher {uint8_t event_dev_id;
Signature · 1 line
1.8.3.1
PATCH v7 36/39 fib: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/fib/dir24_8.h | 4 +++- lib/fib/trie.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
lib/fib/dir24_8.h +3 -1
@@ -6,6 +6,8 @@#ifndef _DIR24_8_H_#define _DIR24_8_H_ +#include <stdalign.h> +#include <rte_prefetch.h> #include <rte_branch_prediction.h>
@@ -32,7 +34,7 @@ struct dir24_8_tbl {uint64_t *tbl8;/**< tbl8 table. */ uint64_t *tbl8_idxes;/**< bitmap containing free tbl8 idxes*/ /* tbl24 table. */ - __extension__ uint64_t tbl24[0] __rte_cache_aligned; + __extension__ alignas(RTE_CACHE_LINE_SIZE )uint64_t tbl24[0 ]; }; static inline void *
lib/fib/trie.h +3 -1
@@ -6,6 +6,8 @@#ifndef _TRIE_H_#define _TRIE_H_ +#include <stdalign.h> +/** * @file * RTE IPv6 Longest Prefix Match (LPM)
@@ -36,7 +38,7 @@ struct rte_trie_tbl {uint32_t *tbl8_pool;/**< bitmap containing free tbl8 idxes*/ uint32_t tbl8_pool_pos;/* tbl24 table. */ - __extension__ uint64_t tbl24[0] __rte_cache_aligned; + __extension__ alignas(RTE_CACHE_LINE_SIZE )uint64_t tbl24[0 ]; }; static inline uint32_t
Signature · 1 line
1.8.3.1
PATCH v7 37/39 gpudev: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/gpudev/gpudev_driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/gpudev/gpudev_driver.h +2 -2
@@ -72,7 +72,7 @@ struct rte_gpu_mpshared {RTE_ATOMIC (uint16_t ) process_refcnt;/* Updated by this library. */ }; -struct rte_gpu { +struct __rte_cache_aligned rte_gpu {/* Backing device. */ struct rte_device *device;/* Data shared between processes. */
@@ -85,7 +85,7 @@ struct rte_gpu {enum rte_gpu_state process_state;/* Updated by this library. */ /* Driver-specific private data for the running process. */ void *process_private; -} __rte_cache_aligned; +};__rte_internal struct rte_gpu *rte_gpu_get_by_name(const char *name);
Signature · 1 line
1.8.3.1
PATCH v7 38/39 graph: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- 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(-)
lib/graph/graph_private.h +2 -2
@@ -70,11 +70,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
lib/graph/graph_stats.c +2 -2
@@ -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, "+-------------------------------+---------------+--------" \
lib/graph/rte_graph.h +2 -2
@@ -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.
lib/graph/rte_graph_worker_common.h +10 -7
@@ -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
Signature · 1 line
1.8.3.1
PATCH v7 39/39 ip_frag: use C11 alignas
In reply to Tyler RetzlaffThe current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.
For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains.
To allow alignment for both compilers do the following:
* 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).
--- lib/ip_frag/ip_reassembly.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/ip_frag/ip_reassembly.h +4 -4
@@ -47,7 +47,7 @@ struct ip_frag_key {* Fragmented packet to reassemble. * First two entries in the frags[] array are for the last and first fragments. */ -struct ip_frag_pkt { +struct __rte_cache_aligned ip_frag_pkt {RTE_TAILQ_ENTRY (ip_frag_pkt) lru;/* LRU list */ struct ip_frag_key key;/* fragmentation key */ uint64_t start;/* creation timestamp */
@@ -55,20 +55,20 @@ struct ip_frag_pkt {uint32_t frag_size;/* size of fragments received */ uint32_t last_idx;/* index of next entry to fill */ struct ip_frag frags[IP_MAX_FRAG_NUM ];/* fragments */ -} __rte_cache_aligned; +};/* fragments tailq */ RTE_TAILQ_HEAD (ip_pkt_list, ip_frag_pkt);/* fragmentation table statistics */ -struct ip_frag_tbl_stat { +struct __rte_cache_aligned ip_frag_tbl_stat {uint64_t find_num;/* total # of find/insert attempts. */ uint64_t add_num;/* # of add ops. */ uint64_t del_num;/* # of del ops. */ uint64_t reuse_num;/* # of reuse (del/add) ops. */ uint64_t fail_total;/* total # of add failures. */ uint64_t fail_nospace;/* # of 'no space' add failures. */ -} __rte_cache_aligned; +};/* fragmentation table */ struct rte_ip_frag_tbl {
Signature · 1 line
1.8.3.1
Re: [PATCH v7 00/39] use C11 alignas
In reply to Tyler RetzlaffQuoted 13 lines · Tyler Retzlaff
The current location used for
__rte_aligned(a)for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of
__rte_aligned(a)to the aforementioned location accepted by all currently supported toolchains.
Quoted 5 lines
** NOTE **
Finally, In the interest of not creating more API (internal or not) the series does not introduce a wrapper for C11 alignas. If we don't introduce a macro an application can't take a dependency.
I have been looking into adding some check so that we catch new introductions of __rte_*aligned calls...
Wdyt of:
devtools/checkpatches.sh +4 -0
@@ -336,6 +336,21 @@ check_internal_tags() { # <patch> return $res } +check_aligned_attributes() { # <patch> + res=0 + + for token in __rte_aligned __rte_cache_aligned
__rte_cache_min_aligned; do
+ if [ $(grep -E '^\+.*\<'$token'\>' "$1" | \
+ grep -vE
'\<(struct|union)[[:space:]]*'$token'\>' | \
+ wc -l) != 0 ]; then
+ echo "Please only use $token for struct or
union types alignment."
+ res=1
+ fi
+ done
+
+ return $res
+}
+
check_release_notes() { # <patch>
rel_notes_prefix=doc/guides/rel_notes/release_ IFS=. read year month release < VERSION
@@ -445,6 +460,14 @@ check () { # <patch-file> <commit>
ret=1
fi+ ! $verbose || printf '\nChecking alignment attributes:\n'
+ report=$(check_aligned_attributes "$tmpinput")
+ if [ $? -ne 0 ] ; then
+ $headline_printed || print_headline "$subject"
+ printf '%s\n' "$report"
+ ret=1
+ fi
+
! $verbose || printf '\nChecking release notes updates:\n'
report=$(check_release_notes "$tmpinput")
if [ $? -ne 0 ] ; thenSignature · 1 line
David Marchand
Re: [PATCH v7 00/39] use C11 alignas
In reply to Tyler RetzlaffHello Tyler,
Quoted 13 lines · Tyler Retzlaff
The current location used for
__rte_aligned(a)for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of
__rte_aligned(a)to the aforementioned location accepted by all currently supported toolchains.
Quoted 5 lines
** NOTE **
Finally, In the interest of not creating more API (internal or not) the series does not introduce a wrapper for C11 alignas. If we don't introduce a macro an application can't take a dependency.
I reorganised the commits since those were global/mechanical changes in lib/.
As part of the alignas() conversion, I updated the references to __rte_*aligned in the documentation so that there is no "bad example" in doc/.
I converted the cacheline1 field to alignas in the mbuf library, but also in eventdev and security libraries.
With this, there is no remaining construct like struct|union { ... } __rte_*aligned in lib/.
I added a check in checkpatches.sh so that we don't reintroduce wrongly placed __rte_*aligned tags.
I made this check global (iow not restricted to lib/) so that developers touching drivers/ and other parts of DPDK are made aware of this change of use of __rte_*aligned tags.
Series applied.
Signature · 1 line
David Marchand
Re: [PATCH v7 00/39] use C11 alignas
Quoted 34 lines · David Marchand
Hello Tyler,
Quoted 13 lines · Tyler Retzlaff
The current location used for
__rte_aligned(a)for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains.For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC.
For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of
__rte_aligned(a)to the aforementioned location accepted by all currently supported toolchains.Quoted 5 lines
** NOTE **
Finally, In the interest of not creating more API (internal or not) the series does not introduce a wrapper for C11 alignas. If we don't introduce a macro an application can't take a dependency.
I reorganised the commits since those were global/mechanical changes in
lib/.As part of the
alignas()conversion, I updated the references to __rte_*aligned in the documentation so that there is no "bad example" in doc/.I converted the cacheline1 field to alignas in the mbuf library, but also in eventdev and security libraries.
With this, there is no remaining construct like struct|union { ... } __rte_*aligned inlib/.
Quoted 7 lines
I added a check in
checkpatches.shso that we don't reintroduce wrongly placed __rte_*aligned tags.
I made this check global (iow not restricted tolib/) so that developers touchingdrivers/and other parts of DPDK are made aware of this change of use of __rte_*aligned tags.Series applied.
Great to have this done, thank you David!
Quoted 3 lines
Signature · 2 lines
-- David Marchand