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 2/2] net/mlx5: Use a single EQ notifier for core events
Date: Sun, 29 Nov 2026 13:27:06 +0200 [thread overview]
Message-ID: <20261129112706.1797994-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20261129112706.1797994-1-tariqt@nvidia.com>
From: Carolina Jubran <cjubran@nvidia.com>
mlx5_events_start() registers 18 EQ notifiers, one per event type
handled by the core, and mlx5_events_stop() unregisters them one by
one. Each unregister waits for an RCU grace period, which adds
significant latency to device teardown.
Register a single NOTIFY_ANY notifier and dispatch the events by type,
so mlx5_events_stop() waits for one grace period instead of 18.
Measurements of "rmmod mlx5_ib mlx5_dpll mlx5_fwctl mlx5_core", with
rcu_expedited=0, two PFs, 72 channels per PF and with the IRQ notifier
optimization already applied:
Before: 4.287 s
After: 3.878 s
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/events.c | 78 ++++++++++---------
1 file changed, 42 insertions(+), 36 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
index 4d7f35b96876..56c06edd6770 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/events.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
@@ -27,36 +27,10 @@ static int pcie_core(struct notifier_block *, unsigned long, void *);
/* handler which forwards the event to events->fw_nh, driver notifiers */
static int forward_event(struct notifier_block *, unsigned long, void *);
-static struct mlx5_nb events_nbs_ref[] = {
- /* Events to be processed by mlx5_core */
- {.nb.notifier_call = any_notifier, .event_type = MLX5_EVENT_TYPE_NOTIFY_ANY },
- {.nb.notifier_call = temp_warn, .event_type = MLX5_EVENT_TYPE_TEMP_WARN_EVENT },
- {.nb.notifier_call = port_module, .event_type = MLX5_EVENT_TYPE_PORT_MODULE_EVENT },
- {.nb.notifier_call = pcie_core, .event_type = MLX5_EVENT_TYPE_GENERAL_EVENT },
-
- /* Events to be forwarded (as is) to mlx5 core interfaces (mlx5e/mlx5_ib) */
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_PORT_CHANGE },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_GENERAL_EVENT },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_OBJECT_CHANGE },
- /* QP/WQ resource events to forward */
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_DCT_DRAINED },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_PATH_MIG },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_COMM_EST },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_SQ_DRAINED },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_SRQ_LAST_WQE },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_WQ_CATAS_ERROR },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_PATH_MIG_FAILED },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_WQ_ACCESS_ERROR },
- /* SRQ events */
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_SRQ_CATAS_ERROR },
- {.nb.notifier_call = forward_event, .event_type = MLX5_EVENT_TYPE_SRQ_RQ_LIMIT },
-};
-
struct mlx5_events {
struct mlx5_core_dev *dev;
struct workqueue_struct *wq;
- struct mlx5_event_nb notifiers[ARRAY_SIZE(events_nbs_ref)];
+ struct mlx5_event_nb notifier;
/* driver notifier chain for fw events */
struct atomic_notifier_head fw_nh;
/* port module events stats */
@@ -372,6 +346,42 @@ static int forward_event(struct notifier_block *nb, unsigned long event, void *d
return NOTIFY_OK;
}
+/* Dispatch internal events through a single EQ notifier. */
+static int mlx5_event_dispatch(struct notifier_block *nb, unsigned long type,
+ void *data)
+{
+ switch (type) {
+ case MLX5_EVENT_TYPE_TEMP_WARN_EVENT:
+ temp_warn(nb, type, data);
+ break;
+ case MLX5_EVENT_TYPE_PORT_MODULE_EVENT:
+ port_module(nb, type, data);
+ break;
+ case MLX5_EVENT_TYPE_GENERAL_EVENT:
+ pcie_core(nb, type, data);
+ fallthrough;
+ case MLX5_EVENT_TYPE_COMM_EST:
+ case MLX5_EVENT_TYPE_DCT_DRAINED:
+ case MLX5_EVENT_TYPE_OBJECT_CHANGE:
+ case MLX5_EVENT_TYPE_PATH_MIG:
+ case MLX5_EVENT_TYPE_PATH_MIG_FAILED:
+ case MLX5_EVENT_TYPE_PORT_CHANGE:
+ case MLX5_EVENT_TYPE_SQ_DRAINED:
+ case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR:
+ case MLX5_EVENT_TYPE_SRQ_LAST_WQE:
+ case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT:
+ case MLX5_EVENT_TYPE_WQ_ACCESS_ERROR:
+ case MLX5_EVENT_TYPE_WQ_CATAS_ERROR:
+ case MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR:
+ forward_event(nb, type, data);
+ break;
+ default:
+ break;
+ }
+
+ return any_notifier(nb, type, data);
+}
+
int mlx5_events_init(struct mlx5_core_dev *dev)
{
struct mlx5_events *events = kzalloc_obj(*events);
@@ -402,22 +412,18 @@ void mlx5_events_cleanup(struct mlx5_core_dev *dev)
void mlx5_events_start(struct mlx5_core_dev *dev)
{
struct mlx5_events *events = dev->priv.events;
- int i;
- for (i = 0; i < ARRAY_SIZE(events_nbs_ref); i++) {
- events->notifiers[i].nb = events_nbs_ref[i];
- events->notifiers[i].ctx = events;
- mlx5_eq_notifier_register(dev, &events->notifiers[i].nb);
- }
+ events->notifier.nb.nb.notifier_call = mlx5_event_dispatch;
+ events->notifier.nb.event_type = MLX5_EVENT_TYPE_NOTIFY_ANY;
+ events->notifier.ctx = events;
+ mlx5_eq_notifier_register(dev, &events->notifier.nb);
}
void mlx5_events_stop(struct mlx5_core_dev *dev)
{
struct mlx5_events *events = dev->priv.events;
- int i;
- for (i = ARRAY_SIZE(events_nbs_ref) - 1; i >= 0 ; i--)
- mlx5_eq_notifier_unregister(dev, &events->notifiers[i].nb);
+ mlx5_eq_notifier_unregister(dev, &events->notifier.nb);
flush_workqueue(events->wq);
}
--
2.44.0
next prev parent reply other threads:[~2026-11-29 11:27 UTC|newest]
Thread overview: 4+ 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 ` [PATCH net-next 1/2] net/mlx5: Avoid RCU synchronization when detaching IRQ notifiers Tariq Toukan
2026-11-29 11:27 ` Tariq Toukan [this message]
2026-11-29 11:33 ` [PATCH net-next 0/2] net/mlx5: Speed up device teardown by avoiding RCU grace periods sashiko-bot
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-3-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