kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
@ 2023-03-08 15:57 Yishai Hadas
  2023-03-08 20:56 ` Alex Williamson
  0 siblings, 1 reply; 5+ messages in thread
From: Yishai Hadas @ 2023-03-08 15:57 UTC (permalink / raw)
  To: alex.williamson, jgg
  Cc: kvm, kevin.tian, joao.m.martins, leonro, yishaih, maorg, avihaih

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.

Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
---
 drivers/vfio/pci/mlx5/main.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index e897537a9e8a..d95fd382814c 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -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) {
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
  2023-03-08 15:57 [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy Yishai Hadas
@ 2023-03-08 20:56 ` Alex Williamson
  2023-03-09  8:08   ` Yishai Hadas
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2023-03-08 20:56 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: jgg, kvm, kevin.tian, joao.m.martins, leonro, maorg, avihaih

On Wed, 8 Mar 2023 17:57:23 +0200
Yishai Hadas <yishaih@nvidia.com> wrote:

> 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.
> 
> Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
>  drivers/vfio/pci/mlx5/main.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
> index e897537a9e8a..d95fd382814c 100644
> --- a/drivers/vfio/pci/mlx5/main.c
> +++ b/drivers/vfio/pci/mlx5/main.c
> @@ -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) {

This is intended for v6.3, correct?  Thanks,

Alex


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
  2023-03-08 20:56 ` Alex Williamson
@ 2023-03-09  8:08   ` Yishai Hadas
  2023-03-19 11:59     ` Yishai Hadas
  0 siblings, 1 reply; 5+ messages in thread
From: Yishai Hadas @ 2023-03-09  8:08 UTC (permalink / raw)
  To: Alex Williamson
  Cc: jgg, kvm, kevin.tian, joao.m.martins, leonro, maorg, avihaih

On 08/03/2023 22:56, Alex Williamson wrote:
> On Wed, 8 Mar 2023 17:57:23 +0200
> Yishai Hadas <yishaih@nvidia.com> wrote:
>
>> 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.
>>
>> Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")
>> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
>> ---
>>   drivers/vfio/pci/mlx5/main.c | 14 ++++----------
>>   1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
>> index e897537a9e8a..d95fd382814c 100644
>> --- a/drivers/vfio/pci/mlx5/main.c
>> +++ b/drivers/vfio/pci/mlx5/main.c
>> @@ -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) {
> This is intended for v6.3, correct?  Thanks,

Yes, thanks.

Yishai



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
  2023-03-09  8:08   ` Yishai Hadas
@ 2023-03-19 11:59     ` Yishai Hadas
  2023-03-19 14:18       ` Alex Williamson
  0 siblings, 1 reply; 5+ messages in thread
From: Yishai Hadas @ 2023-03-19 11:59 UTC (permalink / raw)
  To: Alex Williamson
  Cc: jgg, kvm, kevin.tian, joao.m.martins, leonro, maorg, avihaih

On 09/03/2023 10:08, Yishai Hadas wrote:
> On 08/03/2023 22:56, Alex Williamson wrote:
>> On Wed, 8 Mar 2023 17:57:23 +0200
>> Yishai Hadas <yishaih@nvidia.com> wrote:
>>
>>> 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.
>>>
>>> Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl 
>>> implementation")
>>> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
>>> ---
>>>   drivers/vfio/pci/mlx5/main.c | 14 ++++----------
>>>   1 file changed, 4 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/vfio/pci/mlx5/main.c 
>>> b/drivers/vfio/pci/mlx5/main.c
>>> index e897537a9e8a..d95fd382814c 100644
>>> --- a/drivers/vfio/pci/mlx5/main.c
>>> +++ b/drivers/vfio/pci/mlx5/main.c
>>> @@ -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) {
>> This is intended for v6.3, correct?  Thanks,
>
> Yes, thanks.
>
> Yishai
>
Alex,

Are we fine to proceed here ?

Thanks,
Yishai


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy
  2023-03-19 11:59     ` Yishai Hadas
@ 2023-03-19 14:18       ` Alex Williamson
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2023-03-19 14:18 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: jgg, kvm, kevin.tian, joao.m.martins, leonro, maorg, avihaih

On Sun, 19 Mar 2023 13:59:31 +0200
Yishai Hadas <yishaih@nvidia.com> wrote:

> On 09/03/2023 10:08, Yishai Hadas wrote:
> > On 08/03/2023 22:56, Alex Williamson wrote:  
> >> On Wed, 8 Mar 2023 17:57:23 +0200
> >> Yishai Hadas <yishaih@nvidia.com> wrote:
> >>  
> >>> 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.
> >>>
> >>> Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl 
> >>> implementation")
> >>> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> >>> ---
> >>>   drivers/vfio/pci/mlx5/main.c | 14 ++++----------
> >>>   1 file changed, 4 insertions(+), 10 deletions(-)
> >>>
> >>> diff --git a/drivers/vfio/pci/mlx5/main.c 
> >>> b/drivers/vfio/pci/mlx5/main.c
> >>> index e897537a9e8a..d95fd382814c 100644
> >>> --- a/drivers/vfio/pci/mlx5/main.c
> >>> +++ b/drivers/vfio/pci/mlx5/main.c
> >>> @@ -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) {  
> >> This is intended for v6.3, correct?  Thanks,  
> >
> > 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-19 14:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 15:57 [PATCH vfio] vfio/mlx5: Fix the report of dirty_bytes upon pre-copy Yishai Hadas
2023-03-08 20:56 ` Alex Williamson
2023-03-09  8:08   ` Yishai Hadas
2023-03-19 11:59     ` Yishai Hadas
2023-03-19 14:18       ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).