On Wed, Sep 4, 2013 at 3:58 PM, Paolo Bonzini <pbonz...@redhat.com> 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