From patchwork Sun Oct 28 23:48:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfank@linux.vnet.ibm.com X-Patchwork-Id: 194759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 561C92C0086 for ; Mon, 29 Oct 2012 10:49:29 +1100 (EST) Received: from localhost ([::1]:34674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TScbf-0005kW-GW for incoming@patchwork.ozlabs.org; Sun, 28 Oct 2012 19:49:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TScbK-0005Xg-Jw for qemu-devel@nongnu.org; Sun, 28 Oct 2012 19:49:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TScbJ-0003q1-K1 for qemu-devel@nongnu.org; Sun, 28 Oct 2012 19:49:06 -0400 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:52372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TScbI-0003o8-Qo for qemu-devel@nongnu.org; Sun, 28 Oct 2012 19:49:05 -0400 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Oct 2012 05:19:02 +0530 Received: from d28relay02.in.ibm.com (9.184.220.59) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 Oct 2012 05:19:00 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9SNn0ns34078748 for ; Mon, 29 Oct 2012 05:19:00 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9T5Ipje008500 for ; Mon, 29 Oct 2012 05:18:52 GMT Received: from oc8440477808.ibm.com ([9.125.25.249]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9T5IebM008036; Mon, 29 Oct 2012 05:18:50 GMT From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2012 07:48:44 +0800 Message-Id: <1351468127-15025-6-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1351468127-15025-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1351468127-15025-1-git-send-email-pingfank@linux.vnet.ibm.com> x-cbid: 12102823-3864-0000-0000-00000544F423 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.3 Cc: Peter Maydell , Stefan Hajnoczi , Marcelo Tosatti , Avi Kivity , Anthony Liguori , Jan Kiszka , Paolo Bonzini Subject: [Qemu-devel] [patch v5 5/8] memory: introduce local lock for address space X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org For those address spaces which want to be able out of big lock, they will be protected by their own local. Signed-off-by: Liu Ping Fan --- memory.c | 11 ++++++++++- memory.h | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/memory.c b/memory.c index 2f68d67..ff34aed 100644 --- a/memory.c +++ b/memory.c @@ -1532,9 +1532,15 @@ void memory_listener_unregister(MemoryListener *listener) QTAILQ_REMOVE(&memory_listeners, listener, link); } -void address_space_init(AddressSpace *as, MemoryRegion *root) +void address_space_init(AddressSpace *as, MemoryRegion *root, bool lock) { memory_region_transaction_begin(); + if (lock) { + as->lock = g_new(QemuMutex, 1); + qemu_mutex_init(as->lock); + } else { + as->lock = NULL; + } as->root = root; as->current_map = g_new(FlatView, 1); flatview_init(as->current_map); @@ -1553,6 +1559,9 @@ void address_space_destroy(AddressSpace *as) QTAILQ_REMOVE(&address_spaces, as, address_spaces_link); address_space_destroy_dispatch(as); flatview_destroy(as->current_map); + if (as->lock) { + g_free(as->lock); + } g_free(as->current_map); } diff --git a/memory.h b/memory.h index 79393f1..12d1c56 100644 --- a/memory.h +++ b/memory.h @@ -22,6 +22,7 @@ #include "cpu-common.h" #include "targphys.h" #include "qemu-queue.h" +#include "qemu-thread.h" #include "iorange.h" #include "ioport.h" #include "int128.h" @@ -164,6 +165,7 @@ typedef struct AddressSpace AddressSpace; */ struct AddressSpace { /* All fields are private. */ + QemuMutex *lock; const char *name; MemoryRegion *root; struct FlatView *current_map; @@ -801,8 +803,9 @@ void mtree_info(fprintf_function mon_printf, void *f); * * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space + * @lock: if true, the physmap protected by local lock, otherwise big lock */ -void address_space_init(AddressSpace *as, MemoryRegion *root); +void address_space_init(AddressSpace *as, MemoryRegion *root, bool lock); /**