From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Implement an fd pool to get real AIO with posix-aio Date: Wed, 24 Sep 2008 12:02:23 +0300 Message-ID: <48DA021F.2050504@redhat.com> References: <1222202051-26701-1-git-send-email-aliguori@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, Ryan Harper , kvm To: Anthony Liguori Return-path: Received: from mx2.redhat.com ([66.187.237.31]:55386 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754158AbYIXJFk (ORCPT ); Wed, 24 Sep 2008 05:05:40 -0400 In-Reply-To: <1222202051-26701-1-git-send-email-aliguori@us.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: Anthony Liguori wrote: > This patch implements a simple fd pool to allow many AIO requests with > posix-aio. The result is significantly improved performance (identical to that > reported for linux-aio) for both cache=on and cache=off. > > The fundamental problem with posix-aio is that it limits itself to one thread > per-file descriptor. I don't know why this is, but this patch provides a simple > mechanism to work around this (duplicating the file descriptor). > > This isn't a great solution, but it seems like a reasonable intermediate step > between posix-aio and a custom thread-pool to replace it. > > > +static int raw_fd_pool_get(BDRVRawState *s) > +{ > + int i; > + > + for (i = 0; i < RAW_FD_POOL_SIZE; i++) { > + /* already in use */ > + if (s->fd_pool[i] != -1) > + continue; > + > + /* try to dup file descriptor */ > + s->fd_pool[i] = dup(s->fd); > + if (s->fd_pool[i] != -1) > + return s->fd_pool[i]; > + } > + > + /* we couldn't dup the file descriptor so just use the main one */ > + return s->fd; > +} > + > dup()ing the fd on each request is unnecessary work; would be better to cache the duped fd. Of course, if this is just a stepping stone, it doesn't matter very much. -- error compiling committee.c: too many arguments to function