From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47946 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZhL8-00053y-Ey for qemu-devel@nongnu.org; Mon, 03 Jan 2011 05:08:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZhL6-0007Uv-Un for qemu-devel@nongnu.org; Mon, 03 Jan 2011 05:08:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZhL6-0007Ur-LN for qemu-devel@nongnu.org; Mon, 03 Jan 2011 05:08:32 -0500 Message-ID: <4D21A01B.7000900@redhat.com> Date: Mon, 03 Jan 2011 12:08:27 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4D219AF5.2030204@web.de> <4D219E6D.8060902@redhat.com> <4D219F06.7040305@web.de> In-Reply-To: <4D219F06.7040305@web.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: Role of qemu_fair_mutex List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Marcelo Tosatti , qemu-devel , kvm On 01/03/2011 12:03 PM, Jan Kiszka wrote: > Am 03.01.2011 11:01, Avi Kivity wrote: > > On 01/03/2011 11:46 AM, Jan Kiszka wrote: > >> Hi, > >> > >> at least in kvm mode, the qemu_fair_mutex seems to have lost its > >> function of balancing qemu_global_mutex access between the io-thread and > >> vcpus. It's now only taken by the latter, isn't it? > >> > >> This and the fact that qemu-kvm does not use this kind of lock made me > >> wonder what its role is and if it is still relevant in practice. I'd > >> like to unify the execution models of qemu-kvm and qemu, and this lock > >> is the most obvious difference (there are surely more subtle ones as > >> well...). > >> > > > > IIRC it was used for tcg, which has a problem that kvm doesn't have: a > > tcg vcpu needs to hold qemu_mutex when it runs, which means there will > > always be contention on qemu_mutex. In the absence of fairness, the tcg > > thread could dominate qemu_mutex and starve the iothread. > > > > This doesn't happen with kvm since kvm vcpus drop qemu_mutex when running. > > > > I see. Then I guess we should do this: > > diff --git a/cpus.c b/cpus.c > index 9bf5224..0de8552 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -734,9 +734,7 @@ static sigset_t block_io_signals(void) > void qemu_mutex_lock_iothread(void) > { > if (kvm_enabled()) { > - qemu_mutex_lock(&qemu_fair_mutex); > qemu_mutex_lock(&qemu_global_mutex); > - qemu_mutex_unlock(&qemu_fair_mutex); > } else { > qemu_mutex_lock(&qemu_fair_mutex); > if (qemu_mutex_trylock(&qemu_global_mutex)) { I think so, though Anthony or Marcelo should confirm my interpretation first. -- error compiling committee.c: too many arguments to function