Patchwork stream: fix ratelimit_set_speed

login
register
mail settings
Submitter Dietmar Maurer
Date Oct. 24, 2012, 10:10 a.m.
Message ID <1351073447-643298-1-git-send-email-dietmar@proxmox.com>
Download mbox | patch
Permalink /patch/194010/
State New
Headers show

Comments

Dietmar Maurer - Oct. 24, 2012, 10:10 a.m.
The formula to compute slice_quota was wrong.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
---
 include/qemu/ratelimit.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Eric Blake - Oct. 24, 2012, 11:29 p.m.
On 10/24/2012 04:10 AM, Dietmar Maurer wrote:
> The formula to compute slice_quota was wrong.
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
>  include/qemu/ratelimit.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

However, it might also be nice to point to the commit introducing the
bug in the commit message (6ef228fc0de)

> 
> diff --git a/include/qemu/ratelimit.h b/include/qemu/ratelimit.h
> index c6ac281..d1610f1 100644
> --- a/include/qemu/ratelimit.h
> +++ b/include/qemu/ratelimit.h
> @@ -42,7 +42,7 @@ static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
>                                         uint64_t slice_ns)
>  {
>      limit->slice_ns = slice_ns;
> -    limit->slice_quota = ((double)speed * 1000000000ULL) / slice_ns;
> +    limit->slice_quota = ((double)speed * slice_ns)/1000000000ULL;
>  }
>  
>  #endif
>
Paolo Bonzini - Nov. 21, 2012, 1:24 p.m.
Il 24/10/2012 12:10, Dietmar Maurer ha scritto:
> The formula to compute slice_quota was wrong.
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
>  include/qemu/ratelimit.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/include/qemu/ratelimit.h b/include/qemu/ratelimit.h
> index c6ac281..d1610f1 100644
> --- a/include/qemu/ratelimit.h
> +++ b/include/qemu/ratelimit.h
> @@ -42,7 +42,7 @@ static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
>                                         uint64_t slice_ns)
>  {
>      limit->slice_ns = slice_ns;
> -    limit->slice_quota = ((double)speed * 1000000000ULL) / slice_ns;
> +    limit->slice_quota = ((double)speed * slice_ns)/1000000000ULL;
>  }
>  
>  #endif
> 

Ping... Stefan, can you commit this fix to block branch too?

Paolo
Kevin Wolf - Nov. 26, 2012, 4:23 p.m.
Am 21.11.2012 14:24, schrieb Paolo Bonzini:
> Il 24/10/2012 12:10, Dietmar Maurer ha scritto:
>> The formula to compute slice_quota was wrong.
>>
>> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
>> ---
>>  include/qemu/ratelimit.h |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/include/qemu/ratelimit.h b/include/qemu/ratelimit.h
>> index c6ac281..d1610f1 100644
>> --- a/include/qemu/ratelimit.h
>> +++ b/include/qemu/ratelimit.h
>> @@ -42,7 +42,7 @@ static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
>>                                         uint64_t slice_ns)
>>  {
>>      limit->slice_ns = slice_ns;
>> -    limit->slice_quota = ((double)speed * 1000000000ULL) / slice_ns;
>> +    limit->slice_quota = ((double)speed * slice_ns)/1000000000ULL;
>>  }
>>  
>>  #endif
>>
> 
> Ping... Stefan, can you commit this fix to block branch too?

Thanks, applied to the block branch for 1.3.

Kevin

Patch

diff --git a/include/qemu/ratelimit.h b/include/qemu/ratelimit.h
index c6ac281..d1610f1 100644
--- a/include/qemu/ratelimit.h
+++ b/include/qemu/ratelimit.h
@@ -42,7 +42,7 @@  static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
                                        uint64_t slice_ns)
 {
     limit->slice_ns = slice_ns;
-    limit->slice_quota = ((double)speed * 1000000000ULL) / slice_ns;
+    limit->slice_quota = ((double)speed * slice_ns)/1000000000ULL;
 }
 
 #endif