From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SlUio-0007Up-Sh for qemu-devel@nongnu.org; Sun, 01 Jul 2012 20:42:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SlUim-0007dd-VS for qemu-devel@nongnu.org; Sun, 01 Jul 2012 20:42:34 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:34551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SlUim-0007dF-Ng for qemu-devel@nongnu.org; Sun, 01 Jul 2012 20:42:32 -0400 Received: by obbta14 with SMTP id ta14so7729047obb.4 for ; Sun, 01 Jul 2012 17:42:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FF0E5FB.1080200@ozlabs.ru> References: <4FF02F2C.30006@ozlabs.ru> <20120701124314.GB4782@redhat.com> <4FF04939.7050608@ozlabs.ru> <1341184071.2588.10.camel@pasglop> <4FF0E5FB.1080200@ozlabs.ru> Date: Mon, 2 Jul 2012 10:42:29 +1000 Message-ID: From: ronnie sahlberg Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] QEMU question: is eventfd not thread safe? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Alex Williamson , "Michael S. Tsirkin" , qemu-devel@nongnu.org, David Gibson 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 patch that I did that would expose the bug in block.iscsi.c, namely the lack of calling qemu_notify_event() ) If we have hit a problem 3 times recently due to developers not realizing the importance of calling qemu_notify_event(), maybe the API is suboptimal. 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 ? regards ronnie sahlberg On Mon, Jul 2, 2012 at 10:06 AM, Alexey Kardashevskiy wrote= : > 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, >>>>> =A0 =A0 =A0 =A0 =A0ioh->fd_write =3D fd_write; >>>>> =A0 =A0 =A0 =A0 =A0ioh->opaque =3D opaque; >>>>> =A0 =A0 =A0 =A0 =A0ioh->deleted =3D 0; >>>>> + =A0 =A0 =A0 =A0kill(getpid(), SIGUSR2); >>>>> =A0 =A0 =A0} >>>>> =A0 =A0 =A0return 0; >>>>> =A0} >> >> That probably wants to be a pthread_kill targetted at the main loop. >> >>>>> +static void sigusr2_print(int signal) >>>>> +{ >>>>> +} >>>>> + >>>>> +static void sigusr2_init(void) >>>>> +{ >>>>> + =A0 =A0struct sigaction action; >>>>> + >>>>> + =A0 =A0memset(&action, 0, sizeof(action)); >>>>> + =A0 =A0sigfillset(&action.sa_mask); >>>>> + =A0 =A0action.sa_handler =3D sigusr2_print; >>>>> + =A0 =A0action.sa_flags =3D 0; >>>>> + =A0 =A0sigaction(SIGUSR2, &action, NULL); >>>>> +} >>>>> + >> >> Won't that conflict with the business in coroutine-sigaltstack.c ? > > The code which touches SIGUSR2 does not compile on power. > >> Hrm... looking at it, it looks like it will save/restore the handler, >> so that should be good. >> >> Still, one might want to wrap that into something, like >> qemu_wake_main_loop(); > > > I already posted another patch with qemu_notify_event() in this mail thre= ad later :) > > >> >> Cheers, >> Ben. >> >>>>> =A0int main_loop_init(void) >>>>> =A0{ >>>>> =A0 =A0 =A0int ret; >>>>> >>>>> + =A0 =A0sigusr2_init(); >>>>> + >>>>> =A0 =A0 =A0qemu_mutex_lock_iothread(); >>>>> =A0 =A0 =A0ret =3D qemu_signal_init(); >>>>> =A0 =A0 =A0if (ret) { >>>>> -- >>>>> 1.7.10 >>> >>> >> >> > > > -- > Alexey >