Skip to content

Commit 5eb8c7e

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Parallelize device resume
Currently device resume works on vqs serially. Building up on previous changes that converted vq operations to the async api, this patch parallelizes the device resume. 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 resume time is reduced from ~16 ms to ~4.5 ms. Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Acked-by: Eugenio Pérez <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Tested-by: Lei Yang <[email protected]>
1 parent dcf3eac commit 5eb8c7e

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,10 +1675,15 @@ static int suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mv
16751675
return suspend_vqs(ndev, mvq->index, 1);
16761676
}
16771677

1678-
static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
1678+
static int resume_vqs(struct mlx5_vdpa_net *ndev, int start_vq, int num_vqs)
16791679
{
1680+
struct mlx5_vdpa_virtqueue *mvq;
16801681
int err;
16811682

1683+
if (start_vq >= ndev->mvdev.max_vqs)
1684+
return -EINVAL;
1685+
1686+
mvq = &ndev->vqs[start_vq];
16821687
if (!mvq->initialized)
16831688
return 0;
16841689

@@ -1690,13 +1695,9 @@ static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq
16901695
/* Due to a FW quirk we need to modify the VQ fields first then change state.
16911696
* This should be fixed soon. After that, a single command can be used.
16921697
*/
1693-
err = modify_virtqueues(ndev, mvq->index, 1, mvq->fw_state);
1694-
if (err) {
1695-
mlx5_vdpa_err(&ndev->mvdev,
1696-
"modify vq properties failed for vq %u, err: %d\n",
1697-
mvq->index, err);
1698+
err = modify_virtqueues(ndev, start_vq, num_vqs, mvq->fw_state);
1699+
if (err)
16981700
return err;
1699-
}
17001701
break;
17011702
case MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND:
17021703
if (!is_resumable(ndev)) {
@@ -1712,25 +1713,12 @@ static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq
17121713
return -EINVAL;
17131714
}
17141715

1715-
err = modify_virtqueues(ndev, mvq->index, 1, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY);
1716-
if (err)
1717-
mlx5_vdpa_err(&ndev->mvdev, "modify to resume failed for vq %u, err: %d\n",
1718-
mvq->index, err);
1719-
1720-
return err;
1716+
return modify_virtqueues(ndev, start_vq, num_vqs, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY);
17211717
}
17221718

1723-
static int resume_vqs(struct mlx5_vdpa_net *ndev)
1719+
static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
17241720
{
1725-
int err = 0;
1726-
1727-
for (int i = 0; i < ndev->cur_num_vqs; i++) {
1728-
int local_err = resume_vq(ndev, &ndev->vqs[i]);
1729-
1730-
err = local_err ? local_err : err;
1731-
}
1732-
1733-
return err;
1721+
return resume_vqs(ndev, mvq->index, 1);
17341722
}
17351723

17361724
static void teardown_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
@@ -3080,7 +3068,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
30803068
return err;
30813069
}
30823070

3083-
resume_vqs(ndev);
3071+
resume_vqs(ndev, 0, ndev->cur_num_vqs);
30843072

30853073
return 0;
30863074
}
@@ -3204,7 +3192,7 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
32043192
teardown_vq_resources(ndev);
32053193

32063194
if (ndev->setup) {
3207-
err = resume_vqs(ndev);
3195+
err = resume_vqs(ndev, 0, ndev->cur_num_vqs);
32083196
if (err) {
32093197
mlx5_vdpa_warn(mvdev, "failed to resume VQs\n");
32103198
goto err_driver;
@@ -3628,7 +3616,7 @@ static int mlx5_vdpa_resume(struct vdpa_device *vdev)
36283616

36293617
down_write(&ndev->reslock);
36303618
mvdev->suspended = false;
3631-
err = resume_vqs(ndev);
3619+
err = resume_vqs(ndev, 0, ndev->cur_num_vqs);
36323620
register_link_notifier(ndev);
36333621
up_write(&ndev->reslock);
36343622

0 commit comments

Comments
 (0)