* [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code
@ 2016-07-13 9:06 Cao jin
2016-07-13 10:21 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2016-07-13 9:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini
When passed argument 'ns' is 0, macro DIV_ROUND_UP will return 0 also.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
qemu-timer.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/qemu-timer.c b/qemu-timer.c
index eb22e92..cfe0893 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -285,12 +285,8 @@ int qemu_timeout_ns_to_ms(int64_t ns)
return -1;
}
- if (!ns) {
- return 0;
- }
-
/* Always round up, because it's better to wait too long than to wait too
- * little and effectively busy-wait
+ * short and effectively busy-wait
*/
ms = DIV_ROUND_UP(ns, SCALE_MS);
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code
2016-07-13 9:06 [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code Cao jin
@ 2016-07-13 10:21 ` Paolo Bonzini
2016-07-13 11:40 ` Cao jin
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2016-07-13 10:21 UTC (permalink / raw)
To: Cao jin, qemu-devel; +Cc: qemu-trivial
On 13/07/2016 11:06, Cao jin wrote:
> When passed argument 'ns' is 0, macro DIV_ROUND_UP will return 0 also.
It's potentially slower though.
Paolo
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> qemu-timer.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/qemu-timer.c b/qemu-timer.c
> index eb22e92..cfe0893 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -285,12 +285,8 @@ int qemu_timeout_ns_to_ms(int64_t ns)
> return -1;
> }
>
> - if (!ns) {
> - return 0;
> - }
> -
> /* Always round up, because it's better to wait too long than to wait too
> - * little and effectively busy-wait
> + * short and effectively busy-wait
> */
> ms = DIV_ROUND_UP(ns, SCALE_MS);
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code
2016-07-13 10:21 ` Paolo Bonzini
@ 2016-07-13 11:40 ` Cao jin
2016-07-13 11:40 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2016-07-13 11:40 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial
On 07/13/2016 06:21 PM, Paolo Bonzini wrote:
>
>
> On 13/07/2016 11:06, Cao jin wrote:
>> When passed argument 'ns' is 0, macro DIV_ROUND_UP will return 0 also.
>
> It's potentially slower though.
>
Is it because the function in the i/o loop path, so the potentially
extra arithmetical instructions matters?
> Paolo
>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
>> ---
>> qemu-timer.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/qemu-timer.c b/qemu-timer.c
>> index eb22e92..cfe0893 100644
>> --- a/qemu-timer.c
>> +++ b/qemu-timer.c
>> @@ -285,12 +285,8 @@ int qemu_timeout_ns_to_ms(int64_t ns)
>> return -1;
>> }
>>
>> - if (!ns) {
>> - return 0;
>> - }
>> -
>> /* Always round up, because it's better to wait too long than to wait too
>> - * little and effectively busy-wait
>> + * short and effectively busy-wait
>> */
>> ms = DIV_ROUND_UP(ns, SCALE_MS);
>>
>>
>
>
>
--
Yours Sincerely,
Cao jin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code
2016-07-13 11:40 ` Cao jin
@ 2016-07-13 11:40 ` Paolo Bonzini
2016-07-13 12:13 ` Cao jin
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2016-07-13 11:40 UTC (permalink / raw)
To: Cao jin, qemu-devel; +Cc: qemu-trivial
On 13/07/2016 13:40, Cao jin wrote:
>
>
> On 07/13/2016 06:21 PM, Paolo Bonzini wrote:
>>
>>
>> On 13/07/2016 11:06, Cao jin wrote:
>>> When passed argument 'ns' is 0, macro DIV_ROUND_UP will return 0 also.
>>
>> It's potentially slower though.
>>
>
> Is it because the function in the i/o loop path, so the potentially
> extra arithmetical instructions matters?
It is quite common for ns to be zero, for example if a bottom half has
to be invoked.
However, qemu_timeout_ns_to_ms is not used in the really important path
(which is aio_poll in aio-posix.c) so I guess your patch is okay.
Thanks,
Paolo
>> Paolo
>>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
>>> ---
>>> qemu-timer.c | 6 +-----
>>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>>
>>> diff --git a/qemu-timer.c b/qemu-timer.c
>>> index eb22e92..cfe0893 100644
>>> --- a/qemu-timer.c
>>> +++ b/qemu-timer.c
>>> @@ -285,12 +285,8 @@ int qemu_timeout_ns_to_ms(int64_t ns)
>>> return -1;
>>> }
>>>
>>> - if (!ns) {
>>> - return 0;
>>> - }
>>> -
>>> /* Always round up, because it's better to wait too long than
>>> to wait too
>>> - * little and effectively busy-wait
>>> + * short and effectively busy-wait
>>> */
>>> ms = DIV_ROUND_UP(ns, SCALE_MS);
>>>
>>>
>>
>>
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code
2016-07-13 11:40 ` Paolo Bonzini
@ 2016-07-13 12:13 ` Cao jin
0 siblings, 0 replies; 5+ messages in thread
From: Cao jin @ 2016-07-13 12:13 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial
On 07/13/2016 07:40 PM, Paolo Bonzini wrote:
>
>
> On 13/07/2016 13:40, Cao jin wrote:
>>
>>
>> On 07/13/2016 06:21 PM, Paolo Bonzini wrote:
>>>
>>>
>>> On 13/07/2016 11:06, Cao jin wrote:
>>>> When passed argument 'ns' is 0, macro DIV_ROUND_UP will return 0 also.
>>>
>>> It's potentially slower though.
>>>
>>
>> Is it because the function in the i/o loop path, so the potentially
>> extra arithmetical instructions matters?
>
> It is quite common for ns to be zero, for example if a bottom half has
> to be invoked.
>
I see. I need dig deeper to understand the wholely I/O mechanism. Thanks
Paolo!
> However, qemu_timeout_ns_to_ms is not used in the really important path
> (which is aio_poll in aio-posix.c) so I guess your patch is okay.
>
> Thanks,
>
> Paolo
>
--
Yours Sincerely,
Cao jin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-07-13 12:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 9:06 [Qemu-devel] [PATCH] qemu-timer: remove unnecessary code Cao jin
2016-07-13 10:21 ` Paolo Bonzini
2016-07-13 11:40 ` Cao jin
2016-07-13 11:40 ` Paolo Bonzini
2016-07-13 12:13 ` Cao jin
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).