From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9cdc-00008f-8X for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:46:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9cdZ-0006hK-21 for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:46:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9cdY-0006hE-TB for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:46:45 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 80A5119CF99 for ; Thu, 17 Dec 2015 17:46:44 +0000 (UTC) From: Paolo Bonzini Date: Thu, 17 Dec 2015 18:45:57 +0100 Message-Id: <1450374401-31352-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1450374401-31352-1-git-send-email-pbonzini@redhat.com> References: <1450374401-31352-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 01/45] exec: Eliminate qemu_ram_free_from_ptr() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost From: Eduardo Habkost Replace qemu_ram_free_from_ptr() with qemu_ram_free(). The only difference between qemu_ram_free_from_ptr() and qemu_ram_free() is that g_free_rcu() is used instead of call_rcu(reclaim_ramblock). We can safely replace it because: * RAM blocks allocated by qemu_ram_alloc_from_ptr() always have RAM_PREALLOC set; * reclaim_ramblock(block) will do nothing except g_free(block) if RAM_PREALLOC is set at block->flags. Signed-off-by: Eduardo Habkost Message-Id: <1446844805-14492-2-git-send-email-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini --- exec.c | 19 ------------------- include/exec/ram_addr.h | 1 - memory.c | 2 +- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/exec.c b/exec.c index 0bf0a6e..d12cd42 100644 --- a/exec.c +++ b/exec.c @@ -1676,25 +1676,6 @@ ram_addr_t qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t maxsz, return qemu_ram_alloc_internal(size, maxsz, resized, NULL, true, mr, errp); } -void qemu_ram_free_from_ptr(ram_addr_t addr) -{ - RAMBlock *block; - - qemu_mutex_lock_ramlist(); - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { - if (addr == block->offset) { - QLIST_REMOVE_RCU(block, next); - ram_list.mru_block = NULL; - /* Write list before version */ - smp_wmb(); - ram_list.version++; - g_free_rcu(block, rcu); - break; - } - } - qemu_mutex_unlock_ramlist(); -} - static void reclaim_ramblock(RAMBlock *block) { if (block->flags & RAM_PREALLOC) { diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 7115154..d1d9963 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -75,7 +75,6 @@ int qemu_get_ram_fd(ram_addr_t addr); void *qemu_get_ram_block_host_ptr(ram_addr_t addr); void *qemu_get_ram_ptr(ram_addr_t addr); void qemu_ram_free(ram_addr_t addr); -void qemu_ram_free_from_ptr(ram_addr_t addr); int qemu_ram_resize(ram_addr_t base, ram_addr_t newsize, Error **errp); diff --git a/memory.c b/memory.c index e193658..cf5b05f 100644 --- a/memory.c +++ b/memory.c @@ -861,7 +861,7 @@ static void memory_region_destructor_ram(MemoryRegion *mr) static void memory_region_destructor_ram_from_ptr(MemoryRegion *mr) { - qemu_ram_free_from_ptr(mr->ram_addr); + qemu_ram_free(mr->ram_addr); } static void memory_region_destructor_rom_device(MemoryRegion *mr) -- 2.5.0