Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 10:06 +1000, Alexey Kardashevskiy wrote: > I already posted another patch with qemu_notify_event() in this mail > thread later :) Yup, just saw that, for some reason I got dropped from the CC list. BTW. I told you there must be an existing mechanism for that :-) Cheers, Ben

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 10:42 +1000, ronnie sahlberg wrote: > > Would it be possible to change the set-event-handlers functions to > automatically call qemu_notify_event() when the descriptos change? > To eliminate the need to call this function at all ? That definitely sounds like the right thing

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 10:06 +1000, Alexey Kardashevskiy wrote: > > Won't that conflict with the business in coroutine-sigaltstack.c ? > > The code which touches SIGUSR2 does not compile on power. Oh, we don't get the altstack coroutine stuff ? interesting... > > Hrm... looking at it, it looks li

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread ronnie sahlberg
Hi, As Paolo said, I hit this with block/iscsi.c a few months back. Then about a month back I recall something that looks alkmost identical to this hit the IDE driver on the KVM list. ( At least the symptoms looked just like my symptoms, and the KVM guys managed to bisect it down to the exact same

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Alexey Kardashevskiy
On 02/07/12 09:07, Benjamin Herrenschmidt wrote: diff --git a/iohandler.c b/iohandler.c index 3c74de6..54f4c48 100644 --- a/iohandler.c +++ b/iohandler.c @@ -77,6 +77,7 @@ int qemu_set_fd_handler2(int fd, ioh->fd_write = fd_write; ioh->opaque = o

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Benjamin Herrenschmidt
> >> diff --git a/iohandler.c b/iohandler.c > >> index 3c74de6..54f4c48 100644 > >> --- a/iohandler.c > >> +++ b/iohandler.c > >> @@ -77,6 +77,7 @@ int qemu_set_fd_handler2(int fd, > >> ioh->fd_write = fd_write; > >> ioh->opaque = opaque; > >> ioh->deleted = 0; > >> +

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Benjamin Herrenschmidt
> Doesn't qemu remove an fd handler before closing the fd? > If not that's the bug right there. No, it's just marked deleted, removal is deferred. But that doesn't change the fact that you need to wake up select. Ie. What happens is: - eventfd gets you fd #x - thread 1 selects() on it which s

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Paolo Bonzini
Il 01/07/2012 16:46, Alexey Kardashevskiy ha scritto: > On 01/07/12 23:40, Alexey Kardashevskiy wrote: >> On 01/07/12 23:32, Paolo Bonzini wrote: >>> Il 01/07/2012 13:06, Alexey Kardashevskiy ha scritto: Doing MSI init stuff, QEMU-VFIO calls the same event_notifier_init() (returns recycle

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Alexey Kardashevskiy
On 01/07/12 23:40, Alexey Kardashevskiy wrote: > On 01/07/12 23:32, Paolo Bonzini wrote: >> Il 01/07/2012 13:06, Alexey Kardashevskiy ha scritto: >>> Doing MSI init stuff, QEMU-VFIO calls the same event_notifier_init() >>> (returns recycled fd=XX what is correct but confuses) and >>> qemu_set_fd_ha

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Alexey Kardashevskiy
On 01/07/12 23:32, Paolo Bonzini wrote: > Il 01/07/2012 13:06, Alexey Kardashevskiy ha scritto: >> Doing MSI init stuff, QEMU-VFIO calls the same event_notifier_init() >> (returns recycled fd=XX what is correct but confuses) and >> qemu_set_fd_handler() which adds a handler but select() does not pi

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Paolo Bonzini
Il 01/07/2012 13:06, Alexey Kardashevskiy ha scritto: > Doing MSI init stuff, QEMU-VFIO calls the same event_notifier_init() > (returns recycled fd=XX what is correct but confuses) and > qemu_set_fd_handler() which adds a handler but select() does not pick > it up. This sounds like a missing qemu_

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Alexey Kardashevskiy
On 01/07/12 22:43, Michael S. Tsirkin wrote: > On Sun, Jul 01, 2012 at 09:06:20PM +1000, Alexey Kardashevskiy wrote: >> QEMU from qemu.org/master (not qemu-kvm), linux host 3.4, ppc64. >> >> Shortly the problem is in the host kernel: closing a file in one thread does >> not interrupt select() wait

Re: [Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Michael S. Tsirkin
On Sun, Jul 01, 2012 at 09:06:20PM +1000, Alexey Kardashevskiy wrote: > QEMU from qemu.org/master (not qemu-kvm), linux host 3.4, ppc64. > > Shortly the problem is in the host kernel: closing a file in one thread does > not interrupt select() waiting on the same file description in another thread

[Qemu-devel] QEMU question: is eventfd not thread safe?

2012-07-01 Thread Alexey Kardashevskiy
QEMU from qemu.org/master (not qemu-kvm), linux host 3.4, ppc64. Shortly the problem is in the host kernel: closing a file in one thread does not interrupt select() waiting on the same file description in another thread. Longer story is: I'll use VFIO as an example as I hit this when I was debug