From patchwork Wed Feb 24 13:27:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8406881 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E044C0553 for ; Wed, 24 Feb 2016 13:34:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB5EC202E6 for ; Wed, 24 Feb 2016 13:34:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C13320212 for ; Wed, 24 Feb 2016 13:34:03 +0000 (UTC) Received: from localhost ([::1]:35876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYZZr-0007nF-0I for patchwork-qemu-devel@patchwork.kernel.org; Wed, 24 Feb 2016 08:34:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYZU9-0005Gh-D7 for qemu-devel@nongnu.org; Wed, 24 Feb 2016 08:28:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYZU8-0005mA-Fc for qemu-devel@nongnu.org; Wed, 24 Feb 2016 08:28:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYZU8-0005m1-AL for qemu-devel@nongnu.org; Wed, 24 Feb 2016 08:28:08 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 030CAC0AC202; Wed, 24 Feb 2016 13:28:08 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1ODRha5009553; Wed, 24 Feb 2016 08:28:06 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 24 Feb 2016 14:27:37 +0100 Message-Id: <1456320461-26756-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1456320461-26756-1-git-send-email-pbonzini@redhat.com> References: <1456320461-26756-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gonglei Subject: [Qemu-devel] [PULL 15/19] exec: store RAMBlock pointer into memory region 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gonglei Each RAM memory region has a unique corresponding RAMBlock. In the current realization, the memory region only stored the ram_addr which means the offset of RAM address space, We need to qurey the global ram.list to find the ram block by ram_addr if we want to get the ram block, which is very expensive. Now, we store the RAMBlock pointer into memory region structure. So, if we know the mr, we can easily get the RAMBlock. Signed-off-by: Gonglei Message-Id: <1456130097-4208-2-git-send-email-arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini --- exec.c | 2 ++ include/exec/memory.h | 2 ++ memory.c | 1 + 3 files changed, 5 insertions(+) diff --git a/exec.c b/exec.c index 1f24500..4c0114a 100644 --- a/exec.c +++ b/exec.c @@ -1717,6 +1717,8 @@ ram_addr_t qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, error_propagate(errp, local_err); return -1; } + + mr->ram_block = new_block; return addr; } diff --git a/include/exec/memory.h b/include/exec/memory.h index c92734a..4025729 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -156,6 +156,7 @@ struct MemoryRegionIOMMUOps { typedef struct CoalescedMemoryRange CoalescedMemoryRange; typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; +typedef struct RAMBlock RAMBlock; struct MemoryRegion { Object parent_obj; @@ -172,6 +173,7 @@ struct MemoryRegion { bool global_locking; uint8_t dirty_log_mask; ram_addr_t ram_addr; + RAMBlock *ram_block; Object *owner; const MemoryRegionIOMMUOps *iommu_ops; diff --git a/memory.c b/memory.c index 09041ed..b4451dd 100644 --- a/memory.c +++ b/memory.c @@ -912,6 +912,7 @@ void memory_region_init(MemoryRegion *mr, } mr->name = g_strdup(name); mr->owner = owner; + mr->ram_block = NULL; if (name) { char *escaped_name = memory_region_escape_name(name);