[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 2/2] ramlist: Resize dirty bitmap blocks after remove rambloc
From: |
Keqian Zhu |
Subject: |
[RFC PATCH 2/2] ramlist: Resize dirty bitmap blocks after remove ramblock |
Date: |
Fri, 20 Nov 2020 16:51:57 +0800 |
Use the new "dirty_bitmap_resize" interface to reduce dirty bitmap
blocks after we remove a ramblock from ramlist.
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
softmmu/physmem.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index f6ff78378e..2a17e0a89a 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -2131,6 +2131,8 @@ static void reclaim_ramblock(RAMBlock *block)
void qemu_ram_free(RAMBlock *block)
{
+ ram_addr_t old_ram_size, new_ram_size;
+
if (!block) {
return;
}
@@ -2140,12 +2142,18 @@ void qemu_ram_free(RAMBlock *block)
}
qemu_mutex_lock_ramlist();
+
+ old_ram_size = last_ram_page();
QLIST_REMOVE_RCU(block, next);
+ new_ram_size = last_ram_page();
+ dirty_bitmap_resize(old_ram_size, new_ram_size);
+
ram_list.mru_block = NULL;
/* Write list before version */
smp_wmb();
ram_list.version++;
call_rcu(block, reclaim_ramblock, rcu);
+
qemu_mutex_unlock_ramlist();
}
--
2.23.0