From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58239 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pb5T5-0006sw-Q6 for qemu-devel@nongnu.org; Fri, 07 Jan 2011 01:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pb5T4-0001tV-KR for qemu-devel@nongnu.org; Fri, 07 Jan 2011 01:06:31 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:44509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pb5T3-0001tI-Tg for qemu-devel@nongnu.org; Fri, 07 Jan 2011 01:06:30 -0500 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp04.in.ibm.com (8.14.4/8.13.1) with ESMTP id p0766PJ2004267 for ; Fri, 7 Jan 2011 11:36:25 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0766Pd43489940 for ; Fri, 7 Jan 2011 11:36:25 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0766OOx022641 for ; Fri, 7 Jan 2011 17:06:25 +1100 Date: Fri, 7 Jan 2011 11:36:23 +0530 From: Arun R Bharadwaj Message-ID: <20110107060623.GB7696@linux.vnet.ibm.com> References: <20110104052627.15887.43436.stgit@localhost6.localdomain6> <20110104052727.15887.7517.stgit@localhost6.localdomain6> <20110105195438.GC9821@stefanha-thinkpad.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20110105195438.GC9821@stefanha-thinkpad.localdomain> Subject: [Qemu-devel] Re: [PATCH 04/13] Add ThreadletQueue. Reply-To: arun@linux.vnet.ibm.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com * Stefan Hajnoczi [2011-01-05 19:54:38]: > On Tue, Jan 04, 2011 at 10:57:27AM +0530, Arun R Bharadwaj wrote: > > @@ -66,15 +81,10 @@ typedef struct PosixAioState { > > struct qemu_paiocb *first_aio; > > } PosixAioState; > > > > - > > -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; > > -static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; > > -static pthread_t thread_id; > > +/* Default ThreadletQueue */ > > +static ThreadletQueue globalqueue; > > +static int globalqueue_init; > > static pthread_attr_t attr; > > > @@ -388,22 +375,24 @@ static void aio_thread(ThreadletWork *work) > > return; > > } > > > > -static void spawn_thread(void) > > +static void spawn_threadlet(ThreadletQueue *queue) > > { > > + pthread_t thread_id; > > sigset_t set, oldset; > > > > - cur_threads++; > > - idle_threads++; > > + queue->cur_threads++; > > + queue->idle_threads++; > > > > /* block all signals */ > > if (sigfillset(&set)) die("sigfillset"); > > if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask"); > > > > - thread_create(&thread_id, &attr, threadlet_worker, NULL); > > + thread_create(&thread_id, &attr, threadlet_worker, queue); > > > > if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore"); > > } > > > > + > > static void qemu_paio_submit(struct qemu_paiocb *aiocb) > > { > > qemu_mutex_lock(&aiocb_mutex); > > > @@ -682,16 +685,6 @@ int paio_init(void) > > qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, > > posix_aio_process_queue, s); > > > > - ret = pthread_attr_init(&attr); > > - if (ret) > > - die2(ret, "pthread_attr_init"); > > - > > - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); > > - if (ret) > > - die2(ret, "pthread_attr_setdetachstate"); > > attr is no longer initialized but still used? > This initialization is still needed. Thanks for pointing this out. This should be removed in patch 8/13 instead. -arun > Stefan