mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-17 21:26:13 -07:00
memory: replace cpu_physical_memory_reset_dirty() with test-and-clear
The cpu_physical_memory_reset_dirty() function is sometimes used together with cpu_physical_memory_get_dirty(). This is not atomic since two separate accesses to the dirty memory bitmap are made. Turn cpu_physical_memory_reset_dirty() and cpu_physical_memory_clear_dirty_range_type() into the atomic cpu_physical_memory_test_and_clear_dirty(). Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <1417519399-3166-6-git-send-email-stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
20015f72bd
commit
03eebc9e32
4 changed files with 33 additions and 38 deletions
11
memory.c
11
memory.c
|
|
@ -1468,13 +1468,9 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr,
|
|||
bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr,
|
||||
hwaddr size, unsigned client)
|
||||
{
|
||||
bool ret;
|
||||
assert(mr->terminates);
|
||||
ret = cpu_physical_memory_get_dirty(mr->ram_addr + addr, size, client);
|
||||
if (ret) {
|
||||
cpu_physical_memory_reset_dirty(mr->ram_addr + addr, size, client);
|
||||
}
|
||||
return ret;
|
||||
return cpu_physical_memory_test_and_clear_dirty(mr->ram_addr + addr,
|
||||
size, client);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1518,7 +1514,8 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,
|
|||
hwaddr size, unsigned client)
|
||||
{
|
||||
assert(mr->terminates);
|
||||
cpu_physical_memory_reset_dirty(mr->ram_addr + addr, size, client);
|
||||
cpu_physical_memory_test_and_clear_dirty(mr->ram_addr + addr, size,
|
||||
client);
|
||||
}
|
||||
|
||||
int memory_region_get_fd(MemoryRegion *mr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue