From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHK0U-0002ET-VP for qemu-devel@nongnu.org; Wed, 04 Sep 2013 16:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHK0O-0006tc-ON for qemu-devel@nongnu.org; Wed, 04 Sep 2013 16:48:54 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:57863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHK0O-0006tS-HY for qemu-devel@nongnu.org; Wed, 04 Sep 2013 16:48:48 -0400 Received: by mail-wi0-f174.google.com with SMTP id hj3so4056085wib.13 for ; Wed, 04 Sep 2013 13:48:47 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <52279102.2090208@redhat.com> References: <1378323694-12042-1-git-send-email-ncmike@ncultra.org> <52279102.2090208@redhat.com> Date: Wed, 4 Sep 2013 16:48:47 -0400 Message-ID: From: Mike Day Content-Type: multipart/alternative; boundary=001a11c23ec693cde404e594ee75 Subject: Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V4 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Paul Mckenney , Mathew Desnoyers , qemu-devel@nongnu.org, Anthony Liguori --001a11c23ec693cde404e594ee75 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 4, 2013 at 3:58 PM, Paolo Bonzini wrote: > > > @@ -1323,23 +1325,21 @@ static RAMBlock *qemu_get_ram_block(ram_addr_t addr) > > { > > RAMBlock *block; > > > > - /* The list is protected by the iothread lock here. */ > > + /* This assumes the iothread lock is taken here too. */ > > + > > block = ram_list.mru_block; > > if (block && addr - block->offset < block->length) { > > - goto found; > > + return block; > > } > > - QTAILQ_FOREACH(block, &ram_list.blocks, next) { > > + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > > if (addr - block->offset < block->length) { > > - goto found; > > + atomic_rcu_set(&ram_list.mru_block, block); > > I think this is not needed, block was already published into the block > list. What is important is to order mru_block == NULL so that it > happens before the node is removed. Which we don't do, but we can fix > later. I am thinking of writing some macros and possibly reorganizing the ram globals into a struct so that we can update it by exchanging pointers atomically. It seems to disjoint right and error-prone now that we are making it rcu-enabled. thanks! Mike --001a11c23ec693cde404e594ee75 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Wed, Sep 4, 2013 at 3:58 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
&g= t;
> > @@ -1323,23 +1325,21 @@ static RAMBlock *qemu_get_ram_block= (ram_addr_t addr)
> > =A0{
> > =A0 =A0 =A0RAMBlock *block;
> >
>= ; > - =A0 =A0/* The list is protected by the iothread lock here. =A0*/> > + =A0 =A0/* This assumes the iothread lock is taken here too. *= /
> > +
> > =A0 =A0 =A0block =3D ram_list.mru_block;
> > =A0 =A0 =A0= if (block && addr - block->offset < block->length) {
&g= t; > - =A0 =A0 =A0 =A0goto found;
> > + =A0 =A0 =A0 =A0return b= lock;
> > =A0 =A0 =A0}
> > - =A0 =A0QTAILQ_FOREACH(block, &ram_list.blocks, next) {
&= gt; > + =A0 =A0QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {> > =A0 =A0 =A0 =A0 =A0if (addr - block->offset < block->le= ngth) {
> > - =A0 =A0 =A0 =A0 =A0 =A0goto found;
> > + =A0 =A0 =A0 =A0 =A0 =A0atomic_rcu_set(&ram_list.mru_block, = block);
>
> I think this is not needed, block was already publi= shed into the block
> list. =A0What is important is to order mru_bloc= k =3D=3D NULL so that it
> happens before the node is removed. =A0Which we don't do, but we c= an fix
> later.

I am thinking of writing some macros and poss= ibly reorganizing the ram globals into a struct so that we can update it by= exchanging pointers atomically. It seems to disjoint right and error-prone= now that we are making it rcu-enabled.

thanks!

Mike
--001a11c23ec693cde404e594ee75--