From: Caleb Sander Mateos <csander@purestorage.com>
To: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Parav Pandit <parav@nvidia.com>,
Caleb Sander Mateos <csander@purestorage.com>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next v2 1/2] mlx5/core: relax memory barrier in eq_update_ci()
Date: Thu, 7 Nov 2024 11:30:51 -0700 [thread overview]
Message-ID: <20241107183054.2443218-1-csander@purestorage.com> (raw)
In-Reply-To: <ZyxMsx8o7NtTAWPp@x130>
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 instruction.
98df6d5b877c ("net/mlx5: A write memory barrier is sufficient in EQ ci
update") already relaxed the full memory barrier to just a write barrier
in mlx5_eq_update_ci(), which duplicates eq_update_ci(). So replace mb()
with wmb() in eq_update_ci() too.
On strongly ordered architectures, no barrier is actually needed because
the MMIO writes to the doorbell register are guaranteed to appear to the
device in the order they were made. However, the kernel's ordered MMIO
primitive writel() lacks a convenient big-endian interface.
Therefore, we opt to stick with __raw_writel() + a barrier.
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
v2: keep memory barrier instead of using ordered writel()
drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
index 4b7f7131c560..b1edc71ffc6d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h
@@ -70,11 +70,11 @@ 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();
+ wmb();
}
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
next prev parent reply other threads:[~2024-11-07 18:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Caleb Sander Mateos [this message]
2024-11-07 18:30 ` [PATCH net-next v2 " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241107183054.2443218-1-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).