summary refs log tree commit diff stats
path: root/system/memory.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2025-08-14 18:05:53 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2025-08-29 12:48:14 +0200
commit73c520b088878682e2d3b7fa19a6366ec8d39829 (patch)
tree4766e598cc92df2e3f4c565ff3e451e2f215ea04 /system/memory.c
parent87511341c30d8c9c77178db16491a0ccacc5d64b (diff)
downloadfocaccia-qemu-73c520b088878682e2d3b7fa19a6366ec8d39829.tar.gz
focaccia-qemu-73c520b088878682e2d3b7fa19a6366ec8d39829.zip
memory: reintroduce BQL-free fine-grained PIO/MMIO
This patch brings back Jan's idea [1] of BQL-free IO access

This will let us make access to ACPI PM/HPET timers cheaper,
and prevent BQL contention in case of workload that heavily
uses the timers with a lot of vCPUs.

1) 196ea13104f (memory: Add global-locking property to memory regions)
   ... de7ea885c539 (kvm: Switch to unlocked MMIO)

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20250814160600.2327672-2-imammedo@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'system/memory.c')
-rw-r--r--system/memory.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/system/memory.c b/system/memory.c
index 5646547940..44701c465c 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -2546,6 +2546,21 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr)
     }
 }
 
+void memory_region_enable_lockless_io(MemoryRegion *mr)
+{
+    mr->lockless_io = true;
+    /*
+     * reentrancy_guard has per device scope, that when enabled
+     * will effectively prevent concurrent access to device's IO
+     * MemoryRegion(s) by not calling accessor callback.
+     *
+     * Turn it off for lock-less IO enabled devices, to allow
+     * concurrent IO.
+     * TODO: remove this when reentrancy_guard becomes per transaction.
+     */
+    mr->disable_reentrancy_guard = true;
+}
+
 void memory_region_add_eventfd(MemoryRegion *mr,
                                hwaddr addr,
                                unsigned size,