From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc6g-000290-0j for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:27:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEc6a-0007Gz-7w for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:27:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc6Z-0007Gv-Ug for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:27:28 -0400 Message-ID: <505AD365.6020301@redhat.com> Date: Thu, 20 Sep 2012 10:27:17 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <50597D1F.3070607@redhat.com> <50598B58.4010704@redhat.com> <50598D0D.2090608@redhat.com> <50598F0C.2040301@redhat.com> <505ACBC4.3030903@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [big lock] Discussion about the convention of device's DMA each other after breaking down biglock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liu ping fan Cc: Jan Kiszka , Marcelo Tosatti , Avi Kivity , Anthony Liguori , qemu-devel@nongnu.org Il 20/09/2012 10:09, liu ping fan ha scritto: > > > > No, MMIO dispatch has to discard the fine-grained lock before acquiring > > the big lock. > > This will cause the device state broken, and expose device under changing risk. We do it all the time with asynchronous I/O. It's just an invariant that fine-grain-locked devices have to obey. You cannot keep the same semantics you enjoyed when a single lock covered everything. > > If you allow > > > > lock(fine) > > lock(coarse) > > > > then the (presumably higher-priority) thread that is requesting the > > fine-grained lock must wait for the lower-priority thread that holds the > > coarse-grained lock. Then you get priority inversion. > > Which thread has higher-priority? Why does the thread with coarse lock > have lower-priority? Because there can be so many things happening under the coarse lock, that just _assuming_ it has lower priority is a good thing. On the other hand, if the device didn't need immediate servicing (which means higher priority), you wouldn't bother taking it out of the big QEMU lock. Paolo