From patchwork Mon Sep 19 14:37:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 115354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5367DB6FA0 for ; Tue, 20 Sep 2011 00:36:59 +1000 (EST) Received: from localhost ([::1]:53305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5exs-0007bC-GT for incoming@patchwork.ozlabs.org; Mon, 19 Sep 2011 10:36:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5exg-0007JH-VY for qemu-devel@nongnu.org; Mon, 19 Sep 2011 10:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5exb-0001aL-G2 for qemu-devel@nongnu.org; Mon, 19 Sep 2011 10:36:44 -0400 Received: from mail-gw0-f53.google.com ([74.125.83.53]:54312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5exb-0001Zy-Ae for qemu-devel@nongnu.org; Mon, 19 Sep 2011 10:36:39 -0400 Received: by gwj20 with SMTP id 20so5568983gwj.12 for ; Mon, 19 Sep 2011 07:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=ZyxxW0IcqZBK68dLOrkB7WSO4SotEpqY944Q3waBaJA=; b=iZ/BZzbDS3it3gcuamGasX/kbwTVYV6/kab6tMrPsSE3a5oua0yTV30j605vNDft9h Xi3CCczhT2/mkDGozHaJYwGzLmPSwh2stpJAfkwGyx0+dXF8nxj9t/+4vCfmR8AcCF/m XEjFN+wmoqZZVrNifqV1Qlz22M7kgW+f6wfRs= Received: by 10.42.163.71 with SMTP id b7mr4558632icy.167.1316442998599; Mon, 19 Sep 2011 07:36:38 -0700 (PDT) Received: from obol602.omnitel.it (tor-exit-router36-readme.formlessnetworking.net. [199.48.147.36]) by mx.google.com with ESMTPS id bk20sm26038167ibb.2.2011.09.19.07.36.33 (version=SSLv3 cipher=OTHER); Mon, 19 Sep 2011 07:36:37 -0700 (PDT) From: Frediano Ziglio To: aliguori@us.ibm.com, kwolf@redhat.com Date: Mon, 19 Sep 2011 16:37:13 +0200 Message-Id: <1316443033-6489-1-git-send-email-freddy77@gmail.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.53 Cc: qemu-devel@nongnu.org, Frediano Ziglio Subject: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Paolo Bonzini --- 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");