Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-06 Thread Paolo Bonzini
Il 05/03/2012 18:35, Avi Kivity ha scritto: The I/O handlers would still use the qemu mutex, no? we'd just protect the select() (taking the mutex from before releasing the global lock, and reacquiring it afterwards). Yes, that could work, but it is _really_ ugly. Yes, it is...

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Jan Kiszka
On 2012-03-05 09:34, Paolo Bonzini wrote: This is quite ugly. Two threads, one running main_loop_wait and one running qemu_aio_wait, can race with each other on running the same iohandler. The result is that an iohandler could run while the underlying socket is not readable or writable, with

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Paolo Bonzini
Il 05/03/2012 10:07, Jan Kiszka ha scritto: This is quite ugly. Two threads, one running main_loop_wait and one running qemu_aio_wait, can race with each other on running the same iohandler. The result is that an iohandler could run while the underlying socket is not readable or

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Avi Kivity
On 03/05/2012 11:07 AM, Jan Kiszka wrote: On 2012-03-05 09:34, Paolo Bonzini wrote: This is quite ugly. Two threads, one running main_loop_wait and one running qemu_aio_wait, can race with each other on running the same iohandler. The result is that an iohandler could run while the

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Jan Kiszka
On 2012-03-05 15:24, Avi Kivity wrote: Long-term, I'd like to cut out certain file descriptors from the main loop and process them completely in separate threads (for separate locking, prioritization etc.). Dunno how NBD works, but maybe it should be reworked like this already. Ideally

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Paolo Bonzini
Il 05/03/2012 15:24, Avi Kivity ha scritto: On 03/05/2012 11:07 AM, Jan Kiszka wrote: On 2012-03-05 09:34, Paolo Bonzini wrote: This is quite ugly. Two threads, one running main_loop_wait and one running qemu_aio_wait, can race with each other on running the same iohandler. The result is

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Avi Kivity
On 03/05/2012 04:30 PM, Paolo Bonzini wrote: Il 05/03/2012 15:24, Avi Kivity ha scritto: On 03/05/2012 11:07 AM, Jan Kiszka wrote: On 2012-03-05 09:34, Paolo Bonzini wrote: This is quite ugly. Two threads, one running main_loop_wait and one running qemu_aio_wait, can race with each other

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Paolo Bonzini
Il 05/03/2012 16:14, Avi Kivity ha scritto: Hmm, I don't think so. It would need to protect execution of the iohandlers too, and pretty much everything can happen there including a nested loop. Of course recursive mutexes exist, but it sounds like too big an axe. The I/O handlers would

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Avi Kivity
On 03/05/2012 06:14 PM, Paolo Bonzini wrote: Il 05/03/2012 16:14, Avi Kivity ha scritto: Hmm, I don't think so. It would need to protect execution of the iohandlers too, and pretty much everything can happen there including a nested loop. Of course recursive mutexes exist, but it

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Avi Kivity
On 03/05/2012 04:30 PM, Jan Kiszka wrote: On 2012-03-05 15:24, Avi Kivity wrote: Long-term, I'd like to cut out certain file descriptors from the main loop and process them completely in separate threads (for separate locking, prioritization etc.). Dunno how NBD works, but maybe it should

Re: [Qemu-devel] [RFC PATCH] fix select(2) race between main_loop_wait and qemu_aio_wait

2012-03-05 Thread Jan Kiszka
On 2012-03-05 18:39, Avi Kivity wrote: On 03/05/2012 04:30 PM, Jan Kiszka wrote: On 2012-03-05 15:24, Avi Kivity wrote: Long-term, I'd like to cut out certain file descriptors from the main loop and process them completely in separate threads (for separate locking, prioritization etc.). Dunno