From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: Ping Fan Liu <pingfank@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe
Date: Wed, 28 Aug 2013 16:39:03 +0200 [thread overview]
Message-ID: <521E0B87.7020703@redhat.com> (raw)
In-Reply-To: <57013E01-633A-4F71-9AC9-921D0917832B@alex.org.uk>
Il 27/08/2013 10:55, Alex Bligh ha scritto:
>> + * Note that this function should not be used when other threads also access
>> + * the timer list. The return value may be outdated by the time it is acted
>> + * upon.
>> + *
>
> I'm in two minds as to whether there is a problem with the comment or the
> code here. Despite git's best endeavours, this is a comment on qemu_clock_has_timers,
> which is called in qemu_clock_warp in cpus.c. I'm still a little confused as
> to what thread(s) that can be called from.
This really means that calling this function must be done with care
because there is potential of races. As long as you use aio_notify
properly so that qemu_clock_warp is called after every timer_mod, it
should be fine.
>> > @@ -531,6 +545,9 @@ void timer_mod_ns(QEMUTimer *ts, int64_t expire_time);
>> > *
>> > * Modify a timer to expiry at @expire_time, taking into
>> > * account the scale associated with the timer.
>> > + *
>> > + * This function is thread-safe but the timer and its timer list must not be
>> > + * freed while this function is running.
>> > */
>> > void timer_mod(QEMUTimer *ts, int64_t expire_timer);
> timer_mod and timer_mod_ns are inevitably called having just read the
> clock with qemu_clock_get. I am presuming these are thread safe (I haven't
> checked) and if so the documentation for them should be similar adjusted.
> Otherwise making these thread safe is all but useless.
rt_clock is thread safe. host_clock is thread safe but there's the
question of where to run the notifiers. Ping Fan has made vm_clock
thread safe for the non-icount case, probably I'll look at icount sometime.
Paolo
next prev parent reply other threads:[~2013-08-28 14:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-27 8:23 [Qemu-devel] [PATCH v2 0/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe Stefan Hajnoczi
2013-08-27 8:23 ` [Qemu-devel] [PATCH v2 1/2] qemu-timer: drop outdated signal safety comments Stefan Hajnoczi
2013-08-27 8:43 ` Alex Bligh
2013-08-27 8:23 ` [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe Stefan Hajnoczi
2013-08-27 8:55 ` Alex Bligh
2013-08-28 8:03 ` Stefan Hajnoczi
2013-08-28 14:39 ` Paolo Bonzini [this message]
2013-08-29 10:00 ` Paolo Bonzini
2013-08-29 15:37 ` Stefan Hajnoczi
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=521E0B87.7020703@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex@alex.org.uk \
--cc=pingfank@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--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).