vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
Subsystems (4)
Yishai Hadas
maintainerPATCH 1/1 vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
Fix the report of dirty_bytes upon pre-copy to include both the existing data on the migration file and the device extra bytes.
This gives a better close estimation to what can be passed any more as part of pre-copy.
--- drivers/vfio/pci/mlx5/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/vfio/pci/mlx5/main.c +4 -10
@@ -442,16 +442,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,if (migf->pre_copy_initial_bytes > *pos) { info.initial_bytes = migf->pre_copy_initial_bytes - *pos; }else { - buf =mlx5vf_get_data_buff_from_pos (migf, *pos, &end_of_data); -if (buf) { - info.dirty_bytes = buf->start_pos + buf->length - *pos; - }else { -if (!end_of_data) { - ret = -EINVAL ; - goto err_migf_unlock; - } - info.dirty_bytes = inc_length; - } + info.dirty_bytes = migf->max_pos - *pos; +if (!info.dirty_bytes) + end_of_data = true; + info.dirty_bytes += inc_length; }if (!end_of_data || !inc_length) {
Signature · 1 line
2.18.1
Quoted 27 lines · On Wed, 8 Mar 2023 17:57:23 +0200 Yishai Hadas <[email protected]> wrote:
Fix the report of
dirty_bytesupon pre-copy to include both the existing data on the migration file and the device extra bytes.This gives a better close estimation to what can be passed any more as part of pre-copy.
Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")Signed-off-by Yishai Hadas <[email protected]>--- drivers/vfio/pci/mlx5/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)drivers/vfio/pci/mlx5/main.c +0
-7@@ -442,16 +442,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,if (migf->pre_copy_initial_bytes > *pos) { info.initial_bytes = migf->pre_copy_initial_bytes - *pos; }else { - buf =mlx5vf_get_data_buff_from_pos (migf, *pos, &end_of_data); -if (buf) { - info.dirty_bytes = buf->start_pos + buf->length - *pos; - }else { -if (!end_of_data) { - ret = -EINVAL ; - goto err_migf_unlock;
drivers/vfio/pci/mlx5/main.c static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, · line 451
Quoted 10 lines
drivers/vfio/pci/mlx5/main.c +4
-3- } - info.dirty_bytes = inc_length; - } + info.dirty_bytes = migf->max_pos - *pos; +if (!info.dirty_bytes) + end_of_data = true; + info.dirty_bytes += inc_length; }if (!end_of_data || !inc_length) {
This is intended for v6.3, correct? Thanks,
Alex
Yishai Hadas
maintainerQuoted 39 lines · Alex Williamson
Quoted 36 lines · On Wed, 8 Mar 2023 17:57:23 +0200 Yishai Hadas <[email protected]> wrote:
Fix the report of
dirty_bytesupon pre-copy to include both the existing data on the migration file and the device extra bytes.This gives a better close estimation to what can be passed any more as part of pre-copy.
Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")Signed-off-by Yishai Hadas <[email protected]>--- drivers/vfio/pci/mlx5/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)drivers/vfio/pci/mlx5/main.c +4
-10@@ -442,16 +442,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,if (migf->pre_copy_initial_bytes > *pos) { info.initial_bytes = migf->pre_copy_initial_bytes - *pos; }else { - buf =mlx5vf_get_data_buff_from_pos (migf, *pos, &end_of_data); -if (buf) { - info.dirty_bytes = buf->start_pos + buf->length - *pos; - }else { -if (!end_of_data) { - ret = -EINVAL ; - goto err_migf_unlock; - } - info.dirty_bytes = inc_length; - } + info.dirty_bytes = migf->max_pos - *pos; +if (!info.dirty_bytes) + end_of_data = true; + info.dirty_bytes += inc_length; }
Quoted 2 lines
drivers/vfio/pci/mlx5/main.c static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, · line 451
Quoted 1 line
drivers/vfio/pci/mlx5/main.c +0
-0if (!end_of_data || !inc_length) {This is intended for v6.3, correct? Thanks,
Yes, thanks.
Yishai
Yishai Hadas
maintainerQuoted 43 lines · Yishai Hadas
Quoted 33 lines · Alex Williamson
Quoted 30 lines · On Wed, 8 Mar 2023 17:57:23 +0200 Yishai Hadas <[email protected]> wrote:
Fix the report of
dirty_bytesupon pre-copy to include both the existing data on the migration file and the device extra bytes.This gives a better close estimation to what can be passed any more as part of pre-copy.
Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")Signed-off-by Yishai Hadas <[email protected]>---
drivers/vfio/pci/mlx5/main.c| 14 ++++----------1 file changed, 4 insertions(+), 10 deletions(-)drivers/vfio/pci/mlx5/main.c +0
-9@@ -442,16 +442,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, if (migf->pre_copy_initial_bytes > *pos) { info.initial_bytes = migf->pre_copy_initial_bytes - *pos; } else { - buf = mlx5vf_get_data_buff_from_pos(migf, *pos, &end_of_data); - if (buf) { - info.dirty_bytes = buf->start_pos + buf->length - *pos; - } else { - if (!end_of_data) { - ret = -EINVAL; - goto err_migf_unlock; - } - info.dirty_bytes = inc_length;Quoted 8 lines
drivers/vfio/pci/mlx5/main.c static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, · line 451
Quoted 7 lines
drivers/vfio/pci/mlx5/main.c +4
-1- } + info.dirty_bytes = migf->max_pos - *pos; + if (!info.dirty_bytes) + end_of_data = true; + info.dirty_bytes += inc_length; } if (!end_of_data || !inc_length) {This is intended for v6.3, correct? Thanks,
Quoted 4 lines
Yes, thanks.
Yishai
Alex,
Are we fine to proceed here ?
Thanks,
Yishai
Quoted 47 lines · On Sun, 19 Mar 2023 13:59:31 +0200 Yishai Hadas <[email protected]> wrote:
Quoted 46 lines · Yishai Hadas
Quoted 44 lines · Alex Williamson
Quoted 30 lines · On Wed, 8 Mar 2023 17:57:23 +0200 Yishai Hadas <[email protected]> wrote:
Fix the report of
dirty_bytesupon pre-copy to include both the existing
data on the migration file and the device extra bytes.This gives a better close estimation to what can be passed any more as part of pre-copy.
Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctlimplementation")
Signed-off-by Yishai Hadas <[email protected]>---
drivers/vfio/pci/mlx5/main.c| 14 ++++----------1 file changed, 4 insertions(+), 10 deletions(-)drivers/vfio/pci/mlx5/main.c +0
-6@@ -442,16 +442,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, if (migf->pre_copy_initial_bytes > *pos) { info.initial_bytes = migf->pre_copy_initial_bytes - *pos; } else { - buf = mlx5vf_get_data_buff_from_pos(migf, *pos, &end_of_data); - if (buf) { - info.dirty_bytes = buf->start_pos + buf->length - *pos; - } else { - if (!end_of_data) { - ret = -EINVAL;drivers/vfio/pci/mlx5/main.c static long mlx5vf_precopy_ioctl(struct file · line 451
Quoted 10 lines
drivers/vfio/pci/mlx5/main.c +4
-4- goto err_migf_unlock; - } - info.dirty_bytes = inc_length; - } + info.dirty_bytes = migf->max_pos - *pos; + if (!info.dirty_bytes) + end_of_data = true; + info.dirty_bytes += inc_length; } if (!end_of_data || !inc_length) {This is intended for v6.3, correct? Thanks,
Quoted 7 lines
Quoted 4 lines
Yes, thanks.
Yishai
Alex,
Are we fine to proceed here ?
Yes, I have this in the vfio for-linus branch, so it should already be in linux-next. I'll send a pull request for it this week. Thanks,
Alex