[Qemu-devel] [PATCH v4 2/3] slirp: define timeout as macro

2013-08-24 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index b71c617..c47af8f 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -47,6 +47,11 @@ static QTAILQ_HEAD(slirp_instances, Slirp

[Qemu-devel] [PATCH v4 1/3] slirp: make timeout local

2013-08-24 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..b71c617 100644 --- a/slirp/slirp.c

[Qemu-devel] [PATCH v4 0/3] slirp: fill mainloop with more precise timeout value

2013-08-24 Thread Liu Ping Fan
no timeout modifications in slirp_pollfds_fill() v2: fold slirp_update_timeout logic into slirp_pollfds_fill. Liu Ping Fan (3): slirp: make timeout local slirp: define timeout as macro slirp: set mainloop timeout with more precise value main-loop.c | 3 +-- slirp/libslirp.h | 3

Re: [Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-24 Thread liu ping fan
On Sat, Aug 24, 2013 at 12:54 AM, Jan Kiszka wrote: > On 2013-08-21 04:15, Liu Ping Fan wrote: >> If slirp needs to emulate tcp timeout, then the timeout value >> for mainloop should be more precise, which is determined by >> slirp's fasttimo or slowtimo. Achi

Re: [Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-24 Thread liu ping fan
On Sat, Aug 24, 2013 at 12:49 AM, Jan Kiszka wrote: > On 2013-08-21 10:07, liu ping fan wrote: >> On Wed, Aug 21, 2013 at 3:36 PM, Alex Bligh wrote: >>> >>> >>> --On 21 August 2013 10:15:52 +0800 Liu Ping Fan wrote: >>> >>>> -void

Re: [Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-21 Thread liu ping fan
On Wed, Aug 21, 2013 at 3:36 PM, Alex Bligh wrote: > > > --On 21 August 2013 10:15:52 +0800 Liu Ping Fan wrote: > >> -void slirp_update_timeout(uint32_t *timeout) >> +static void slirp_update_timeout(uint32_t *timeout) >> { >> -if (!QTAILQ_EMPTY(&

[Qemu-devel] Emulation of ICH PIRQ#16~23

2013-08-20 Thread liu ping fan
When I debug the hpet with linux v3.10. I found it can not work with linux-2.6/Documentation/timers/hpet_example.c. But on bare metal, hpet_example can work! After tracing, I found the trouble is caused by drivers/char/hpet.c hpet_timer_set_irq() gsi = acpi_register_gsi(NULL, irq,

[Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-20 Thread Liu Ping Fan
If slirp needs to emulate tcp timeout, then the timeout value for mainloop should be more precise, which is determined by slirp's fasttimo or slowtimo. Achieve this by swap the logic sequence of slirp_pollfds_fill and slirp_update_timeout. Signed-off-by: Liu Ping Fan --- main-loop.c

[Qemu-devel] [PATCH v3 2/3] slirp: define timeout as macro

2013-08-20 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index b71c617..1e8983e 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -47,6 +47,9 @@ static QTAILQ_HEAD(slirp_instances, Slirp

[Qemu-devel] [PATCH v3 1/3] slirp: make timeout local

2013-08-20 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..b71c617 100644 --- a/slirp/slirp.c

[Qemu-devel] [PATCH v3 0/3] slirp: fill mainloop with more precise timeout value

2013-08-20 Thread Liu Ping Fan
logic into slirp_pollfds_fill. Liu Ping Fan (3): slirp: make timeout local slirp: define timeout as macro slirp: set mainloop timeout with more precise value main-loop.c | 3 +-- slirp/libslirp.h | 3 +-- slirp/slirp.c| 55 +++ slirp/slirp

Re: [Qemu-devel] [PATCH v2 4/4] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-19 Thread liu ping fan
On Sun, Aug 18, 2013 at 10:54 PM, Paolo Bonzini wrote: > Il 14/08/2013 02:34, liu ping fan ha scritto: >> On Tue, Aug 13, 2013 at 10:53 PM, Paolo Bonzini wrote: >>> >>> Il 13/08/2013 07:43, Liu Ping Fan ha scritto: >>>> After disabling the QemuClock,

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 wrote: > On Thu, Aug 15, 2013 at 4:01 PM, Stefan Hajnoczi 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 >>> wrote: >>> > @@ -376,

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 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 wrote: >> > @@ -376,13 +411,16 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) >>

Re: [Qemu-devel] [PATCH v2 2/3] slirp: define timeout as macro

2013-08-14 Thread liu ping fan
On Wed, Aug 14, 2013 at 7:48 PM, Stefan Hajnoczi wrote: > On Wed, Aug 14, 2013 at 11:02:51AM +0800, Liu Ping Fan wrote: >> @@ -47,6 +47,9 @@ static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances >> = >> static struct in_addr dns_addr; >> static u_int dn

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 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_clock_has_timers() w

Re: [Qemu-devel] [PATCH v2 3/3] slirp: set mainloop timeout with more precise value

2013-08-14 Thread liu ping fan
On Wed, Aug 14, 2013 at 4:35 PM, Jan Kiszka wrote: > On 2013-08-14 05:02, Liu Ping Fan wrote: >> If slirp needs to emulate tcp timeout, then the timeout value >> for mainloop should be more precise, which is determined by >> slirp's fasttimo or slowtimo. Achieve this by

[Qemu-devel] [PATCH v2 3/3] slirp: set mainloop timeout with more precise value

2013-08-13 Thread Liu Ping Fan
If slirp needs to emulate tcp timeout, then the timeout value for mainloop should be more precise, which is determined by slirp's fasttimo or slowtimo. Achieve this by swap the logic sequence of slirp_pollfds_fill and slirp_update_timeout. Signed-off-by: Liu Ping Fan --- main-loop.c

[Qemu-devel] [PATCH v2 1/3] slirp: make timeout local

2013-08-13 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..b71c617 100644 --- a/slirp/slirp.c

[Qemu-devel] [PATCH v2 0/3]

2013-08-13 Thread Liu Ping Fan
These patches are separated from "[PATCH v1 0/5] make slirp subsystem self-contained", as Paolo suggested. With them, we can set the mainloop timeout more precisely when slirp has to emulate tcp timeout problem. v2: fold slirp_update_timeout logic into slirp_pollfds_fill. Liu P

[Qemu-devel] [PATCH v2 2/3] slirp: define timeout as macro

2013-08-13 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index b71c617..c224523 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -47,6 +47,9 @@ static QTAILQ_HEAD(slirp_instances, Slirp

Re: [Qemu-devel] Using aio_poll for timer carrier threads

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 10:13 PM, Jan Kiszka wrote: > On 2013-08-13 15:45, Stefan Hajnoczi wrote: >> On Tue, Aug 13, 2013 at 09:56:17AM +0200, Jan Kiszka wrote: >>> in the attempt to use Alex' ppoll-based timer rework for decoupled, >>> real-time capable timer device models I'm now scratching my h

Re: [Qemu-devel] [PATCH v2 4/4] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 10:53 PM, Paolo Bonzini wrote: > > Il 13/08/2013 07:43, Liu Ping Fan ha scritto: > > After disabling the QemuClock, we should make sure that no QemuTimers > > are still in flight. To implement that with light overhead, we resort > > to QemuEvent.

Re: [Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more precise value

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 4:19 PM, Jan Kiszka wrote: > On 2013-08-13 05:15, Liu Ping Fan wrote: >> If slirp needs to emulate tcp timeout, then the timeout value >> for mainloop should be more precise, which is determined by >> slirp's fasttimo or slowtimo. >>

Re: [Qemu-devel] [PATCH v2 1/4] seqlock: introduce read-write seqlock

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 4:26 PM, Jan Kiszka wrote: > On 2013-08-13 07:43, Liu Ping Fan wrote: >> From: Paolo Bonzini >> >> This lets the read-side access run outside the BQL. >> >> Signed-off-by: Paolo Bonzini >&

Re: [Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more precise value

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 4:29 PM, Jan Kiszka wrote: > On 2013-08-13 10:25, liu ping fan wrote: >> On Tue, Aug 13, 2013 at 4:19 PM, Jan Kiszka wrote: >>> On 2013-08-13 05:15, Liu Ping Fan wrote: >>>> If slirp needs to emulate tcp timeout, then the timeout value &g

Re: [Qemu-devel] [PATCH 1/3] slirp: make timeout local

2013-08-13 Thread liu ping fan
On Tue, Aug 13, 2013 at 4:03 PM, Jan Kiszka wrote: > On 2013-08-13 05:15, Liu Ping Fan wrote: >> Each slirp has its own time to caculate timeout. >> >> Signed-off-by: Liu Ping Fan >> --- >> slirp/slirp.c | 22 ++ >> slirp/slirp.h | 3

[Qemu-devel] [PATCH v2 3/4] qemu-thread: add QemuEvent

2013-08-12 Thread Liu Ping Fan
From: Paolo Bonzini This emulates Win32 manual-reset events using futexes or conditional variables. Typical ways to use them are with multi-producer, single-consumer data structures, to test for a complex condition whose elements come from different threads: for (;;) { qemu_event_re

[Qemu-devel] [PATCH v2 4/4] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-12 Thread Liu Ping Fan
. And the callers of qemu_clock_enable() should be sync by themselves, not protected by this patch. Signed-off-by: Liu Ping Fan --- include/qemu/timer.h | 4 qemu-timer.c | 53 +++- 2 files changed, 56 insertions(+), 1 deletion(-) diff

[Qemu-devel] [PATCH v2 2/4] timer: protect timers_state's clock with seqlock

2013-08-12 Thread Liu Ping Fan
e, it is still protected by BQL. Lock rule: private lock innermost, ie BQL->"this lock" Signed-off-by: Liu Ping Fan --- cpus.c | 36 ++-- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/cpus.c b/cpus.c index a6d7833..a748608 100644

[Qemu-devel] [PATCH v2 1/4] seqlock: introduce read-write seqlock

2013-08-12 Thread Liu Ping Fan
From: Paolo Bonzini This lets the read-side access run outside the BQL. Signed-off-by: Paolo Bonzini --- include/qemu/seqlock.h | 72 ++ 1 file changed, 72 insertions(+) create mode 100644 include/qemu/seqlock.h diff --git a/include/qemu/seqloc

[Qemu-devel] [PATCH v2 0/4] timers thread-safe stuff

2013-08-12 Thread Liu Ping Fan
d code 2. fix race issue for qemu_clock_enable(foo,disable) Liu Ping Fan (2): timer: protect timers_state's clock with seqlock timer: make qemu_clock_enable sync between disable and timer's cb Paolo Bonzini (2): seqlock: introduce read-write seqlock qemu-threa

[Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more precise value

2013-08-12 Thread Liu Ping Fan
If slirp needs to emulate tcp timeout, then the timeout value for mainloop should be more precise, which is determined by slirp's fasttimo or slowtimo. Signed-off-by: Liu Ping Fan --- main-loop.c | 2 +- slirp/slirp.c | 18 ++ 2 files changed, 19 insertions(+), 1 del

[Qemu-devel] [PATCH 1/3] slirp: make timeout local

2013-08-12 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..55654d5 100644 --- a/slirp/slirp.c

[Qemu-devel] [PATCH 2/3] slirp: define timeout as macro

2013-08-12 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 55654d5..1deaad9 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -47,6 +47,9 @@ static QTAILQ_HEAD(slirp_instances, Slirp

[Qemu-devel] [PATCH 0/3] slirp: fill mainloop with more precise timeout value

2013-08-12 Thread Liu Ping Fan
These patches is separated from "[PATCH v1 0/5] make slirp subsystem self-contained", as Paolo suggested. lists.nongnu.org/archive/html/qemu-devel/2013-08/msg00980.html With them, we can fill the timeout of mainloop more precise, when slirp has to emulate tcp timeout problem. Li

Re: [Qemu-devel] [RFC] [PATCHv8 09/30] aio / timers: Add QEMUTimerListGroup and helper functions

2013-08-09 Thread liu ping fan
[...] >> typedef struct QEMUClock QEMUClock; >> typedef struct QEMUTimerList QEMUTimerList; >> +typedef QEMUTimerList *QEMUTimerListGroup[QEMU_CLOCK_MAX]; > > Please wrap this in a struct for easier future extensibility. > > I'm not a big fan of the TimerListGroup name, but I cannot think of > an

Re: [Qemu-devel] [PATCH v1 2/5] slirp: make timeout local

2013-08-09 Thread liu ping fan
On Fri, Aug 9, 2013 at 4:06 PM, Paolo Bonzini wrote: > Il 08/08/2013 08:26, Liu Ping Fan ha scritto: >> Each slirp has its own time to caculate timeout. >> >> Signed-off-by: Liu Ping Fan >> --- >> slirp/slirp.c | 22 ++ >> slirp/s

Re: [Qemu-devel] [RFC] [PATCHv8 00/30] aio / timers: Add AioContext timers and use ppoll

2013-08-09 Thread liu ping fan
On Fri, Aug 9, 2013 at 4:12 PM, Jan Kiszka wrote: > On 2013-08-08 23:41, Alex Bligh wrote: >> This patch series adds support for timers attached to an AioContext clock >> which get called within aio_poll. >> >> In doing so it removes alarm timers and moves to use ppoll where possible. >> >> This p

Re: [Qemu-devel] [PATCH v1 1/5] util: introduce gsource event abstraction

2013-08-09 Thread liu ping fan
On Fri, Aug 9, 2013 at 12:29 AM, Michael Roth wrote: > Quoting Liu Ping Fan (2013-08-08 01:26:07) >> Introduce struct EventsGSource. It will ease the usage of GSource >> associated with a group of files, which are dynamically allocated >> and release, ex, slirp. >> >

[Qemu-devel] [PATCH v1 3/5] slirp: make slirp event dispatch based on slirp instance

2013-08-07 Thread Liu Ping Fan
GPollFD will drive the state of slirp-sockets. Note, the logic in slirp_pollfds_fill/_poll is not changed, but due to drop of the functions, rearrange the code to obey the coding style. For other minor changes, they accord to the nearby style. Signed-off-by: Liu Ping Fan --- main-loop.c | 4

[Qemu-devel] [PATCH v1 2/5] slirp: make timeout local

2013-08-07 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..55654d5 100644 --- a/slirp/slirp.c

[Qemu-devel] [PATCH v1 4/5] slirp: decouple timeout for gpoll

2013-08-07 Thread Liu Ping Fan
In order to decouple with main loop, we fill timeout for gpoll through slirp's GSource prepare. (Later, after curtime is decoupled, slirp system will be self-contained, and isolated from main-loop) Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 4 +--- 1 file changed, 1 insertion(

[Qemu-devel] [PATCH v1 1/5] util: introduce gsource event abstraction

2013-08-07 Thread Liu Ping Fan
Introduce struct EventsGSource. It will ease the usage of GSource associated with a group of files, which are dynamically allocated and release, ex, slirp. Signed-off-by: Liu Ping Fan --- util/Makefile.objs | 1 + util/event_gsource.c | 94

[Qemu-devel] [PATCH v1 5/5] slirp: fold curtime into slirp instance

2013-08-07 Thread Liu Ping Fan
Each slirp instance will work on its own curtime updated when _prepare. This patch help to fold the remaining main-loop's related stuff into GSource, and isolated from main-loop. Signed-off-by: Liu Ping Fan --- main-loop.c | 3 --- slirp/ip_icmp.c | 4 ++-- slirp/libsl

[Qemu-devel] [PATCH v1 0/5] make slirp subsystem self-contained

2013-08-07 Thread Liu Ping Fan
This series aims to port slirp onto GSource, so that it can be driven by g_main_dispatch. And clean up the #ifdef in main-loop. Liu Ping Fan (5): util: introduce gsource event abstraction slirp: make timeout local slirp: make slirp event dispatch based on slirp instance slirp: decouple

Re: [Qemu-devel] [RFC] [PATCHv7 01/22] aio / timers: Add qemu_clock_free and expose qemu_clock_new and clock types

2013-08-07 Thread liu ping fan
On Wed, Aug 7, 2013 at 7:48 AM, Alex Bligh wrote: > Add qemu_clock_free and expose qemu_new_clock as qemu_clock_new. > > Expose clock types. > > Signed-off-by: Alex Bligh > --- > include/qemu/timer.h | 22 ++ > qemu-timer.c | 11 ++- > 2 files changed, 28

Re: [Qemu-devel] [RFC] [PATCHv7 07/22] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList

2013-08-07 Thread liu ping fan
On Wed, Aug 7, 2013 at 7:49 AM, Alex Bligh wrote: > Split QEMUClock into QEMUClock and QEMUTimerList so that we can > have more than one QEMUTimerList associated with the same clock. > > Introduce a default_timerlist concept and make existing > qemu_clock_* calls that actually should operate on a

Re: [Qemu-devel] [PATCH 2/4] timer: protect timers_state's clock with seqlock

2013-08-06 Thread liu ping fan
On Tue, Aug 6, 2013 at 5:30 PM, Stefan Hajnoczi wrote: > On Mon, Aug 05, 2013 at 03:33:24PM +0800, Liu Ping Fan wrote: >> diff --git a/cpus.c b/cpus.c >> index 85e743d..ab92db9 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -107,12 +107,17 @@ static int64_

Re: [Qemu-devel] [PATCH 2/4] timer: protect timers_state's clock with seqlock

2013-08-05 Thread liu ping fan
;> Note in tcg mode, vm_clock still read inside BQL, so icount is >> left without change. As for cpu_ticks in timers_state, it >> is still protected by BQL. >> >> Lock rule: private lock innermost, ie BQL->"this lock" >> >> Signed-off-by: Liu Pi

Re: [Qemu-devel] [PATCH 0/4]: timers thread-safe stuff

2013-08-05 Thread liu ping fan
On Mon, Aug 5, 2013 at 6:00 PM, Alex Bligh wrote: > Pingfan, > > > --On 5 August 2013 15:33:22 +0800 Liu Ping Fan > wrote: > >> The patches has been rebased onto Alex's [RFC] [PATCHv5 00/16] aio / >> timers: Add AioContext timers and use ppoll >> perm

[Qemu-devel] [PATCH 3/4] qemu-thread: add QemuEvent

2013-08-05 Thread Liu Ping Fan
From: Paolo Bonzini This emulates Win32 manual-reset events using futexes or conditional variables. Typical ways to use them are with multi-producer, single-consumer data structures, to test for a complex condition whose elements come from different threads: for (;;) { qemu_event_re

[Qemu-devel] [PATCH 4/4] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-05 Thread Liu Ping Fan
. And the callers of qemu_clock_enable() should be sync by themselves, not protected by this patch. Signed-off-by: Liu Ping Fan --- include/qemu/timer.h | 1 + qemu-timer.c | 11 +++ 2 files changed, 12 insertions(+) diff --git a/include/qemu/timer.h b/include/qemu/timer.h

[Qemu-devel] [PATCH 1/4] seqlock: introduce read-write seqlock

2013-08-05 Thread Liu Ping Fan
From: Paolo Bonzini This lets the read-side access run outside the BQL. Signed-off-by: Paolo Bonzini --- include/qemu/seqlock.h | 72 ++ 1 file changed, 72 insertions(+) create mode 100644 include/qemu/seqlock.h diff --git a/include/qemu/seqloc

[Qemu-devel] [PATCH 2/4] timer: protect timers_state's clock with seqlock

2013-08-05 Thread Liu Ping Fan
protected by BQL. Lock rule: private lock innermost, ie BQL->"this lock" Signed-off-by: Liu Ping Fan --- cpus.c | 36 +--- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/cpus.c b/cpus.c index 85e743d..ab92db9 100644 --- a/cpus.c

[Qemu-devel] [PATCH 0/4]: timers thread-safe stuff

2013-08-05 Thread Liu Ping Fan
e(foo,false) Liu Ping Fan (2): timer: protect timers_state's clock with seqlock timer: make qemu_clock_enable sync between disable and timer's cb Paolo Bonzini (2): seqlock: introduce read-write seqlock qemu-thread: add QemuEvent cpus.c | 36 +++--

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-04 Thread liu ping fan
On Fri, Aug 2, 2013 at 10:43 PM, Stefan Hajnoczi wrote: > On Fri, Aug 02, 2013 at 11:33:40AM +0800, liu ping fan wrote: >> On Thu, Aug 1, 2013 at 9:28 PM, Alex Bligh wrote: >> > Paolo, >> > >> > >> > --On 1 August 2013 08:19:34 -0400 Paolo Bonzini

Re: [Qemu-devel] [sheepdog] [PATCH v4 06/10] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers

2013-08-02 Thread liu ping fan
On Fri, Aug 2, 2013 at 2:20 PM, MORITA Kazutaka wrote: > At Tue, 30 Jul 2013 15:58:58 +0200, > Stefan Hajnoczi wrote: >> >> On Fri, Jul 26, 2013 at 03:10:48PM +0900, MORITA Kazutaka wrote: >> > This helper function behaves similarly to co_sleep_ns(), but the >> > sleeping coroutine will be resumed

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-01 Thread liu ping fan
On Thu, Aug 1, 2013 at 9:28 PM, Alex Bligh wrote: > Paolo, > > > --On 1 August 2013 08:19:34 -0400 Paolo Bonzini wrote: > >>> > True, qemu_event basically works only when a single thread resets it. >>> > But there is no race condition here because qemu_run_timers cannot be >>> > executed concurre

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-08-01 Thread liu ping fan
On Thu, Aug 1, 2013 at 10:28 PM, Paolo Bonzini wrote: > On Aug 01 2013, Alex Bligh wrote: >> Paolo, >> >> --On 1 August 2013 15:51:11 +0200 Paolo Bonzini wrote: >> >> >>> So actually there is another problem with this patch (both the >> >>> condvar and the event approach are equally buggy). If

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-07-31 Thread liu ping fan
On Tue, Jul 30, 2013 at 5:17 PM, Paolo Bonzini wrote: > Il 30/07/2013 04:42, liu ping fan ha scritto: >> On Mon, Jul 29, 2013 at 7:21 PM, Paolo Bonzini wrote: >>> Il 29/07/2013 10:10, liu ping fan ha scritto: >>>> On Mon, Jul 29, 2013 at 2:30 PM, Paolo Bonzini wr

Re: [Qemu-devel] [RFC v2 0/5] arm AioContext with its own timer stuff

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 5:22 PM, Stefan Hajnoczi wrote: > On Mon, Jul 29, 2013 at 11:16:03AM +0800, Liu Ping Fan wrote: >> summary of the model: >> Three qemu-wide clock source allowed in system. And each AioContext has >> three corresponding timer list to run time

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 7:21 PM, Paolo Bonzini wrote: > Il 29/07/2013 10:10, liu ping fan ha scritto: >> On Mon, Jul 29, 2013 at 2:30 PM, Paolo Bonzini wrote: >>> Il 29/07/2013 05:16, Liu Ping Fan ha scritto: >>>> After disabling the QemuClock, we should make su

Re: [Qemu-devel] [RFC v2 4/5] timer: associate three timerlists with AioContext

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 9:11 PM, Paolo Bonzini wrote: > Il 29/07/2013 10:20, liu ping fan ha scritto: >>> > Another issue is that deadline computation is not using the AioContext's >>> > timer lists. >>> > >> Sorry, can not catch the meaning. W

Re: [Qemu-devel] [RFC v2 4/5] timer: associate three timerlists with AioContext

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 2:32 PM, Paolo Bonzini wrote: > Il 29/07/2013 05:16, Liu Ping Fan ha scritto: >> Currently, timers run on iothread inside QBL, this limits the usage >> of timers in some case, e.g. virtio-blk-dataplane. In order to run >> timers on private thre

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 2:30 PM, Paolo Bonzini wrote: > Il 29/07/2013 05:16, Liu Ping Fan ha scritto: >> After disabling the QemuClock, we should make sure that no QemuTimers >> are still in flight. To implement that, the caller of disabling will >> wait until the last us

Re: [Qemu-devel] [RFC v2 1/5] timer: protect timers_state with lock

2013-07-29 Thread liu ping fan
On Mon, Jul 29, 2013 at 2:26 PM, Paolo Bonzini wrote: > Il 29/07/2013 05:16, Liu Ping Fan ha scritto: >> In kvm mode, vm_clock may be read on AioContexts outside BQL(next >> patch). This will make timers_state --the foundation of vm_clock >> exposed to race condition.

[Qemu-devel] [RFC v2 5/5] timer: run timers on aio_poll

2013-07-28 Thread Liu Ping Fan
Stop call timers in main loop and let each mini event-loop run its own timers. Signed-off-by: Liu Ping Fan --- aio-posix.c | 2 ++ include/qemu/timer.h | 4 ++-- main-loop.c | 2 -- qemu-timer.c | 15 ++- 4 files changed, 14 insertions(+), 9 deletions

[Qemu-devel] [RFC v2 4/5] timer: associate three timerlists with AioContext

2013-07-28 Thread Liu Ping Fan
later, we will run timers in aio_poll. Signed-off-by: Liu Ping Fan -- issue to fix --- Note: before this patch, there should be another one to fix the race issue by qemu_mod_timer() and _run_timers(). --- async.c | 9 include/block/aio.h | 13 +++ include/qemu

[Qemu-devel] [RFC v2 2/5] timer: pick out timer list info from QemuClock

2013-07-28 Thread Liu Ping Fan
-off-by: Liu Ping Fan --- qemu-timer.c | 106 ++- 1 file changed, 68 insertions(+), 38 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 9500d12..5a42035 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -30,6 +30,7 @@ #include "

[Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb

2013-07-28 Thread Liu Ping Fan
After disabling the QemuClock, we should make sure that no QemuTimers are still in flight. To implement that, the caller of disabling will wait until the last user's exit. Note, the callers of qemu_clock_enable() should be sync by themselves, not protected by this patch. Signed-off-by: Liu

[Qemu-devel] [RFC v2 1/5] timer: protect timers_state with lock

2013-07-28 Thread Liu Ping Fan
lock innermost, ie BQL->"this lock" Signed-off-by: Liu Ping Fan --- cpus.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/cpus.c b/cpus.c index 61e86a8..4af81e9 100644 --- a/cpus.c +++ b/cpus.c @@ -112,7 +112,9 @@ typedef struc

[Qemu-devel] [RFC v2 0/5] arm AioContext with its own timer stuff

2013-07-28 Thread Liu Ping Fan
problem (Thanks for Jan and Stefan) fix process=true when aio_poll run timers (Thanks for Alex) Liu Ping Fan (5): timer: protect timers_state with lock timer: pick out timer list info from QemuClock timer: make qemu_clock_enable sync between disable and timer's cb timer: associate

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-24 Thread liu ping fan
[...] >> http://social.msdn.microsoft.com/Forums/vstudio/en-US/e8a7cb1e-9edd-4ee3-982e-f66b7bf6ae44/improve-accuracy-waitforsingleobject >> >> suggest that WaitFor{Single,Multiple}Objects can have pretty >> appalling latency anyway (100ms!), and there's no evidence that's >> limited by making one o

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-24 Thread liu ping fan
On Wed, Jul 24, 2013 at 2:42 PM, Paolo Bonzini wrote: > Il 24/07/2013 03:28, liu ping fan ha scritto: >> On Tue, Jul 23, 2013 at 6:30 PM, Paolo Bonzini wrote: >>> > Il 23/07/2013 04:53, liu ping fan ha scritto: >>>> >> The scenior I can figure out is

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-23 Thread liu ping fan
On Tue, Jul 23, 2013 at 6:30 PM, Paolo Bonzini wrote: > Il 23/07/2013 04:53, liu ping fan ha scritto: >> The scenior I can figure out is if adopting timeout of poll, then when >> changing the deadline, we need to invoke poll, and set the new >> timeout, right? > > Yes,

Re: [Qemu-devel] [RFC 6/8] timer: run timers on aio_poll

2013-07-22 Thread liu ping fan
On Sun, Jul 21, 2013 at 5:55 PM, Alex Bligh wrote: > > > --On 21 July 2013 16:43:03 +0800 Liu Ping Fan wrote: > >> diff --git a/aio-posix.c b/aio-posix.c >> index b68eccd..29c2769 100644 >> --- a/aio-posix.c >> +++ b/aio-posix.c >> @@ -191,6 +191,8 @@ bo

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-22 Thread liu ping fan
On Mon, Jul 22, 2013 at 6:18 PM, liu ping fan wrote: > On Mon, Jul 22, 2013 at 5:40 PM, Alex Bligh wrote: >> Liu, >> >> >> --On 22 July 2013 12:38:02 +0800 liu ping fan wrote: >> >>> I read your second series, and try to summary the main differe

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-22 Thread liu ping fan
On Mon, Jul 22, 2013 at 2:28 PM, Jan Kiszka wrote: > On 2013-07-22 06:38, liu ping fan wrote: >> On Sun, Jul 21, 2013 at 5:53 PM, Alex Bligh wrote: >>> Liu, >>> >>> >>> --On 21 July 2013 16:42:57 +0800 Liu Ping Fan wrote: >>> >>&g

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-22 Thread liu ping fan
On Mon, Jul 22, 2013 at 5:40 PM, Alex Bligh wrote: > Liu, > > > --On 22 July 2013 12:38:02 +0800 liu ping fan wrote: > >> I read your second series, and try to summary the main different between >> us. Please correct me, if I misunderstood something. >> --

Re: [Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-21 Thread liu ping fan
On Sun, Jul 21, 2013 at 5:53 PM, Alex Bligh wrote: > Liu, > > > --On 21 July 2013 16:42:57 +0800 Liu Ping Fan wrote: > >> Currently, the timers run on iothread within BQL, so virtio-block >> dataplane can not use throttle, as Stefan Hajnoczi pointed out in his >&g

[Qemu-devel] [RFC 6/8] timer: run timers on aio_poll

2013-07-21 Thread Liu Ping Fan
Stop call timers in main loop and let each mini event-loop run its own timers. Signed-off-by: Liu Ping Fan --- aio-posix.c | 2 ++ main-loop.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aio-posix.c b/aio-posix.c index b68eccd..29c2769 100644 --- a/aio-posix.c +++ b

[Qemu-devel] [RFC 8/8] block: enable throttle with aiocontext

2013-07-21 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- block.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index c6b7b6c..b9e6cc8 100644 --- a/block.c +++ b/block.c @@ -149,7 +149,12 @@ static void bdrv_block_timer(void *opaque) void bdrv_io_limits_enable

[Qemu-devel] [RFC 5/8] timer: associate timer with AioContext

2013-07-21 Thread Liu Ping Fan
Currently, timers run on iothread inside QBL, this limits the usage of timers in some case, e.g. virtio-blk-dataplane. In order to run timers on private thread, we arm AioContext with three lists in according to three QemuClock (and later, run timers in aio_poll). Signed-off-by: Liu Ping Fan

[Qemu-devel] [RFC 3/8] timer: make timers_state static

2013-07-21 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 61e86a8..4254ca9 100644 --- a/cpus.c +++ b/cpus.c @@ -112,7 +112,7 @@ typedef struct TimersState { int64_t dummy; } TimersState; -TimersState timers_state

[Qemu-devel] [RFC 7/8] block: associate BlockDriverState with AioContext

2013-07-21 Thread Liu Ping Fan
The default aio for BDS is qemu_aio_context, while for data plane, it will has its own ctx. Relating BDS with AioContext can help block layer to determine its running environment. Some stuff like timers need such info, so that they can run in the correct environment. Signed-off-by: Liu Ping Fan

[Qemu-devel] [RFC 4/8] timer: protect timers_state with lock

2013-07-21 Thread Liu Ping Fan
lock innermost, ie BQL->"this lock" Signed-off-by: Liu Ping Fan --- cpus.c | 27 +++ 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 4254ca9..22df5fb 100644 --- a/cpus.c +++ b/cpus.c @@ -113,6 +113,8 @@ typedef struc

[Qemu-devel] [RFC 1/8] timer: associate alarm_timer with AioContext

2013-07-21 Thread Liu Ping Fan
are linked on a QSLIST for clock reset. Signed-off-by: Liu Ping Fan - To fix sigaction(SIGALRM, &act, NULL) is process-wide, not thread? I think what I need is an timerfd for each thread, right? Will fix in next version. --- async.c | 3 ++ include/block/a

[Qemu-devel] [RFC 2/8] timer: pick out timer list info from QemuClock

2013-07-21 Thread Liu Ping Fan
To allow timer to run on the different backend threads, we will arm the thread's AioContext with its own timer list. So separate these kind of info from QemuClock. Signed-off-by: Liu Ping Fan --- qemu-timer.c | 106 ++- 1 file change

[Qemu-devel] [RFC 0/8] arm AioContext with its own timer stuff

2013-07-21 Thread Liu Ping Fan
I plan to adopt the bh model. (Not sure about this, maybe Stefan's solution in another thread is better) Although leave most of the race issue unresolved, patch 4 has tried to fix one of them as Jan Kiszka points out that vm_clock can be read outside BQL, thanks Jan :) Liu Ping Fa

[Qemu-devel] [PATCH v2 2/2] object: Object apply the refcnt interface by Qref

2013-07-15 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- include/qom/object.h | 3 ++- qom/object.c | 15 +-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 23fc048..6331972 100644 --- a/include/qom/object.h +++ b/include/qom

[Qemu-devel] [PATCH v2 1/2] refcnt: introduce Qref to abstract the refcnt interface

2013-07-15 Thread Liu Ping Fan
Qref is similar to kref. It hides the refcnt detail and provides a common interface. And this patch is based on the idiom of refcnt, and adopts some optimization about memory model, which finally falls back on gcc implementation. Signed-off-by: Liu Ping Fan --- v2: put Qref to a dedicated

[Qemu-devel] [PATCH v6] QEMUBH: make AioContext's bh re-entrant

2013-07-15 Thread Liu Ping Fan
BH will be used outside big lock, so introduce lock to protect between the writers, ie, bh's adders and deleter. The lock only affects the writers and bh's callback does not take this extra lock. Note that for the same AioContext, aio_bh_poll() can not run in parallel yet. Signed-off-by

[Qemu-devel] [PATCH 1/2] object: introduce Qref to abstract the refcnt interface

2013-07-14 Thread Liu Ping Fan
Qref is similar to kref. It hides the refcnt detail and provides a common interface. And this patch is based on the idiom of refcnt, and adopts some optimization about memory model, which finally falls back on gcc implementation. Signed-off-by: Liu Ping Fan --- include/qom/object.h | 34

[Qemu-devel] [PATCH 2/2] object: Object apply the refcnt interface by Qref

2013-07-14 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan --- include/qom/object.h | 2 +- qom/object.c | 15 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 2e165fb..8426dd1 100644 --- a/include/qom/object.h +++ b/include/qom/object.h

Re: [Qemu-devel] [PATCH v2] atomic: using memory_order_relaxed for refcnt inc/dec ops

2013-07-14 Thread liu ping fan
On Sun, Jul 14, 2013 at 1:57 PM, Paolo Bonzini wrote: > Il 14/07/2013 04:53, Liu Ping Fan ha scritto: >> Refcnt's atomic inc/dec ops are frequent and its idiom need no seq_cst >> order. So to get better performance, it worth to adopt _relaxed >> other than _seq_cst memo

[Qemu-devel] [PATCH v2] atomic: using memory_order_relaxed for refcnt inc/dec ops

2013-07-13 Thread Liu Ping Fan
ltins. Signed-off-by: Liu Ping Fan --- v2: update atomics.txt fix the dependency MACRO --- docs/atomics.txt | 4 include/qemu/atomic.h | 14 ++ 2 files changed, 18 insertions(+) diff --git a/docs/atomics.txt b/docs/atomics.txt index 6f2997b..c8ad31d 100644 --- a

Re: [Qemu-devel] [PATCH] atomic: using memory_order_relaxed for refcnt inc/dec ops

2013-07-13 Thread liu ping fan
On Sat, Jul 13, 2013 at 12:24 AM, Richard Henderson wrote: > On 07/11/2013 11:32 PM, Liu Ping Fan wrote: >> Refcnt's atomic inc/dec ops are frequent and its idiom need no seq_cst >> order. So to get better performance, it worth to adopt _relaxed >> other than _se

[Qemu-devel] [PATCH] atomic: using memory_order_relaxed for refcnt inc/dec ops

2013-07-11 Thread Liu Ping Fan
ltins. Signed-off-by: Liu Ping Fan --- include/qemu/atomic.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 0aa8913..1f474b7 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -183,8 +183,15 @@ #endif /* Pr

Re: [Qemu-devel] [PATCH v5] QEMUBH: make AioContext's bh re-entrant

2013-07-07 Thread liu ping fan
On Sun, Jul 7, 2013 at 8:31 PM, Andreas Färber wrote: > Am 07.07.2013 12:00, schrieb Liu Ping Fan: >> From: Liu Ping Fan >> >> BH will be used outside big lock, so introduce lock to protect >> between the writers, ie, bh's adders and deleter. The lock only

<    1   2   3   4   5   6   7   8   >