mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-06-03 18:38:20 +00:00
Move RAMBlock deallocation to reclaim_ramblock
Backports a minor portion of commit 43771539d4666cba16298fc6b0ea63867425277c from qemu
This commit is contained in:
parent
aa0ce52b97
commit
6a7974277a
24
qemu/exec.c
24
qemu/exec.c
|
@ -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);
|
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) {
|
if (block->flags & RAM_PREALLOC) {
|
||||||
;
|
;
|
||||||
#ifndef _WIN32
|
#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);
|
qemu_anon_ram_free(block->host, block->max_length);
|
||||||
}
|
}
|
||||||
g_free(block);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue