Skip to contentSkip to conversation

net/mlx5: remove counter alignment

PATCH Superseded Rongwei Liu 3 participants 5 messages Oct 28, 2025 – Nov 2, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: remove counter alignment

The memory footprint was increased due to the alignment.

---
 drivers/net/mlx5/mlx5_hws_cnt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_hws_cnt.h +2 -2
index f5b7e8f643..d19a7bf37e 100644
@@ -43,7 +43,7 @@ struct mlx5_hws_cnt_dcs_mng {
 };
 
 union mlx5_hws_cnt_state {
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)data;
+	RTE_ATOMIC(uint32_t)data;
 	struct {
 		uint32_t in_used:1;
 		/* Indicator whether this counter in used or in pool. */
@@ -64,7 +64,7 @@ struct mlx5_hws_cnt {
 	struct flow_counter_stats reset;
 	union mlx5_hws_cnt_state cnt_state;
 	/* This struct is only meaningful when user own this counter. */
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)query_gen_when_free;
+	RTE_ATOMIC(uint32_t)query_gen_when_free;
 	/*
 	 * When PMD own this counter (user put back counter to PMD
 	 * counter pool, i.e), this field recorded value of counter
Signature · 1 line
2.27.0
#1 lore raw

Hi,

Quoted 1 line · Rongwei Liu

The memory footprint was increased due to the alignment.

s/alignment/overalignment/

For clarity that the relevant fields were overaligned.

Quoted 3 lines

---

Since this is a bug fix, please add Fixes tag for the following commit:

	820ca7361bb7 ("net/mlx5: fix flow aging race condition")

Cc-ing to stable mailing list won't be needed,
because the offending patch is only in 25.11-rc1

drivers/net/mlx5/mlx5_hws_cnt.h struct mlx5_hws_cnt_dcs_mng { · line 46

Quoted 13 lines
 drivers/net/mlx5/mlx5_hws_cnt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_hws_cnt.h +1 -1
index f5b7e8f643..d19a7bf37e 100644
@@ -43,7 +43,7 @@ struct mlx5_hws_cnt_dcs_mng {
 };
 
 union mlx5_hws_cnt_state {
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)data;
+	RTE_ATOMIC(uint32_t)data;

Please add a space between RTE_ATOMIC(uint32_t) and data.

drivers/net/mlx5/mlx5_hws_cnt.h struct mlx5_hws_cnt { · line 67

Quoted 9 lines
drivers/net/mlx5/mlx5_hws_cnt.h +1 -1
 	struct {
 		uint32_t in_used:1;
 		/* Indicator whether this counter in used or in pool. */
@@ -64,7 +64,7 @@ struct mlx5_hws_cnt {
 	struct flow_counter_stats reset;
 	union mlx5_hws_cnt_state cnt_state;
 	/* This struct is only meaningful when user own this counter. */
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)query_gen_when_free;
+	RTE_ATOMIC(uint32_t)query_gen_when_free;

Same as above.

Quoted 6 lines
drivers/net/mlx5/mlx5_hws_cnt.h +0 -0
 	/*
 	 * When PMD own this counter (user put back counter to PMD
 	 * counter pool, i.e), this field recorded value of counter
Signature · 1 line
2.27.0

Best regards,
Dariusz Sosnowski

#2 lore raw

PATCH v2 1/1 net/mlx5: remove counter alignment

The memory footprint was increased due to the alignment.

Fixes 820ca7361bb7fa4 ("net/mlx5: fix flow aging race condition")
---
 drivers/net/mlx5/mlx5_hws_cnt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_hws_cnt.h +2 -2
index f5b7e8f643..8d7a9d34df 100644
@@ -43,7 +43,7 @@ struct mlx5_hws_cnt_dcs_mng {
 };
 
 union mlx5_hws_cnt_state {
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)data;
+	RTE_ATOMIC(uint32_t) data;
 	struct {
 		uint32_t in_used:1;
 		/* Indicator whether this counter in used or in pool. */
@@ -64,7 +64,7 @@ struct mlx5_hws_cnt {
 	struct flow_counter_stats reset;
 	union mlx5_hws_cnt_state cnt_state;
 	/* This struct is only meaningful when user own this counter. */
-	alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t)query_gen_when_free;
+	RTE_ATOMIC(uint32_t) query_gen_when_free;
 	/*
 	 * When PMD own this counter (user put back counter to PMD
 	 * counter pool, i.e), this field recorded value of counter
Signature · 1 line
2.27.0