From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [RFC v3 1/8] memory: get rid of memory_region_destructor_ram_from_ptr()
Date: Wed, 8 Jul 2015 11:46:41 +0200 [thread overview]
Message-ID: <1436348808-223033-2-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1436348808-223033-1-git-send-email-imammedo@redhat.com>
memory_region_destructor_ram() -> qemu_ram_free()
calls reclaim_ramblock() which does:
if (!(block->flags & RAM_PREALLOC))
free_host_memory()
g_free(block)
while
memory_region_destructor_ram_from_ptr() -> qemu_ram_free_from_ptr()
calls g_free_rcu(block, rcu) results -> g_free(block)
and for memory_region_init_ram_ptr() we set RAM_PREALLOC
so qemu_ram_free() degrades to just g_free(block) so we could
just use qemu_ram_free() instead of qemu_ram_free_from_ptr().
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Conflicts:
memory.c
---
exec.c | 19 -------------------
include/exec/ram_addr.h | 1 -
memory.c | 7 +------
3 files changed, 1 insertion(+), 26 deletions(-)
diff --git a/exec.c b/exec.c
index 251dc79..eb5ece7 100644
--- a/exec.c
+++ b/exec.c
@@ -1571,25 +1571,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 c113f21..9c10462 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -37,7 +37,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 5a0cc66..ec07ae8 100644
--- a/memory.c
+++ b/memory.c
@@ -864,11 +864,6 @@ static void memory_region_destructor_alias(MemoryRegion *mr)
memory_region_unref(mr->alias);
}
-static void memory_region_destructor_ram_from_ptr(MemoryRegion *mr)
-{
- qemu_ram_free_from_ptr(mr->ram_addr);
-}
-
static void memory_region_destructor_rom_device(MemoryRegion *mr)
{
qemu_ram_free(mr->ram_addr & TARGET_PAGE_MASK);
@@ -1251,7 +1246,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. */
--
1.8.3.1
next prev parent reply other threads:[~2015-07-08 9:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 9:46 [Qemu-devel] [RFC v3 0/8] Fix QEMU crash during memory hotplug with vhost=on Igor Mammedov
2015-07-08 9:46 ` Igor Mammedov [this message]
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 2/8] memory: introduce MemoryRegion container with reserved HVA range Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 3/8] pc: reserve hotpluggable memory range with memory_region_init_hva_range() Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 4/8] pc: fix QEMU crashing when more than ~50 memory hotplugged Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 5/8] exec: make sure that RAMBlock descriptor won't be leaked Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 6/8] exec: add qemu_ram_unmap_hva() API for unmapping memory from HVA area Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 7/8] memory: extend memory_region_add_subregion() to support error reporting Igor Mammedov
2015-07-08 11:03 ` Michael S. Tsirkin
2015-07-08 11:09 ` Peter Maydell
2015-07-08 14:58 ` Igor Mammedov
2015-07-08 17:30 ` Michael S. Tsirkin
2015-07-08 18:41 ` Igor Mammedov
2015-07-09 6:58 ` Michael S. Tsirkin
2015-07-08 17:42 ` Paolo Bonzini
2015-07-08 18:58 ` Igor Mammedov
2015-07-08 9:46 ` [Qemu-devel] [RFC v3 8/8] memory: add support for deleting HVA mapped MemoryRegion Igor Mammedov
2015-07-08 9:58 ` Michael S. Tsirkin
2015-07-08 14:43 ` Igor Mammedov
2015-07-08 14:50 ` Michael S. Tsirkin
2015-07-08 10:01 ` [Qemu-devel] [RFC v3 0/8] Fix QEMU crash during memory hotplug with vhost=on Michael S. Tsirkin
2015-07-08 11:41 ` Igor Mammedov
2015-07-08 11:45 ` Michael S. Tsirkin
2015-07-08 15:46 ` Igor Mammedov
2015-07-09 17:04 ` Andrey Korolyov
2015-07-15 15:18 ` Igor Mammedov
2015-07-15 15:26 ` Andrey Korolyov
2015-07-15 16:08 ` Michael S. Tsirkin
2015-07-15 16:46 ` Andrey Korolyov
2015-07-16 20:35 ` Andrey Korolyov
2015-07-17 20:45 ` Andrey Korolyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436348808-223033-2-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).