public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dragos Tatulea <dtatulea@nvidia.com>
To: "Dragos Tatulea" <dtatulea@nvidia.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>
Cc: Si-Wei Liu <si-wei.liu@oracle.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	<virtualization@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: [PATCH vhost 7/7] vdpa/mlx5: Keep notifiers during suspend but ignore
Date: Fri, 2 Aug 2024 10:20:24 +0300	[thread overview]
Message-ID: <20240802072039.267446-8-dtatulea@nvidia.com> (raw)
In-Reply-To: <20240802072039.267446-1-dtatulea@nvidia.com>

Unregistering notifiers is a costly operation. Instead of removing
the notifiers during device suspend and adding them back at resume,
simply ignore the call when the device is suspended.

At resume time call queue_link_work() to make sure that the device state
is propagated in case there were changes.

For 1 vDPA device x 32 VQs (16 VQPs) attached to a large VM (256 GB RAM,
32 CPUs x 2 threads per core), the device suspend time is reduced from
~13 ms to ~2.5 ms.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 87d355aba380..af96e49697d0 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -2934,6 +2934,9 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p
 	struct mlx5_eqe *eqe = param;
 	int ret = NOTIFY_DONE;
 
+	if (ndev->mvdev.suspended)
+		return NOTIFY_DONE;
+
 	if (event == MLX5_EVENT_TYPE_PORT_CHANGE) {
 		switch (eqe->sub_type) {
 		case MLX5_PORT_CHANGE_SUBTYPE_DOWN:
@@ -3679,7 +3682,6 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
 	mlx5_vdpa_info(mvdev, "suspending device\n");
 
 	down_write(&ndev->reslock);
-	unregister_link_notifier(ndev);
 	err = suspend_vqs(ndev, 0, ndev->cur_num_vqs);
 	mlx5_vdpa_cvq_suspend(mvdev);
 	mvdev->suspended = true;
@@ -3701,7 +3703,7 @@ static int mlx5_vdpa_resume(struct vdpa_device *vdev)
 	down_write(&ndev->reslock);
 	mvdev->suspended = false;
 	err = resume_vqs(ndev, 0, ndev->cur_num_vqs);
-	register_link_notifier(ndev);
+	queue_link_work(ndev);
 	up_write(&ndev->reslock);
 
 	return err;
-- 
2.45.2


  parent reply	other threads:[~2024-08-02  7:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  7:20 [PATCH vhost 0/7] vdpa/mlx5: Parallelize device suspend/resume Dragos Tatulea
2024-08-02  7:20 ` [PATCH mlx5-vhost 1/7] net/mlx5: Support throttled commands from async API Dragos Tatulea
2024-08-02  7:20 ` [PATCH vhost 2/7] vdpa/mlx5: Introduce error logging function Dragos Tatulea
2024-08-06 17:57   ` Eugenio Perez Martin
2024-08-02  7:20 ` [PATCH vhost 3/7] vdpa/mlx5: Use async API for vq query command Dragos Tatulea
2024-08-02  7:20 ` [PATCH vhost 4/7] vdpa/mlx5: Use async API for vq modify commands Dragos Tatulea
2024-08-07 13:12   ` Eugenio Perez Martin
2024-08-02  7:20 ` [PATCH vhost 5/7] vdpa/mlx5: Parallelize device suspend Dragos Tatulea
2024-08-02  7:20 ` [PATCH vhost 6/7] vdpa/mlx5: Parallelize device resume Dragos Tatulea
2024-08-02  7:20 ` Dragos Tatulea [this message]
2024-08-02 13:14 ` [PATCH vhost 0/7] vdpa/mlx5: Parallelize device suspend/resume Michael S. Tsirkin
2024-08-04  8:48   ` Leon Romanovsky
2024-08-04 13:39     ` Michael S. Tsirkin
2024-08-04 14:52       ` Leon Romanovsky
2024-08-16  9:13   ` Dragos Tatulea
2024-08-07 13:25 ` Eugenio Perez Martin
2024-08-07 14:54   ` Dragos Tatulea

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=20240802072039.267446-8-dtatulea@nvidia.com \
    --to=dtatulea@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=tariqt@nvidia.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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