Message ID | 20201116132210.1730-1-yuzenghui@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | memory: Skip dirty tracking for un-migratable memory regions | expand |
On Mon, 16 Nov 2020 21:22:10 +0800 Zenghui Yu <yuzenghui@huawei.com> wrote: > It makes no sense to track dirty pages for those un-migratable memory > regions (e.g., Memory BAR region of the VFIO PCI device) and doing so > will potentially lead to some unpleasant issues during migration [1]. > > Skip dirty tracking for those regions by evaluating if the region is > migratable before setting dirty_log_mask (DIRTY_MEMORY_MIGRATION). > > [1] https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg03757.html > > Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> > --- > softmmu/memory.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/softmmu/memory.c b/softmmu/memory.c > index 71951fe4dc..aa393f1bb0 100644 > --- a/softmmu/memory.c > +++ b/softmmu/memory.c > @@ -1806,7 +1806,10 @@ bool memory_region_is_ram_device(MemoryRegion *mr) > uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) > { > uint8_t mask = mr->dirty_log_mask; > - if (global_dirty_log && (mr->ram_block || memory_region_is_iommu(mr))) { > + RAMBlock *rb = mr->ram_block; > + > + if (global_dirty_log && ((rb && qemu_ram_is_migratable(rb)) || > + memory_region_is_iommu(mr))) { > mask |= (1 << DIRTY_MEMORY_MIGRATION); > } > return mask; Looks reasonable. Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On 16/11/20 14:22, Zenghui Yu wrote: > It makes no sense to track dirty pages for those un-migratable memory > regions (e.g., Memory BAR region of the VFIO PCI device) and doing so > will potentially lead to some unpleasant issues during migration [1]. > > Skip dirty tracking for those regions by evaluating if the region is > migratable before setting dirty_log_mask (DIRTY_MEMORY_MIGRATION). > > [1] https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg03757.html > > Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> > --- > softmmu/memory.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/softmmu/memory.c b/softmmu/memory.c > index 71951fe4dc..aa393f1bb0 100644 > --- a/softmmu/memory.c > +++ b/softmmu/memory.c > @@ -1806,7 +1806,10 @@ bool memory_region_is_ram_device(MemoryRegion *mr) > uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) > { > uint8_t mask = mr->dirty_log_mask; > - if (global_dirty_log && (mr->ram_block || memory_region_is_iommu(mr))) { > + RAMBlock *rb = mr->ram_block; > + > + if (global_dirty_log && ((rb && qemu_ram_is_migratable(rb)) || > + memory_region_is_iommu(mr))) { > mask |= (1 << DIRTY_MEMORY_MIGRATION); > } > return mask; > Queued, thanks. Paolo
diff --git a/softmmu/memory.c b/softmmu/memory.c index 71951fe4dc..aa393f1bb0 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1806,7 +1806,10 @@ bool memory_region_is_ram_device(MemoryRegion *mr) uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) { uint8_t mask = mr->dirty_log_mask; - if (global_dirty_log && (mr->ram_block || memory_region_is_iommu(mr))) { + RAMBlock *rb = mr->ram_block; + + if (global_dirty_log && ((rb && qemu_ram_is_migratable(rb)) || + memory_region_is_iommu(mr))) { mask |= (1 << DIRTY_MEMORY_MIGRATION); } return mask;
It makes no sense to track dirty pages for those un-migratable memory regions (e.g., Memory BAR region of the VFIO PCI device) and doing so will potentially lead to some unpleasant issues during migration [1]. Skip dirty tracking for those regions by evaluating if the region is migratable before setting dirty_log_mask (DIRTY_MEMORY_MIGRATION). [1] https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg03757.html Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> --- softmmu/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)