From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYDv7-0002ZC-Go for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYDv6-0003bb-DZ for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:22:01 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:38408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYDv6-0003bR-7W for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:22:00 -0400 Received: by wifj2 with SMTP id j2so39595974wif.1 for ; Wed, 18 Mar 2015 06:21:59 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 18 Mar 2015 14:21:42 +0100 Message-Id: <1426684909-95030-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1426684909-95030-1-git-send-email-pbonzini@redhat.com> References: <1426684909-95030-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/8] memory: Add global-locking property to memory regions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jan Kiszka From: Jan Kiszka This introduces the memory region property "global_locking". It is true by default. By setting it to false, a device model can request BQL-free dispatching of region accesses to its r/w handlers. The actual BQL break-up will be provided in a separate patch. Signed-off-by: Jan Kiszka Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 26 ++++++++++++++++++++++++++ memory.c | 11 +++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 06ffa1d..0ee2079 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -158,6 +158,7 @@ struct MemoryRegion { bool rom_device; bool warning_printed; /* For reservations */ bool flush_coalesced_mmio; + bool global_locking; MemoryRegion *alias; hwaddr alias_offset; int32_t priority; @@ -778,6 +779,31 @@ void memory_region_set_flush_coalesced(MemoryRegion *mr); void memory_region_clear_flush_coalesced(MemoryRegion *mr); /** + * memory_region_set_global_locking: Declares the access processing requires + * QEMU's global lock. + * + * When this is invoked, access to this memory regions will be processed while + * holding the global lock of QEMU. This is the default behavior of memory + * regions. + * + * @mr: the memory region to be updated. + */ +void memory_region_set_global_locking(MemoryRegion *mr); + +/** + * memory_region_clear_global_locking: Declares that access processing does + * not depend on the QEMU global lock. + * + * By clearing this property, accesses to the memory region will be processed + * outside of QEMU's global lock (unless the lock is held on when issuing the + * access request). In this case, the device model implementing the access + * handlers is responsible for synchronization of concurrency. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_global_locking(MemoryRegion *mr); + +/** * memory_region_add_eventfd: Request an eventfd to be triggered when a word * is written to a location. * diff --git a/memory.c b/memory.c index ee3f2a8..cc798e1 100644 --- a/memory.c +++ b/memory.c @@ -953,6 +953,7 @@ static void memory_region_initfn(Object *obj) mr->ops = &unassigned_mem_ops; mr->enabled = true; mr->romd_mode = true; + mr->global_locking = true; mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); QTAILQ_INIT(&mr->coalesced); @@ -1549,6 +1550,16 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr) } } +void memory_region_set_global_locking(MemoryRegion *mr) +{ + mr->global_locking = true; +} + +void memory_region_clear_global_locking(MemoryRegion *mr) +{ + mr->global_locking = false; +} + void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size, -- 2.3.0