From: Eduardo Habkost <ehabkost@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] exec: Eliminate qemu_ram_free_from_ptr()
Date: Fri, 6 Nov 2015 19:20:04 -0200 [thread overview]
Message-ID: <1446844805-14492-2-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1446844805-14492-1-git-send-email-ehabkost@redhat.com>
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 <ehabkost@redhat.com>
---
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 a028961..851959b 100644
--- a/exec.c
+++ b/exec.c
@@ -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) {
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 3360ac5..b0d3c10 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -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);
diff --git a/memory.c b/memory.c
index c435c88..183eca5 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.1.0
next prev parent reply other threads:[~2015-11-06 21:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 21:20 [Qemu-devel] [PATCH 0/2] memory: Eliminate qemu_ram_free_from_ptr() & memory_region_destructor_ram_from_ptr() Eduardo Habkost
2015-11-06 21:20 ` Eduardo Habkost [this message]
2015-11-06 21:20 ` [Qemu-devel] [PATCH 2/2] memory: Eliminate memory_region_destructor_ram_from_ptr() Eduardo Habkost
2015-11-09 9:43 ` [Qemu-devel] [PATCH 0/2] memory: Eliminate qemu_ram_free_from_ptr() & memory_region_destructor_ram_from_ptr() Paolo Bonzini
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=1446844805-14492-2-git-send-email-ehabkost@redhat.com \
--to=ehabkost@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).