[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/19] memory: Fix incorrect calls of log_global_start/stop
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 07/19] memory: Fix incorrect calls of log_global_start/stop |
Date: |
Tue, 18 Jan 2022 13:02:17 +0100 |
From: Peter Xu <peterx@redhat.com>
We should only call the log_global_start/stop when the global dirty track
bitmask changes from zero<->non-zero.
No real issue reported for this yet probably because no immediate user to
enable both dirty rate measurement and migration at the same time. However
it'll be good to be prepared for it.
Fixes: 63b41db4bc ("memory: make global_dirty_tracking a bitmask")
Cc: qemu-stable@nongnu.org
Cc: Hyman Huang <huangy81@chinatelecom.cn>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20211130080028.6474-1-peterx@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/memory.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/softmmu/memory.c b/softmmu/memory.c
index e37a4b8ae39..678dc62f069 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2794,6 +2794,8 @@ static VMChangeStateEntry *vmstate_change;
void memory_global_dirty_log_start(unsigned int flags)
{
+ unsigned int old_flags = global_dirty_tracking;
+
if (vmstate_change) {
qemu_del_vm_change_state_handler(vmstate_change);
vmstate_change = NULL;
@@ -2802,15 +2804,14 @@ void memory_global_dirty_log_start(unsigned int flags)
assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
assert(!(global_dirty_tracking & flags));
global_dirty_tracking |= flags;
-
trace_global_dirty_changed(global_dirty_tracking);
- MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
-
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
- memory_region_transaction_begin();
- memory_region_update_pending = true;
- memory_region_transaction_commit();
+ if (!old_flags) {
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
+ memory_region_transaction_begin();
+ memory_region_update_pending = true;
+ memory_region_transaction_commit();
+ }
}
static void memory_global_dirty_log_do_stop(unsigned int flags)
@@ -2821,12 +2822,12 @@ static void memory_global_dirty_log_do_stop(unsigned
int flags)
trace_global_dirty_changed(global_dirty_tracking);
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
- memory_region_transaction_begin();
- memory_region_update_pending = true;
- memory_region_transaction_commit();
-
- MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
+ if (!global_dirty_tracking) {
+ memory_region_transaction_begin();
+ memory_region_update_pending = true;
+ memory_region_transaction_commit();
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
+ }
}
static void memory_vm_change_state_handler(void *opaque, bool running,
--
2.34.1
- [PULL 01/19] memory: Directly dispatch alias accesses on origin memory region, (continued)
- [PULL 01/19] memory: Directly dispatch alias accesses on origin memory region, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 04/19] machine: Use host_memory_backend_is_mapped() in machine_consume_memdev(), Philippe Mathieu-Daudé, 2022/01/18
- [PULL 02/19] memory: Split mtree_info() as mtree_info_flatview() + mtree_info_as(), Philippe Mathieu-Daudé, 2022/01/18
- [PULL 03/19] memory: Have 'info mtree' remove duplicated Address Space information, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 06/19] memory: Update description of memory_region_is_mapped(), Philippe Mathieu-Daudé, 2022/01/18
- [PULL 08/19] stubs: Restrict fw_cfg to system emulation, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 10/19] hw/pci: Restrict pci-bus stub to sysemu, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 19/19] docs/devel: add some clarifying text for aliases, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 17/19] hw/dma: Use dma_addr_t type definition when relevant, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 12/19] hw/dma: Remove CONFIG_USER_ONLY check, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 07/19] memory: Fix incorrect calls of log_global_start/stop,
Philippe Mathieu-Daudé <=
- [PULL 09/19] hw/nvram: Restrict fw_cfg QOM interface to sysemu and tools, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 05/19] memory: Make memory_region_is_mapped() succeed when mapped via an alias, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 16/19] hw/dma: Move ScatterGatherEntry / QEMUSGList declarations around, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 14/19] hw/scsi: Rename SCSIRequest::resid as 'residual', Philippe Mathieu-Daudé, 2022/01/18
- [PULL 11/19] hw/pci: Document pci_dma_map(), Philippe Mathieu-Daudé, 2022/01/18
- [PULL 13/19] hw/rdma/rdma_utils: Rename rdma_pci_dma_map 'len' argument, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 18/19] hw/dma: Let dma_buf_read() / dma_buf_write() propagate MemTxResult, Philippe Mathieu-Daudé, 2022/01/18
- [PULL 15/19] hw/dma: Fix format string issues using dma_addr_t, Philippe Mathieu-Daudé, 2022/01/18
- Re: [PULL 00/19] Memory API patches for 2022-01-18, Peter Maydell, 2022/01/18