On 13/04/2023 12.31, Richard Henderson wrote:
On 4/13/23 07:45, Thomas Huth wrote:
      uint32_t dirty_ring_size = kvm_dirty_ring_size();
      uint64_t dirty_ring_size_meory_MB =
-        dirty_ring_size * TARGET_PAGE_SIZE >> 20;
+        dirty_ring_size * qemu_target_page_size() >> 20;

Existing problem, the types here are suspicious: dirty_ring_size is uint32_t, dirty_ring_size_meory (typo) is uint64_t.

I wonder if this is better computed as

    uint32_t dirty_ring_size_MB = dirty_ring_size >> (20 - qemu_target_page_bits());

qemu_target_page_size() returns a "size_t", so I think it should be fine for 64-bit hosts. But for 32-bit hosts, this looks error prone, indeed, so I think your suggestion is a good idea. Care to send a patch?

 Thomas


Reply via email to