qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Cc: xen-devel@lists.xensource.com,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.
Date: Tue, 26 Aug 2008 18:47:30 +0100	[thread overview]
Message-ID: <20080826174729.GB25893@shareable.org> (raw)
In-Reply-To: <48B422F2.1090900@codemonkey.ws>

Anthony Liguori wrote:
> In KVM, we do use the signal number to determine action.  We could use 
> globals but since we're multi-threaded, that gets pretty nasty.  The 
> same would apply to a threaded QEMU.

Often one pipe per select-caller is enough, with global state to
distinguish events.  For signalfd() emulation, that's an array of

    sig_atomic_t signal_was_hit[NSIG];

(Or just `char' - in pthreads that should be safe to write, right?
One bit is enough storage, but not thread safe.)

However, if you depend on the signal number _combined_ with which
thread receives the signal - then you're in trouble.

pthread_self() should not be called from a signal handler; it's safety
is not portable.  Thread-local storage (__thread int x) is not
portable and might not be signal safe either.  All you've got left is
gettid(), and that's not portable either.

"signalfd helper thread writing to pipe" wouldn't solve that either.
You'd need one _per_ thread that would have called signalfd() (if you
had it) - in order to distinguish recipients.  But that helper's
handler can't tell which thread it is, and therefore which pipe to write to!

But you did say you're using signalfd().  And signalfd() doesn't
distinguish thread recipients (I'm surprised it doesn't).  That whole
meander was just an interesting but irrelevant puzzle.

Leading to: why would (real) signals being used to collect AIO events
anyway, if you don't have signalfd()?  If you've got a helper thread,
just call aio_suspend() in the helper thread.  Then you can just
deliver the AIO completion result to the relevant data structure or
even move it off the waiting queue (pthread_mutex_lock is your
friend), then wake the main waiting thread with byte written to its
pipe.

-- Jamie

  reply	other threads:[~2008-08-26 17:47 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 16:27 [Qemu-devel] [PATCH 00/13] merge some xen bits into qemu Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 01/13] Handle terminating signals Gerd Hoffmann
2008-08-21 20:11   ` Anthony Liguori
     [not found]   ` <m2n.s.1KWGbo-001Nr9@chiark.greenend.org.uk>
2008-08-26 10:44     ` Ian Jackson
2008-08-26 12:16       ` Gerd Hoffmann
2008-08-26 12:36         ` Ian Jackson
2008-08-26 12:58           ` Gerd Hoffmann
2008-08-26 17:55             ` Jamie Lokier
2008-08-26 13:17           ` Anthony Liguori
2008-08-26 13:38             ` [Xen-devel] " Ian Jackson
2008-08-26 14:52               ` Avi Kivity
2008-08-26 17:49                 ` Jamie Lokier
2008-08-26 15:04               ` Anthony Liguori
2008-08-26 15:08                 ` Ian Jackson
2008-08-26 15:20                   ` Anthony Liguori
2008-08-26 15:28                     ` Ian Jackson
2008-08-26 15:36                       ` Anthony Liguori
2008-08-26 17:47                         ` Jamie Lokier [this message]
2008-08-26 18:03                           ` Jamie Lokier
2008-08-26 18:50                           ` Anthony Liguori
2008-08-27  9:46                           ` Ian Jackson
2008-08-27 16:27                             ` Jamie Lokier
2008-08-27 16:35                               ` Ian Jackson
2008-08-27 17:55                                 ` Anthony Liguori
2008-08-27 18:41                                 ` Jamie Lokier
2008-08-28  9:34                                   ` Ian Jackson
2008-09-07  2:41                                     ` Anthony Liguori
2008-08-26 15:36                       ` Samuel Thibault
2008-08-26 15:21                   ` Anthony Liguori
     [not found]               ` <m2n.s.1KXzwZ-002RA9@chiark.greenend.org.uk>
2008-08-26 15:23                 ` Ian Jackson
2008-08-26 15:29                   ` Avi Kivity
     [not found]                   ` <m2n.s.1KY0XT-002RJM@chiark.greenend.org.uk>
2008-08-26 15:38                     ` Ian Jackson
2008-08-26 16:12                       ` Avi Kivity
2008-08-26 16:14                         ` Julian Seward
2008-08-26 16:39                           ` Anthony Liguori
2008-08-27  8:05                           ` Avi Kivity
2008-08-27  8:49                             ` Alan Cox
2008-08-27  9:10                               ` Avi Kivity
2008-08-27  9:16                                 ` Keir Fraser
2008-08-27  9:12                               ` Gleb Natapov
     [not found]             ` <m2n.s.1KXz4u-002Qvq@chiark.greenend.org.uk>
2008-08-26 14:55               ` Ian Jackson
2008-08-21 16:27 ` [Qemu-devel] [PATCH 02/13] add DisplayState->idle Gerd Hoffmann
2008-08-21 16:33   ` [Qemu-devel] " Samuel Thibault
2008-08-21 20:12   ` [Qemu-devel] " Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 03/13] add container_of() macro to osdep.h Gerd Hoffmann
2008-08-21 20:12   ` Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 04/13] move GUI_REFRESH_INTERVAL define from vl.c to console.h Gerd Hoffmann
2008-08-21 20:12   ` Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support Gerd Hoffmann
2008-08-21 20:18   ` Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 06/13] xen: backend driver core Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 07/13] xen: add console backend driver Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 08/13] xen: add framebuffer " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 09/13] xen: add block device " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 10/13] xen: add net " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 11/13] xen: blk & nic configuration via cmd line Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 12/13] set vnc password from xenstore Gerd Hoffmann
2008-08-21 20:14   ` Anthony Liguori
2008-08-21 20:19     ` [Xen-devel] " Daniel P. Berrange
2008-08-21 20:22       ` Anthony Liguori
2008-08-21 20:26         ` Daniel P. Berrange
2008-08-21 21:34         ` Gerd Hoffmann
2008-08-21 21:48           ` Daniel P. Berrange
2008-08-21 22:36             ` Anthony Liguori
2008-08-24  9:03               ` Avi Kivity
2008-08-22  7:04             ` Gerd Hoffmann
2008-08-22 19:11               ` Jamie Lokier
2008-08-22 19:01             ` Jamie Lokier
2008-08-21 22:34           ` Anthony Liguori
2008-08-22  8:27             ` Gerd Hoffmann
2008-08-24  8:57         ` Avi Kivity
2008-08-24  9:59           ` Jamie Lokier
2008-08-24 10:07             ` Avi Kivity
2008-08-24 12:48               ` Jamie Lokier
2008-08-21 20:59       ` Jamie Lokier
2008-08-21 21:29       ` Gerd Hoffmann
2008-08-26 10:13     ` Ian Jackson
2008-08-21 20:17   ` [Qemu-devel] Re: [Xen-devel] " Daniel P. Berrange
2008-08-21 21:25     ` Gerd Hoffmann
     [not found]     ` <m2n.s.1KWHfl-001Ntw@chiark.greenend.org.uk>
2008-08-26 10:47       ` Ian Jackson
2008-08-21 16:27 ` [Qemu-devel] [PATCH 13/13] xen: pv domain builder Gerd Hoffmann
     [not found] ` <m2n.s.1KWDD7-002TB9@chiark.greenend.org.uk>
2008-08-26 10:31   ` [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support Ian Jackson
2008-08-26 12:34     ` Gerd Hoffmann
2008-08-26 12:57     ` [Xen-devel] " Daniel P. Berrange
2008-08-26 13:20       ` Gerd Hoffmann
2008-08-26 13:23         ` Daniel P. Berrange
2008-08-26 13:33           ` Ian Jackson
2008-08-26 14:14             ` Daniel P. Berrange
2008-08-26 14:31               ` Gerd Hoffmann
2008-08-26 14:40                 ` Daniel P. Berrange
2008-08-26 14:49                   ` Gerd Hoffmann
2008-08-26 14:53                     ` Daniel P. Berrange
2008-08-26 19:24                       ` Gerd Hoffmann
2008-08-26 14:53                     ` Ian Jackson
2008-08-27  8:51                       ` Gerd Hoffmann
2008-08-27  9:53                         ` Ian Jackson
2008-08-27  9:56                           ` Daniel P. Berrange
2008-08-27 10:00                             ` Ian Jackson
2008-08-27 10:23                               ` Daniel P. Berrange
2008-08-27 10:37                                 ` Gerd Hoffmann
2008-08-27 10:44                                   ` Daniel P. Berrange
2008-08-27 11:01                                     ` Gerd Hoffmann
     [not found]             ` <m2n.s.1KXzR5-002R2A@chiark.greenend.org.uk>
2008-08-26 15:05               ` Ian Jackson
2008-08-26 15:09                 ` Daniel P. Berrange
2008-08-26 13:24       ` Ian Jackson
2008-08-26 13:50         ` Daniel P. Berrange
     [not found] ` <m2n.s.1KWDfC-002TCd@chiark.greenend.org.uk>
     [not found]   ` <m2n.s.1KWDGv-002TBJ@chiark.greenend.org.uk>
     [not found]     ` <m2n.s.1KWDEt-002TBA@chiark.greenend.org.uk>
2008-08-26 10:42       ` [Qemu-devel] [PATCH 13/13] xen: pv domain builder Ian Jackson
2008-08-26 10:50         ` [Xen-devel] " Samuel Thibault
2008-08-26 13:43           ` Ian Jackson
2008-08-26 21:00           ` Markus Armbruster
2008-08-26 12:55         ` Gerd Hoffmann
2008-08-26 13:14           ` Ian Jackson
2008-08-26 13:53             ` Gerd Hoffmann
2008-08-26 14:19               ` Ian Jackson
2008-08-26 20:00                 ` [Xen-devel] " Gerd Hoffmann
2008-08-27  9:48                   ` Ian Jackson
2008-08-26 13:56             ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080826174729.GB25893@shareable.org \
    --to=jamie@shareable.org \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).