From: Jason Gunthorpe <jgg@nvidia.com>
To: Yishai Hadas <yishaih@nvidia.com>
Cc: alex.williamson@redhat.com, kvm@vger.kernel.org,
kevin.tian@intel.com, joao.m.martins@oracle.com,
leonro@nvidia.com, shayd@nvidia.com, maorg@nvidia.com,
avihaih@nvidia.com, cohuck@redhat.com
Subject: Re: [PATCH vfio 10/13] vfio/mlx5: Introduce SW headers for migration states
Date: Wed, 9 Nov 2022 14:38:41 -0400 [thread overview]
Message-ID: <Y2vzseOPAX2s4SmN@nvidia.com> (raw)
In-Reply-To: <20221106174630.25909-11-yishaih@nvidia.com>
On Sun, Nov 06, 2022 at 07:46:27PM +0200, Yishai Hadas wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> As mentioned in the previous patches, mlx5 is transferring multiple
> states when the PRE_COPY protocol is used. This states mechanism
> requires the target VM to know the states' size in order to execute
> multiple loads.
> Therefore, add SW header, with the needed information, for each saved
> state the source VM is transferring to the target VM.
>
> This patch implements the source VM handling of the headers, following
> patch will implement the target VM handling of the headers.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/vfio/pci/mlx5/cmd.h | 7 +++++
> drivers/vfio/pci/mlx5/main.c | 50 +++++++++++++++++++++++++++++++++---
> 2 files changed, 54 insertions(+), 3 deletions(-)
This seems very awkwardly done. If you are going to string together
sg_tables, then just do that consistently. Put the header into its own
small sg_table as well and have a simple queue of sg_table/starting
offset/length chunks to let read figure out on its own. When you start
new stuff you stick it to the back of the queue. eg when you get the
incremental stick on two sg_tables to the queue. when you get to the
final stick on the final sg_table to the back of the queue. Whatever
has or hasn't happened just works out naturally.
There are too many special cases trying to figure out which chunk is
the right chunk.
> #define MIGF_TOTAL_DATA(migf) \
> - (migf->table_start_pos + migf->image_length + migf->final_length)
> + (migf->table_start_pos + migf->image_length + migf->final_length + \
> + migf->sw_headers_bytes_sent)
And make all these macros static inline functions in all the patches -
they don't even have proper argument bracketing..
> +static void mlx5vf_send_sw_header(struct mlx5_vf_migration_file *migf,
> + loff_t *pos, char __user **buf, size_t *len,
> + ssize_t *done)
> +{
> + struct mlx5_vf_migration_header header = {};
> + size_t header_size = sizeof(header);
> + void *header_buf = &header;
> + size_t size_to_transfer;
> +
> + if (*pos >= mlx5vf_final_table_start_pos(migf))
> + header.image_size = migf->final_length;
> + else
> + header.image_size = migf->image_length;
> +
> + size_to_transfer = header_size -
> + (migf->sw_headers_bytes_sent % header_size);
> + size_to_transfer = min_t(size_t, size_to_transfer, *len);
> + header_buf += header_size - size_to_transfer;
> + if (copy_to_user(*buf, header_buf, size_to_transfer)) {
> + *done = -EFAULT;
A function that has errors should return a value, not something like
this..
Jason
next prev parent reply other threads:[~2022-11-09 18:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-06 17:46 [PATCH vfio 00/13] Add migration PRE_COPY support for mlx5 driver Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 01/13] vfio: Add an option to get migration data size Yishai Hadas
2022-11-09 7:42 ` liulongfang
2022-11-09 17:06 ` Jason Gunthorpe
2022-11-13 16:58 ` Yishai Hadas
2022-11-14 19:04 ` Alex Williamson
2022-11-06 17:46 ` [PATCH vfio 02/13] vfio/mlx5: Fix a typo in mlx5vf_cmd_load_vhca_state() Yishai Hadas
2022-11-09 17:06 ` Jason Gunthorpe
2022-11-06 17:46 ` [PATCH vfio 03/13] net/mlx5: Introduce ifc bits for pre_copy Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 04/13] vfio: Extend the device migration protocol with PRE_COPY Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 05/13] vfio/mlx5: Enforce a single SAVE command at a time Yishai Hadas
2022-11-09 18:04 ` Jason Gunthorpe
2022-11-10 10:38 ` Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 06/13] vfio/mlx5: Refactor total_length name and usage Yishai Hadas
2022-11-09 18:11 ` Jason Gunthorpe
2022-11-10 11:38 ` Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 07/13] vfio/mlx5: Introduce device transitions of PRE_COPY Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 08/13] vfio/mlx5: Introduce vfio precopy ioctl implementation Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 09/13] vfio/mlx5: Manage read() of multiple state saves Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 10/13] vfio/mlx5: Introduce SW headers for migration states Yishai Hadas
2022-11-09 18:38 ` Jason Gunthorpe [this message]
2022-11-06 17:46 ` [PATCH vfio 11/13] vfio/mlx5: Introduce multiple loads Yishai Hadas
2022-11-09 18:45 ` Jason Gunthorpe
2022-11-06 17:46 ` [PATCH vfio 12/13] vfio/mlx5: Fallback to STOP_COPY upon specific PRE_COPY error Yishai Hadas
2022-11-06 17:46 ` [PATCH vfio 13/13] vfio/mlx5: Enable MIGRATION_PRE_COPY flag Yishai Hadas
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=Y2vzseOPAX2s4SmN@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=avihaih@nvidia.com \
--cc=cohuck@redhat.com \
--cc=joao.m.martins@oracle.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leonro@nvidia.com \
--cc=maorg@nvidia.com \
--cc=shayd@nvidia.com \
--cc=yishaih@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.