vfio/mlx5: Pre-allocate chunks for the STOP_COPY phase
authorYishai Hadas <yishaih@nvidia.com>
Mon, 11 Sep 2023 09:38:53 +0000 (12:38 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 28 Sep 2023 19:07:29 +0000 (13:07 -0600)
commit5798e4dd584f23bb5a4db4c524522c4dd8a84a78
treefff2c42224ad108961eee8a1c6eaf8bd2cec54e4
parent9114100d10b3e970857afd0bc2f296e147fc9392
vfio/mlx5: Pre-allocate chunks for the STOP_COPY phase

This patch is another preparation step towards working in chunk mode.

It pre-allocates chunks for the STOP_COPY phase to let the driver use
them immediately and prevent an extra allocation upon that phase.

Before that patch we had a single large buffer that was dedicated for
the STOP_COPY phase as there was a single SAVE in the source for the
last image.

Once we'll move to chunk mode the idea is to have some small buffers
that will be used upon the STOP_COPY phase.

The driver will read-ahead from the firmware the full state in
small/optimized chunks while letting QEMU/user space read in parallel
the available data.

Each buffer holds its chunk number to let it be recognized down the road
in the coming patches.

The chunk buffer size is picked-up based on the minimum size that
firmware requires, the total full size and some max value in the driver
code which was set to 8MB to achieve some optimized downtime in the
general case.

As the chunk mode is applicable even if we move directly to STOP_COPY
the buffers preparation and some other related stuff is done
unconditionally with regards to STOP/PRE-COPY.

Note:
In that phase in the series we still didn't activate the chunk mode and
the first buffer will be used in all the places.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230911093856.81910-7-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/mlx5/cmd.c
drivers/vfio/pci/mlx5/cmd.h
drivers/vfio/pci/mlx5/main.c