qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Frediano Ziglio <freddy77@gmail.com>
Cc: kwolf@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2
Date: Mon, 19 Sep 2011 17:02:49 +0200	[thread overview]
Message-ID: <4E775999.7060008@redhat.com> (raw)
In-Reply-To: <1316443033-6489-1-git-send-email-freddy77@gmail.com>

On 09/19/2011 04:37 PM, Frediano Ziglio wrote:
> Now that iothread is always compiled sending a signal seems only an
> additional step. This patch also avoid writing to two pipe (one from signal
> and one in qemu_service_io).
>
> Work with kvm enabled or disabled. strace output is more readable (less syscalls).
>
> Signed-off-by: Frediano Ziglio<freddy77@gmail.com>
> ---
>   cpus.c             |    5 -----
>   posix-aio-compat.c |   29 +++++++++--------------------
>   2 files changed, 9 insertions(+), 25 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 54c188c..d0cfe91 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -380,11 +380,6 @@ static int qemu_signal_init(void)
>       int sigfd;
>       sigset_t set;
>
> -    /* SIGUSR2 used by posix-aio-compat.c */
> -    sigemptyset(&set);
> -    sigaddset(&set, SIGUSR2);
> -    pthread_sigmask(SIG_UNBLOCK,&set, NULL);
> -
>       /*
>        * SIG_IPI must be blocked in the main thread and must not be caught
>        * by sigwait() in the signal thread. Otherwise, the cpu thread will
> diff --git a/posix-aio-compat.c b/posix-aio-compat.c
> index 3193dbf..185d5b2 100644
> --- a/posix-aio-compat.c
> +++ b/posix-aio-compat.c
> @@ -42,7 +42,6 @@ struct qemu_paiocb {
>       int aio_niov;
>       size_t aio_nbytes;
>   #define aio_ioctl_cmd   aio_nbytes /* for QEMU_AIO_IOCTL */
> -    int ev_signo;
>       off_t aio_offset;
>
>       QTAILQ_ENTRY(qemu_paiocb) node;
> @@ -309,6 +308,8 @@ static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
>       return nbytes;
>   }
>
> +static void posix_aio_notify_event(void);
> +
>   static void *aio_thread(void *unused)
>   {
>       pid_t pid;
> @@ -381,7 +382,7 @@ static void *aio_thread(void *unused)
>           aiocb->ret = ret;
>           mutex_unlock(&lock);
>
> -        if (kill(pid, aiocb->ev_signo)) die("kill failed");
> +        posix_aio_notify_event();
>       }
>
>       cur_threads--;
> @@ -548,18 +549,14 @@ static int posix_aio_flush(void *opaque)
>
>   static PosixAioState *posix_aio_state;
>
> -static void aio_signal_handler(int signum)
> +static void posix_aio_notify_event(void)
>   {
> -    if (posix_aio_state) {
> -        char byte = 0;
> -        ssize_t ret;
> -
> -        ret = write(posix_aio_state->wfd,&byte, sizeof(byte));
> -        if (ret<  0&&  errno != EAGAIN)
> -            die("write()");
> -    }
> +    char byte = 0;
> +    ssize_t ret;
>
> -    qemu_service_io();
> +    ret = write(posix_aio_state->wfd,&byte, sizeof(byte));
> +    if (ret<  0&&  errno != EAGAIN)
> +        die("write()");
>   }
>
>   static void paio_remove(struct qemu_paiocb *acb)
> @@ -623,7 +620,6 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
>           return NULL;
>       acb->aio_type = type;
>       acb->aio_fildes = fd;
> -    acb->ev_signo = SIGUSR2;
>
>       if (qiov) {
>           acb->aio_iov = qiov->iov;
> @@ -651,7 +647,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
>           return NULL;
>       acb->aio_type = QEMU_AIO_IOCTL;
>       acb->aio_fildes = fd;
> -    acb->ev_signo = SIGUSR2;
>       acb->aio_offset = 0;
>       acb->aio_ioctl_buf = buf;
>       acb->aio_ioctl_cmd = req;
> @@ -665,7 +660,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
>
>   int paio_init(void)
>   {
> -    struct sigaction act;
>       PosixAioState *s;
>       int fds[2];
>       int ret;
> @@ -675,11 +669,6 @@ int paio_init(void)
>
>       s = g_malloc(sizeof(PosixAioState));
>
> -    sigfillset(&act.sa_mask);
> -    act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
> -    act.sa_handler = aio_signal_handler;
> -    sigaction(SIGUSR2,&act, NULL);
> -
>       s->first_aio = NULL;
>       if (qemu_pipe(fds) == -1) {
>           fprintf(stderr, "failed to create pipe\n");

I think it is possible to go a step further, turn 
posix_aio_process_queue into a bottom half and get rid of the pipe 
altogether.  This in turn would remove the only real user of 
io_process_queue in qemu_aio_set_fd_handler.  However, this is already a 
nice improvement.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2011-09-19 15:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 14:37 [Qemu-devel] [PATCH v2] block: avoid SIGUSR2 Frediano Ziglio
2011-09-19 15:02 ` Paolo Bonzini [this message]
2011-09-19 15:11   ` Kevin Wolf
2011-09-19 15:25     ` Paolo Bonzini
2011-09-19 15:15 ` Kevin Wolf
2011-10-27 13:26 ` Kevin Wolf
2011-10-27 13:57   ` Stefan Hajnoczi
2011-10-27 14:15     ` Kevin Wolf
2011-10-27 14:32       ` Kevin Wolf
2011-10-28 11:33         ` Kevin Wolf
2011-10-28 11:35           ` Kevin Wolf
2011-10-28 11:50           ` Paolo Bonzini
2011-10-28 12:29             ` Kevin Wolf
2011-10-28 12:31               ` Stefan Hajnoczi
2011-10-28 15:58                 ` Paolo Bonzini
2011-10-31  2:10                 ` Zhi Yong Wu
2011-10-28 12:20           ` Cleber Rosa

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=4E775999.7060008@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=freddy77@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).