From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [RFC PATCH v4 2/5] ramlist mutex Date: Tue, 16 Aug 2011 23:28:56 -0700 Message-ID: <4E4B5FA8.4020006@redhat.com> References: <8f99d56f3a48b6255cf70425bc435d8f231f5352.1313552764.git.udeshpan@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, quintela@redhat.com To: Umesh Deshpande Return-path: In-Reply-To: <8f99d56f3a48b6255cf70425bc435d8f231f5352.1313552764.git.udeshpan@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On 08/16/2011 08:56 PM, Umesh Deshpande wrote: > @@ -3001,8 +3016,10 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) > > QLIST_FOREACH(block,&ram_list.blocks, next) { > if (addr == block->offset) { > + qemu_mutex_lock_ramlist(); > QLIST_REMOVE(block, next); > QLIST_REMOVE(block, next_mru); > + qemu_mutex_unlock_ramlist(); > qemu_free(block); > return; > } > @@ -3015,8 +3032,10 @@ void qemu_ram_free(ram_addr_t addr) > > QLIST_FOREACH(block,&ram_list.blocks, next) { > if (addr == block->offset) { > + qemu_mutex_lock_ramlist(); > QLIST_REMOVE(block, next); > QLIST_REMOVE(block, next_mru); > + qemu_mutex_unlock_ramlist(); > if (block->flags& RAM_PREALLOC_MASK) { > ; > } else if (mem_path) { You must protect the whole QLIST_FOREACH. Otherwise looks good. Paolo