memory: Eliminate qemu_ram_free_from_ptr() & memory_region_destructor_ram_from_ptr()
cover memory: Eliminate qemu_ram_free_from_ptr() & memory_region_destructor_ram_from_ptr()
This series eliminates two functions that are not needed anymore:qemu_ram_free_from_ptr(), and memory_region_destructor_ram_from_ptr().
Eduardo Habkost (2):
exec: Eliminate qemu_ram_free_from_ptr()
memory: Eliminate memory_region_destructor_ram_from_ptr()
exec.c | 19 ------------------- include/exec/ram_addr.h | 1 - memory.c | 7 +------ 3 files changed, 1 insertion(+), 26 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/2 exec: Eliminate qemu_ram_free_from_ptr()
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.
--- exec.c | 19 ------------------- include/exec/ram_addr.h | 1 - memory.c | 2 +- 3 files changed, 1 insertion(+), 21 deletions(-)
exec.c +0 -19
@@ -1672,25 +1672,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 ) {
include/exec/ram_addr.h +0 -1
@@ -77,7 +77,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);
memory.c +1 -1
@@ -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)
Signature · 1 line
2.1.0
PATCH 2/2 memory: Eliminate memory_region_destructor_ram_from_ptr()
In reply to Eduardo HabkostThe function is equivalent to memory_region_destructor_ram(), so it's not needed anymore.
--- memory.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
memory.c +1 -6
@@ -859,11 +859,6 @@ static void memory_region_destructor_ram(MemoryRegion *mr)qemu_ram_free (mr->ram_addr); } -static void memory_region_destructor_ram_from_ptr (MemoryRegion *mr) -{ -qemu_ram_free (mr->ram_addr); -} -static void memory_region_destructor_rom_device (MemoryRegion *mr) {qemu_ram_free (mr->ram_addr &TARGET_PAGE_MASK );
@@ -1246,7 +1241,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,memory_region_init (mr, owner, name, size); mr->ram = true; mr->terminates = true; - mr->destructor = memory_region_destructor_ram_from_ptr; + mr->destructor = memory_region_destructor_ram; mr->dirty_log_mask =tcg_enabled () ? (1 <<DIRTY_MEMORY_CODE ) :0 ;/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */
Signature · 1 line
2.1.0
Paolo Bonzini
AppliedQuoted 12 lines · Eduardo Habkost
This series eliminates two functions that are not needed anymore:
qemu_ram_free_from_ptr(), andmemory_region_destructor_ram_from_ptr().Eduardo Habkost (2):
exec: Eliminateqemu_ram_free_from_ptr()
memory: Eliminatememory_region_destructor_ram_from_ptr()exec.c | 19 ------------------- include/exec/ram_addr.h | 1 - memory.c | 7 +------ 3 files changed, 1 insertion(+), 26 deletions(-)
Queued for 2.6, thanks.
Paolo