Skip to contentSkip to conversation

softmmu: Move dirtylimit.c into the target independent source set

PATCH In review Thomas Huth 3 participants 4 messages Apr 13, 2023 – Apr 26, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softmmu: Move dirtylimit.c into the target independent source set

dirtylimit.c just uses one TARGET_PAGE_SIZE macro - change it to qemu_target_page_size() so we can move thefile into the target independent source set. Then we only have to compile this file once during the build instead of multiple times (one time for each target).

---
 softmmu/dirtylimit.c | 3 ++-
 softmmu/meson.build  | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
softmmu/dirtylimit.c +2 -1
index c56f0f58c8..82986c1499 100644
@@ -20,6 +20,7 @@
 #include "monitor/hmp.h"
 #include "monitor/monitor.h"
 #include "exec/memory.h"
+#include "exec/target_page.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
 #include "trace.h"
@@ -236,7 +237,7 @@ static inline int64_t dirtylimit_dirty_ring_full_time(uint64_t dirtyrate)
     static uint64_t max_dirtyrate;
     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;
 
     if (max_dirtyrate < dirtyrate) {
         max_dirtyrate = dirtyrate;
softmmu/meson.build +1 -1
index b392f0bd35..974732b0f3 100644
@@ -3,7 +3,6 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
   'ioport.c',
   'memory.c',
   'physmem.c',
-  'dirtylimit.c',
   'watchpoint.c',
 )])
 
@@ -18,6 +17,7 @@ softmmu_ss.add(files(
   'cpu-throttle.c',
   'cpu-timers.c',
   'datadir.c',
+  'dirtylimit.c',
   'dma-helpers.c',
   'globals.c',
   'memory_mapping.c',
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Thomas Huth

dirtylimit.c just uses one TARGET_PAGE_SIZE macro - change it to qemu_target_page_size() so we can move thefile into the target independent source set. Then we only have to compile this file once during the build instead of multiple times (one time for each target).

#2 lore raw
In reply to Thomas Huth

softmmu/dirtylimit.c static inline int64_t dirtylimit_dirty_ring_full_time(uint64_t dirtyrate) · line 240

Quoted 4 lines · Thomas Huth

uint32_t dirty_ring_size = kvm_dirty_ring_size(); uint64_t dirty_ring_size_meory_MB =

softmmu/dirtylimit.c +1 -1
-        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());

r~

#3 lore raw
Quoted 6 lines · Richard Henderson
Quoted 4 lines · Thomas Huth

      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;

Quoted 6 lines

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