From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEikL-00025C-Lq for qemu-devel@nongnu.org; Wed, 28 Aug 2013 12:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEikF-0005Xs-57 for qemu-devel@nongnu.org; Wed, 28 Aug 2013 12:37:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEikE-0005Xe-RE for qemu-devel@nongnu.org; Wed, 28 Aug 2013 12:37:23 -0400 Message-ID: <521E2737.1030108@redhat.com> Date: Wed, 28 Aug 2013 18:37:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1377705768-21996-1-git-send-email-ncmike@ncultra.org> In-Reply-To: <1377705768-21996-1-git-send-email-ncmike@ncultra.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mike Day Cc: Paul Mckenney , Mathew Desnoyers , qemu-devel@nongnu.org, Anthony Liguori Il 28/08/2013 18:02, Mike Day ha scritto: > @@ -1102,15 +1110,15 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) > pstrcat(new_block->idstr, sizeof(new_block->idstr), name); > > /* This assumes the iothread lock is taken here too. */ > - qemu_mutex_lock_ramlist(); > - QTAILQ_FOREACH(block, &ram_list.blocks, next) { > + rcu_read_lock(); > + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > if (block != new_block && !strcmp(block->idstr, new_block->idstr)) { > fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n", > new_block->idstr); > abort(); > } > } > - qemu_mutex_unlock_ramlist(); > + rcu_read_unlock(); Forgot about this. Every time you see "This assumes the iothread lock is taken here too", you're in the write side so you do not need lock/unlock and you do not need... > /* This assumes the iothread lock is taken here too. */ > qemu_mutex_lock_ramlist(); > - QTAILQ_FOREACH(block, &ram_list.blocks, next) { > + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > if (addr == block->offset) { > - QTAILQ_REMOVE(&ram_list.blocks, block, next); > + QLIST_REMOVE_RCU(block, next); > ram_list.mru_block = NULL; > ram_list.version++; > g_free(block); qemu_mutex_lock_ramlist/qemu_mutex_unlock_ramlist either. Otherwise, the patch is pretty solid! Thanks, Paolo