From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEcjK-00039Q-NB for qemu-devel@nongnu.org; Thu, 20 Sep 2012 05:07:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEcjC-0004mf-DI for qemu-devel@nongnu.org; Thu, 20 Sep 2012 05:07:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEcjC-0004mP-58 for qemu-devel@nongnu.org; Thu, 20 Sep 2012 05:07:22 -0400 Message-ID: <505ADCC4.5010001@redhat.com> Date: Thu, 20 Sep 2012 12:07:16 +0300 From: Avi Kivity MIME-Version: 1.0 References: <50597D1F.3070607@redhat.com> <50598B58.4010704@redhat.com> <50598D0D.2090608@redhat.com> <50598F0C.2040301@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: Paolo Bonzini , Marcelo Tosatti , qemu-devel@nongnu.org, Anthony Liguori , Jan Kiszka On 09/20/2012 10:51 AM, liu ping fan wrote: > On Wed, Sep 19, 2012 at 5:23 PM, Avi Kivity wrote: >> On 09/19/2012 12:19 PM, liu ping fan wrote: >>> On Wed, Sep 19, 2012 at 5:14 PM, Paolo Bonzini wrote: >>>> Il 19/09/2012 11:11, liu ping fan ha scritto: >>>>>> > Why not? devA will drop its local lock, devX will retake the big lock >>>>>> > recursively, devB will take its local lock. In the end, we have biglock >>>>>> > -> devB. >>>>>> > >>>>> But when adopting local lock, we assume take local lock, then biglock. >>>> >>>> No, because the local lock will be dropped before taking the biglock. >>>> The order must always be coarse->fine. >>>> >>> But if we takes coarse firstly, then the mmio-dispatcher will still >>> contend for the big lock against each other. >> >> Can you detail the sequence? >> > LOCK(local lock) > ....................... > LOCK(big lock) > Access timer/block/network subsystem > UNLOCK(big lock) > ..................... > UNLOCK(local lock) This is an invalid sequence. Either the subsystem has to be fine-grain locked, or the lock order has to be reversed. Before we finish subsystem conversion, an mmio dispatcher may look like: dev_write(...) { lock(s->lock) switch (addr) { case REGA: ... case REGB: ... case REGC: unlock(s->lock) lock(big lock) lock(s->lock) qemu_mod_timer() unlock(bit lock) break; ... } unlock(s->lock) } -- error compiling committee.c: too many arguments to function