netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] mlx5/core: avoid memory barrier in eq_update_ci()
@ 2024-11-01  3:46 Caleb Sander Mateos
  2024-11-01  3:46 ` [PATCH net-next 2/2] mlx5/core: deduplicate {mlx5_,}eq_update_ci() Caleb Sander Mateos
  0 siblings, 1 reply; 19+ messages in thread
From: Caleb Sander Mateos @ 2024-11-01  3:46 UTC (permalink / raw)
  To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Caleb Sander Mateos, netdev, linux-rdma, linux-kernel

The memory barrier in eq_update_ci() after the doorbell write is a
significant hot spot in mlx5_eq_comp_int(). Under heavy TCP load, we see
3% of CPU time spent on the mfence. As explained in [1], this barrier is
only needed to preserve the ordering of writes to the doorbell register.

Use writel() instead of __raw_writel() for the doorbell write to provide
this ordering without the need for a full memory barrier.
memory-barriers.txt guarantees MMIO writes using writel() appear to the
device in the same order they were made. On strongly-ordered
architectures like x86, writel() adds no overhead to __raw_writel();
both translate into a single store instruction. Removing the mb() avoids
the costly mfence instruction.

[1]: https://lore.kernel.org/netdev/CALzJLG8af0SMfA1C8U8r_Fddb_ZQhvEZd6=2a97dOoBcgLA0xg@mail.gmail.com/

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
index 4b7f7131c560..f03736711343 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
@@ -68,13 +68,12 @@ static inline struct mlx5_eqe *next_eqe_sw(struct mlx5_eq *eq)
 static inline void eq_update_ci(struct mlx5_eq *eq, int arm)
 {
 	__be32 __iomem *addr = eq->doorbell + (arm ? 0 : 2);
 	u32 val = (eq->cons_index & 0xffffff) | (eq->eqn << 24);
 
-	__raw_writel((__force u32)cpu_to_be32(val), addr);
-	/* We still want ordering, just not swabbing, so add a barrier */
-	mb();
+	/* Ensure ordering of consecutive doorbell writes */
+	writel((__force u32)cpu_to_be32(val), addr);
 }
 
 int mlx5_eq_table_init(struct mlx5_core_dev *dev);
 void mlx5_eq_table_cleanup(struct mlx5_core_dev *dev);
 int mlx5_eq_table_create(struct mlx5_core_dev *dev);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-11-12  2:38 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01  3:46 [PATCH net-next 1/2] mlx5/core: avoid memory barrier in eq_update_ci() Caleb Sander Mateos
2024-11-01  3:46 ` [PATCH net-next 2/2] mlx5/core: deduplicate {mlx5_,}eq_update_ci() Caleb Sander Mateos
2024-11-03  3:55   ` Parav Pandit
2024-11-03 22:18     ` Caleb Sander
2024-11-05  5:22       ` Parav Pandit
2024-11-05 16:06         ` Caleb Sander
2024-11-06  5:44           ` Parav Pandit
2024-11-06 23:44             ` Caleb Sander
2024-11-07  2:36               ` Saeed Mahameed
2024-11-07  2:43                 ` Parav Pandit
2024-11-07  4:45                 ` Caleb Sander
2024-11-07  5:14                   ` Saeed Mahameed
2024-11-07 18:30                     ` [PATCH net-next v2 1/2] mlx5/core: relax memory barrier in eq_update_ci() Caleb Sander Mateos
2024-11-07 18:30                       ` [PATCH net-next v2 2/2] mlx5/core: deduplicate {mlx5_,}eq_update_ci() Caleb Sander Mateos
2024-11-08 10:49                         ` Parav Pandit
2024-11-11 11:59                           ` Tariq Toukan
2024-11-08 10:46                       ` [PATCH net-next v2 1/2] mlx5/core: relax memory barrier in eq_update_ci() Parav Pandit
2024-11-11 11:59                         ` Tariq Toukan
2024-11-12  2:38                       ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).