qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ping Fan Liu <pingfank@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, Alex Bligh <alex@alex.org.uk>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe
Date: Thu, 29 Aug 2013 17:37:29 +0200	[thread overview]
Message-ID: <20130829153729.GA27529@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <521F1BAC.902@redhat.com>

On Thu, Aug 29, 2013 at 12:00:12PM +0200, Paolo Bonzini wrote:
> Il 27/08/2013 10:23, Stefan Hajnoczi ha scritto:
> >  /* modify the current timer so that it will be fired when current_time
> >     >= expire_time. The corresponding callback will be called. */
> >  void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)
> >  {
> > +    QEMUTimerList *timer_list = ts->timer_list;
> >      QEMUTimer **pt, *t;
> >  
> >      timer_del(ts);
> >  
> >      /* add the timer in the sorted list */
> > -    pt = &ts->timer_list->active_timers;
> > +    qemu_mutex_lock(&timer_list->active_timers_lock);
> > +    pt = &timer_list->active_timers;
> 
> I think deletion and modification of the list should happen without
> releasing the lock in the middle.

Thanks for explaining the race between two timer_mod_ns() calls to me on
IRC.  I have sent a new revision of this series with your fixes included.

Stefan

      reply	other threads:[~2013-08-29 15:37 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
2013-08-29 10:00   ` Paolo Bonzini
2013-08-29 15:37     ` Stefan Hajnoczi [this message]

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=20130829153729.GA27529@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=alex@alex.org.uk \
    --cc=pbonzini@redhat.com \
    --cc=pingfank@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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).