From: Stefan Hajnoczi <stefanha@gmail.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
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 10:03:37 +0200 [thread overview]
Message-ID: <20130828080337.GC4696@stefanha-thinkpad.muc.redhat.com> (raw)
In-Reply-To: <57013E01-633A-4F71-9AC9-921D0917832B@alex.org.uk>
On Tue, Aug 27, 2013 at 09:55:22AM +0100, Alex Bligh wrote:
> On 27 Aug 2013, at 09:23, Stefan Hajnoczi wrote:
> > diff --git a/include/qemu/timer.h b/include/qemu/timer.h
> > index e4934dd..b58903b 100644
> > --- a/include/qemu/timer.h
> > +++ b/include/qemu/timer.h
> > @@ -115,6 +115,10 @@ static inline int64_t qemu_clock_get_us(QEMUClockType type)
> > * Determines whether a clock's default timer list
> > * has timers attached
> > *
> > + * 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.
Remember icount is a TCG feature and will only be accessed from a single
thread.
> > @@ -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.
Ping Fan's series deals with thread-safe clock sources, this series only
tackles the timer_list.
We need to apply both series to be able to use timers from threads.
Stefan
next prev parent reply other threads:[~2013-08-28 8:04 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 [this message]
2013-08-28 14:39 ` Paolo Bonzini
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=20130828080337.GC4696@stefanha-thinkpad.muc.redhat.com \
--to=stefanha@gmail.com \
--cc=alex@alex.org.uk \
--cc=pbonzini@redhat.com \
--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).