From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>
Cc: Carolina Jubran <cjubran@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
"Leon Romanovsky" <leon@kernel.org>, <linux-rdma@vger.kernel.org>,
Mark Bloch <mbloch@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>, Shay Drori <shayd@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next 1/2] net/mlx5: Avoid RCU synchronization when detaching IRQ notifiers
Date: Sun, 29 Nov 2026 13:27:05 +0200 [thread overview]
Message-ID: <20261129112706.1797994-2-tariqt@nvidia.com> (raw)
In-Reply-To: <20261129112706.1797994-1-tariqt@nvidia.com>
From: Carolina Jubran <cjubran@nvidia.com>
EQ teardown unregisters IRQ notifiers individually, with each
unregister waiting for an RCU grace period. This introduces
significant latency when destroying multiple EQs.
The IRQ notifier chain is walked only by the handler of the same IRQ,
so once a notifier is unlinked, synchronize_irq() is enough to ensure
no handler still uses it.
Use a raw notifier chain and synchronize_irq() instead.
Measurements of "rmmod mlx5_ib mlx5_dpll mlx5_fwctl mlx5_core", with
rcu_expedited=0, two PFs, and 72 channels per PF:
Before: 6.316 s, 239 synchronize_rcu() calls
After: 4.287 s, 89 synchronize_rcu() calls
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/pci_irq.c | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
index 2bcafc572a42..4bf1af8ef205 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
@@ -4,6 +4,7 @@
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/notifier.h>
+#include <linux/rcupdate.h>
#include <linux/mlx5/driver.h>
#include <linux/mlx5/vport.h>
#include "mlx5_core.h"
@@ -28,7 +29,9 @@
#define MLX5_EQ_SHARE_IRQ_MIN_CTRL (4)
struct mlx5_irq {
- struct atomic_notifier_head nh;
+ /* Walked only by irq_int_handler(), see mlx5_irq_detach_nb() */
+ struct raw_notifier_head nh;
+ spinlock_t nh_lock; /* serializes nh updates */
cpumask_var_t mask;
char name[MLX5_MAX_IRQ_FORMATTED_NAME];
struct mlx5_irq_pool *pool;
@@ -213,7 +216,9 @@ static int irq_get(struct mlx5_irq *irq)
static irqreturn_t irq_int_handler(int irq, void *nh)
{
- atomic_notifier_call_chain(nh, 0, NULL);
+ rcu_read_lock();
+ raw_notifier_call_chain(nh, 0, NULL);
+ rcu_read_unlock();
return IRQ_HANDLED;
}
@@ -281,7 +286,8 @@ struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
irq_set_name(pool, name, i);
else
irq_sf_set_name(pool, name, i);
- ATOMIC_INIT_NOTIFIER_HEAD(&irq->nh);
+ RAW_INIT_NOTIFIER_HEAD(&irq->nh);
+ spin_lock_init(&irq->nh_lock);
snprintf(irq->name, MLX5_MAX_IRQ_FORMATTED_NAME,
MLX5_IRQ_NAME_FORMAT_STR, name, pci_name(dev->pdev));
err = request_irq(irq->map.virq, irq_int_handler, 0, irq->name,
@@ -325,6 +331,7 @@ struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
int mlx5_irq_attach_nb(struct mlx5_irq *irq, struct notifier_block *nb)
{
+ unsigned long flags;
int ret;
ret = irq_get(irq);
@@ -333,7 +340,9 @@ int mlx5_irq_attach_nb(struct mlx5_irq *irq, struct notifier_block *nb)
* on non-existing IRQ.
*/
return -ENOENT;
- ret = atomic_notifier_chain_register(&irq->nh, nb);
+ spin_lock_irqsave(&irq->nh_lock, flags);
+ ret = raw_notifier_chain_register(&irq->nh, nb);
+ spin_unlock_irqrestore(&irq->nh_lock, flags);
if (ret)
mlx5_irq_put(irq);
return ret;
@@ -341,9 +350,16 @@ int mlx5_irq_attach_nb(struct mlx5_irq *irq, struct notifier_block *nb)
int mlx5_irq_detach_nb(struct mlx5_irq *irq, struct notifier_block *nb)
{
- int err = 0;
+ unsigned long flags;
+ int err;
- err = atomic_notifier_chain_unregister(&irq->nh, nb);
+ spin_lock_irqsave(&irq->nh_lock, flags);
+ err = raw_notifier_chain_unregister(&irq->nh, nb);
+ spin_unlock_irqrestore(&irq->nh_lock, flags);
+ /* The chain is walked only by irq_int_handler(), so waiting for
+ * in flight handlers is enough to stop using nb.
+ */
+ synchronize_irq(irq->map.virq);
mlx5_irq_put(irq);
return err;
}
--
2.44.0
next prev parent reply other threads:[~2026-11-29 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 11:27 [PATCH net-next 0/2] net/mlx5: Speed up device teardown by avoiding RCU grace periods Tariq Toukan
2026-11-29 11:27 ` Tariq Toukan [this message]
2026-11-29 11:27 ` [PATCH net-next 2/2] net/mlx5: Use a single EQ notifier for core events Tariq Toukan
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=20261129112706.1797994-2-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
--cc=willemb@google.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