From patchwork Thu Mar 25 13:47:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 48518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E880B7C33 for ; Fri, 26 Mar 2010 00:59:17 +1100 (EST) Received: from localhost ([127.0.0.1]:45293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nunac-0002qF-EV for incoming@patchwork.ozlabs.org; Thu, 25 Mar 2010 09:59:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NunUt-0000i9-Jc for qemu-devel@nongnu.org; Thu, 25 Mar 2010 09:53:19 -0400 Received: from [140.186.70.92] (port=60789 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NunUn-0008JB-72 for qemu-devel@nongnu.org; Thu, 25 Mar 2010 09:53:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NunTY-0007yQ-Sr for qemu-devel@nongnu.org; Thu, 25 Mar 2010 09:51:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25094) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NunTY-0007xu-LN for qemu-devel@nongnu.org; Thu, 25 Mar 2010 09:51:56 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2PDpt5k028140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Mar 2010 09:51:55 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2PDpsdT030759; Thu, 25 Mar 2010 09:51:54 -0400 Received: from amt.cnet (vpn-11-138.rdu.redhat.com [10.11.11.138]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2PDprlD007570; Thu, 25 Mar 2010 09:51:53 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 745D36520C8; Thu, 25 Mar 2010 10:50:48 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o2PDol0C017603; Thu, 25 Mar 2010 10:50:47 -0300 Message-Id: <20100325134957.646980309@amt.cnet> User-Agent: quilt/0.47-1 Date: Thu, 25 Mar 2010 10:47:16 -0300 From: Marcelo Tosatti To: Anthony Liguori References: <20100325134715.354365213@amt.cnet> Content-Disposition: inline; filename=qemu-io-worker X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: amit.shah@redhat.com, Marcelo Tosatti , qemu-devel@nongnu.org Subject: [Qemu-devel] [patch 1/2] Pass QEMUIOWorker to qemu_notify_event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This can be used later to introduce generic iothread workers. Signed-off-by: Marcelo Tosatti Index: qemu-ioworker/async.c =================================================================== --- qemu-ioworker.orig/async.c +++ qemu-ioworker/async.c @@ -180,7 +180,7 @@ void qemu_bh_schedule(QEMUBH *bh) bh->scheduled = 1; bh->idle = 0; /* stop the currently executing CPU to execute the BH ASAP */ - qemu_notify_event(); + qemu_notify_event(main_io_worker); } void qemu_bh_cancel(QEMUBH *bh) Index: qemu-ioworker/hw/mac_dbdma.c =================================================================== --- qemu-ioworker.orig/hw/mac_dbdma.c +++ qemu-ioworker/hw/mac_dbdma.c @@ -655,7 +655,7 @@ void DBDMA_register_channel(void *dbdma, void DBDMA_schedule(void) { - qemu_notify_event(); + qemu_notify_event(main_io_worker); } static void Index: qemu-ioworker/hw/virtio-net.c =================================================================== --- qemu-ioworker.orig/hw/virtio-net.c +++ qemu-ioworker/hw/virtio-net.c @@ -360,7 +360,7 @@ static void virtio_net_handle_rx(VirtIOD /* We now have RX buffers, signal to the IO thread to break out of the * select to re-poll the tap file descriptor */ - qemu_notify_event(); + qemu_notify_event(main_io_worker); } static int virtio_net_can_receive(VLANClientState *nc) Index: qemu-ioworker/qemu-common.h =================================================================== --- qemu-ioworker.orig/qemu-common.h +++ qemu-ioworker/qemu-common.h @@ -235,11 +235,17 @@ typedef uint64_t pcibus_t; void cpu_save(QEMUFile *f, void *opaque); int cpu_load(QEMUFile *f, void *opaque, int version_id); +typedef struct QEMUIOWorker { + void *opaque; +} QEMUIOWorker; + /* Force QEMU to stop what it's doing and service IO */ void qemu_service_io(void); /* Force QEMU to process pending events */ -void qemu_notify_event(void); +void qemu_notify_event(QEMUIOWorker *worker); + +extern QEMUIOWorker *main_io_worker; /* Unblock cpu */ void qemu_cpu_kick(void *env); Index: qemu-ioworker/vl.c =================================================================== --- qemu-ioworker.orig/vl.c +++ qemu-ioworker/vl.c @@ -258,6 +258,9 @@ uint8_t qemu_uuid[16]; static QEMUBootSetHandler *boot_set_handler; static void *boot_set_opaque; +QEMUIOWorker iothread_worker; +QEMUIOWorker *main_io_worker = &iothread_worker; + #ifdef SIGRTMIN #define SIG_IPI (SIGRTMIN+4) #else @@ -1884,7 +1887,7 @@ static int ram_load(QEMUFile *f, void *o void qemu_service_io(void) { - qemu_notify_event(); + qemu_notify_event(main_io_worker); } /***********************************************************/ @@ -2137,19 +2140,19 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } - qemu_notify_event(); + qemu_notify_event(main_io_worker); } void qemu_system_shutdown_request(void) { shutdown_requested = 1; - qemu_notify_event(); + qemu_notify_event(main_io_worker); } void qemu_system_powerdown_request(void) { powerdown_requested = 1; - qemu_notify_event(); + qemu_notify_event(main_io_worker); } static int cpu_can_run(CPUState *env) @@ -2313,7 +2316,7 @@ void qemu_cpu_kick(void *env) return; } -void qemu_notify_event(void) +void qemu_notify_event(QEMUIOWorker *worker) { CPUState *env = cpu_single_env; @@ -2701,7 +2704,7 @@ void qemu_init_vcpu(void *_env) tcg_init_vcpu(env); } -void qemu_notify_event(void) +void qemu_notify_event(QEMUIOWorker *worker) { qemu_event_increment(); } @@ -2709,7 +2712,7 @@ void qemu_notify_event(void) static void qemu_system_vmstop_request(int reason) { vmstop_requested = reason; - qemu_notify_event(); + qemu_notify_event(main_io_worker); } void vm_stop(int reason) Index: qemu-ioworker/qemu-timer.c =================================================================== --- qemu-ioworker.orig/qemu-timer.c +++ qemu-ioworker/qemu-timer.c @@ -547,7 +547,7 @@ void qemu_mod_timer(QEMUTimer *ts, int64 } /* Interrupt execution to force deadline recalculation. */ if (use_icount) - qemu_notify_event(); + qemu_notify_event(main_io_worker); } } @@ -775,7 +775,7 @@ static void host_alarm_handler(int host_ t->expired = alarm_has_dynticks(t); t->pending = 1; - qemu_notify_event(); + qemu_notify_event(main_io_worker); } }