From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 6/6] kvm tools: Protect IOPORT tree by rwsem Date: Thu, 26 May 2011 19:19:01 +0300 Message-ID: <1306426741.3065.33.camel@lappy> References: <1306419950-19064-1-git-send-email-levinsasha928@gmail.com> <1306419950-19064-6-git-send-email-levinsasha928@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com To: Pekka Enberg Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:33785 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754172Ab1EZQ0S (ORCPT ); Thu, 26 May 2011 12:26:18 -0400 Received: by wwa36 with SMTP id 36so968890wwa.1 for ; Thu, 26 May 2011 09:26:17 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 2011-05-26 at 19:01 +0300, Pekka Enberg wrote: > On Thu, 26 May 2011, Sasha Levin wrote: > > Makes ioport thread-safe. > > > > Signed-off-by: Sasha Levin > > --- > > tools/kvm/ioport.c | 7 +++++++ > > 1 files changed, 7 insertions(+), 0 deletions(-) > > > > diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c > > index 1f13960..db9ff0f 100644 > > --- a/tools/kvm/ioport.c > > +++ b/tools/kvm/ioport.c > > @@ -3,6 +3,7 @@ > > #include "kvm/kvm.h" > > #include "kvm/util.h" > > #include "kvm/rbtree-interval.h" > > +#include "kvm/rwsem.h" > > > > #include /* for KVM_EXIT_* */ > > #include > > @@ -22,6 +23,7 @@ struct ioport_entry { > > > > static struct rb_root ioport_tree = RB_ROOT; > > bool ioport_debug; > > +static DECLARE_RWSEM(ioport_tree_sem); > > Why do we need a new lock here? Can't we reuse the new ioport_mutex? ioport_mutex is used for allocations of ioports to devices, this lock is intended to protect the ioport tree from being read while new devices are added. -- Sasha.