From: Dragos Tatulea <dtatulea@nvidia.com>
To: "Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Eugenio Perez Martin <eperezma@redhat.com>,
<virtualization@lists.linux-foundation.org>
Cc: Dragos Tatulea <dtatulea@nvidia.com>,
Si-Wei Liu <si-wei.liu@oracle.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Gal Pressman <gal@nvidia.com>,
Parav Pandit <parav@nvidia.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH vhost v2 06/10] vdpa/mlx5: Parallelize device suspend
Date: Fri, 16 Aug 2024 12:01:55 +0300 [thread overview]
Message-ID: <20240816090159.1967650-7-dtatulea@nvidia.com> (raw)
In-Reply-To: <20240816090159.1967650-1-dtatulea@nvidia.com>
Currently device suspend works on vqs serially. Building up on previous
changes that converted vq operations to the async api, this patch
parallelizes the device suspend:
1) Suspend all active vqs parallel.
2) Query suspended vqs in parallel.
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
~37 ms to ~13 ms.
A later patch will remove the link unregister operation which will make
it even faster.
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
---
drivers/vdpa/mlx5/net/mlx5_vnet.c | 56 ++++++++++++++++---------------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 9be7a88d71a7..5fba16c80dbb 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1630,49 +1630,51 @@ static int modify_virtqueues(struct mlx5_vdpa_net *ndev, int start_vq, int num_v
return err;
}
-static int suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
+static int suspend_vqs(struct mlx5_vdpa_net *ndev, int start_vq, int num_vqs)
{
- struct mlx5_virtq_attr attr;
+ struct mlx5_vdpa_virtqueue *mvq;
+ struct mlx5_virtq_attr *attrs;
+ int vq_idx, i;
int err;
+ if (start_vq >= ndev->cur_num_vqs)
+ return -EINVAL;
+
+ mvq = &ndev->vqs[start_vq];
if (!mvq->initialized)
return 0;
if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
return 0;
- err = modify_virtqueues(ndev, mvq->index, 1, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND);
- if (err) {
- mlx5_vdpa_err(&ndev->mvdev, "modify to suspend failed, err: %d\n", err);
- return err;
- }
-
- err = query_virtqueues(ndev, mvq->index, 1, &attr);
- if (err) {
- mlx5_vdpa_err(&ndev->mvdev, "failed to query virtqueue, err: %d\n", err);
+ err = modify_virtqueues(ndev, start_vq, num_vqs, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND);
+ if (err)
return err;
- }
-
- mvq->avail_idx = attr.available_index;
- mvq->used_idx = attr.used_index;
-
- return 0;
-}
-static int suspend_vqs(struct mlx5_vdpa_net *ndev)
-{
- int err = 0;
- int i;
+ attrs = kcalloc(num_vqs, sizeof(struct mlx5_virtq_attr), GFP_KERNEL);
+ if (!attrs)
+ return -ENOMEM;
- for (i = 0; i < ndev->cur_num_vqs; i++) {
- int local_err = suspend_vq(ndev, &ndev->vqs[i]);
+ err = query_virtqueues(ndev, start_vq, num_vqs, attrs);
+ if (err)
+ goto done;
- err = local_err ? local_err : err;
+ for (i = 0, vq_idx = start_vq; i < num_vqs; i++, vq_idx++) {
+ mvq = &ndev->vqs[vq_idx];
+ mvq->avail_idx = attrs[i].available_index;
+ mvq->used_idx = attrs[i].used_index;
}
+done:
+ kfree(attrs);
return err;
}
+static int suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
+{
+ return suspend_vqs(ndev, mvq->index, 1);
+}
+
static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
{
int err;
@@ -3053,7 +3055,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
bool teardown = !is_resumable(ndev);
int err;
- suspend_vqs(ndev);
+ suspend_vqs(ndev, 0, ndev->cur_num_vqs);
if (teardown) {
err = save_channels_info(ndev);
if (err)
@@ -3606,7 +3608,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
down_write(&ndev->reslock);
unregister_link_notifier(ndev);
- err = suspend_vqs(ndev);
+ err = suspend_vqs(ndev, 0, ndev->cur_num_vqs);
mlx5_vdpa_cvq_suspend(mvdev);
mvdev->suspended = true;
up_write(&ndev->reslock);
--
2.45.1
next prev parent reply other threads:[~2024-08-16 9:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 9:01 [PATCH vhost v2 00/10] vdpa/mlx5: Parallelize device suspend/resume Dragos Tatulea
2024-08-16 9:01 ` [PATCH mlx5-vhost v2 01/10] net/mlx5: Support throttled commands from async API Dragos Tatulea
2024-09-09 9:32 ` Dragos Tatulea
2024-09-11 8:00 ` Eugenio Perez Martin
2024-09-11 17:05 ` Dragos Tatulea
2024-08-16 9:01 ` [PATCH vhost v2 02/10] vdpa/mlx5: Introduce error logging function Dragos Tatulea
2024-08-16 9:01 ` [PATCH vhost v2 03/10] vdpa/mlx5: Introduce async fw command wrapper Dragos Tatulea
2024-08-28 12:34 ` Eugenio Perez Martin
2024-08-16 9:01 ` [PATCH vhost v2 04/10] vdpa/mlx5: Use async API for vq query command Dragos Tatulea
2024-08-28 12:34 ` Eugenio Perez Martin
2024-08-16 9:01 ` [PATCH vhost v2 05/10] vdpa/mlx5: Use async API for vq modify commands Dragos Tatulea
2024-08-28 12:35 ` Eugenio Perez Martin
2024-08-16 9:01 ` Dragos Tatulea [this message]
2024-08-16 9:01 ` [PATCH vhost v2 07/10] vdpa/mlx5: Parallelize device resume Dragos Tatulea
2024-08-16 9:01 ` [PATCH vhost v2 08/10] vdpa/mlx5: Keep notifiers during suspend but ignore Dragos Tatulea
2024-08-16 9:01 ` [PATCH vhost v2 09/10] vdpa/mlx5: Small improvement for change_num_qps() Dragos Tatulea
2024-08-28 12:48 ` Eugenio Perez Martin
2024-08-16 9:01 ` [PATCH vhost v2 10/10] vdpa/mlx5: Parallelize VQ suspend/resume for CVQ MQ command Dragos Tatulea
2024-08-28 12:59 ` Eugenio Perez Martin
[not found] ` <CAJaqyWfwkNUYcMWwG4LthhYEquUYDJPRvHeyh9C_R-ioeFYuXw@mail.gmail.com>
2024-09-02 10:03 ` [PATCH vhost v2 00/10] vdpa/mlx5: Parallelize device suspend/resume Lei Yang
2024-09-02 11:05 ` Dragos Tatulea
2024-09-03 7:40 ` Lei Yang
2024-09-03 7:47 ` Dragos Tatulea
2024-09-03 8:10 ` Eugenio Perez Martin
2024-09-03 8:16 ` 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=20240816090159.1967650-7-dtatulea@nvidia.com \
--to=dtatulea@nvidia.com \
--cc=eperezma@redhat.com \
--cc=gal@nvidia.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=si-wei.liu@oracle.com \
--cc=tariqt@nvidia.com \
--cc=virtualization@lists.linux-foundation.org \
--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
all inboxes | Powered by JetHome®