Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-19 Thread Paolo Bonzini
Il 12/08/2013 14:49, Stefan Hajnoczi ha scritto: Introduce QEMUTimerList-active_timers_lock to protect the linked list of active timers. This allows qemu_timer_mod_ns() to be called from any thread. Note that vm_clock is not thread-safe and its use of qemu_clock_has_timers() works fine

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-19 Thread Paolo Bonzini
Il 15/08/2013 14:00, Stefan Hajnoczi ha scritto: The common case is that we only check the first timer in -active_timers. Usually the first timer has not expired yet and we return; the lock was taken once only. I'm not sure it's worth complicating the case where we iterate multiple times.

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-15 Thread Stefan Hajnoczi
On Thu, Aug 15, 2013 at 08:05:11AM +0800, liu ping fan wrote: On Mon, Aug 12, 2013 at 8:49 PM, Stefan Hajnoczi stefa...@redhat.com wrote: @@ -376,13 +411,16 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) current_time = qemu_clock_get_ns(timer_list-clock-type); for(;;) {

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-15 Thread liu ping fan
On Thu, Aug 15, 2013 at 4:01 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Thu, Aug 15, 2013 at 08:05:11AM +0800, liu ping fan wrote: On Mon, Aug 12, 2013 at 8:49 PM, Stefan Hajnoczi stefa...@redhat.com wrote: @@ -376,13 +411,16 @@ bool timerlist_run_timers(QEMUTimerList *timer_list)

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-15 Thread liu ping fan
On Thu, Aug 15, 2013 at 4:22 PM, liu ping fan qemul...@gmail.com wrote: On Thu, Aug 15, 2013 at 4:01 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Thu, Aug 15, 2013 at 08:05:11AM +0800, liu ping fan wrote: On Mon, Aug 12, 2013 at 8:49 PM, Stefan Hajnoczi stefa...@redhat.com wrote: @@

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-15 Thread Alex Bligh
On 15 Aug 2013, at 09:22, liu ping fan wrote: How about new_list for vcpu to add timer, an before walking, splice the new_list to timer_list? If I understand you right, you would have to be careful any timer routine modified itself or (less likely) any other timer, as that timer would no

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-15 Thread Stefan Hajnoczi
On Thu, Aug 15, 2013 at 04:24:57PM +0800, liu ping fan wrote: On Thu, Aug 15, 2013 at 4:22 PM, liu ping fan qemul...@gmail.com wrote: On Thu, Aug 15, 2013 at 4:01 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Thu, Aug 15, 2013 at 08:05:11AM +0800, liu ping fan wrote: On Mon, Aug 12, 2013

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-14 Thread liu ping fan
On Mon, Aug 12, 2013 at 8:49 PM, Stefan Hajnoczi stefa...@redhat.com wrote: Introduce QEMUTimerList-active_timers_lock to protect the linked list of active timers. This allows qemu_timer_mod_ns() to be called from any thread. Note that vm_clock is not thread-safe and its use of

[Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-12 Thread Stefan Hajnoczi
Introduce QEMUTimerList-active_timers_lock to protect the linked list of active timers. This allows qemu_timer_mod_ns() to be called from any thread. Note that vm_clock is not thread-safe and its use of qemu_clock_has_timers() works fine today but is also not thread-safe. The purpose of this

Re: [Qemu-devel] [PATCH 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe

2013-08-12 Thread Alex Bligh
--On 12 August 2013 14:49:29 +0200 Stefan Hajnoczi stefa...@redhat.com wrote: Introduce QEMUTimerList-active_timers_lock to protect the linked list of active timers. This allows qemu_timer_mod_ns() to be called from any thread. Note that vm_clock is not thread-safe and its use of