Move RAMBlock deallocation to reclaim_ramblock

Backports a minor portion of commit 43771539d4666cba16298fc6b0ea63867425277c from qemu
This commit is contained in:
Lioncash 2018-02-18 19:36:18 -05:00
parent aa0ce52b97
commit 6a7974277a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -1205,15 +1205,8 @@ 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(struct uc_struct *uc, ram_addr_t addr)
static void reclaim_ramblock(RAMBlock *block)
{
RAMBlock *block;
QLIST_FOREACH(block, &uc->ram_list.blocks, next) {
if (addr == block->offset) {
QLIST_REMOVE(block, next);
uc->ram_list.mru_block = NULL;
uc->ram_list.version++;
if (block->flags & RAM_PREALLOC) {
;
#ifndef _WIN32
@ -1225,6 +1218,21 @@ void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
qemu_anon_ram_free(block->host, block->max_length);
}
g_free(block);
}
void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
{
RAMBlock *block;
QLIST_FOREACH(block, &uc->ram_list.blocks, next) {
if (addr == block->offset) {
QLIST_REMOVE(block, next);
uc->ram_list.mru_block = NULL;
/* Write list before version */
smp_wmb();
uc->ram_list.version++;
// Unicorn: call directly instead of via call_rcu
reclaim_ramblock(block);
break;
}
}