From: Sergey Fedorov <serge.fdrv@gmail.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
qemu-devel@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline case
Date: Tue, 10 Jun 2014 13:08:01 +0400 [thread overview]
Message-ID: <5396CAF1.6070200@gmail.com> (raw)
In-Reply-To: <92F4C938-662F-4458-BF51-1BEC1C9869E7@alex.org.uk>
On 09.06.2014 21:36, Alex Bligh wrote:
> On 9 Jun 2014, at 17:42, Sergey Fedorov wrote:
>
>> If there is no deadline across all timerlists attached to the clock
>> then qemu_clock_deadline_ns_all() returns -1. Cast it to unsinged so
>> MIN() do not treat it as minimum.
>>
>> Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
>> ---
>> cpus.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpus.c b/cpus.c
>> index dd7ac13..3ec15cb 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -346,8 +346,8 @@ void qtest_clock_warp(int64_t dest)
>> int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>> assert(qtest_enabled());
>> while (clock < dest) {
>> - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
>> - int64_t warp = MIN(dest - clock, deadline);
>> + uint64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
>> + uint64_t warp = MIN(dest - clock, deadline);
> Please don't do that. It looks like a bug where you've not read the return
> type.
>
> Instead, just do
>
> int64_t warp = qemu_soonest_timeout(dest - clock, deadline);
>
> which puts all the ugly casting stuff in one nicely documented inline function
> and will generate the same code.
Thank you! I'm resubmitting the patch.
>
>> seqlock_write_lock(&timers_state.vm_clock_seqlock);
>> qemu_icount_bias += warp;
>> seqlock_write_unlock(&timers_state.vm_clock_seqlock);
>> --
>> 1.9.1
>>
>>
>>
next prev parent reply other threads:[~2014-06-10 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-09 16:42 [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline case Sergey Fedorov
2014-06-09 17:36 ` Alex Bligh
2014-06-10 9:08 ` Sergey Fedorov [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-06-10 9:10 Sergey Fedorov
2014-06-10 11:03 ` Paolo Bonzini
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=5396CAF1.6070200@gmail.com \
--to=serge.fdrv@gmail.com \
--cc=afaerber@suse.de \
--cc=alex@alex.org.uk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.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 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).