From patchwork Mon Feb 18 23:12:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Korolev X-Patchwork-Id: 221552 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 ABA522C0089 for ; Tue, 19 Feb 2013 10:13:40 +1100 (EST) Received: from localhost ([::1]:32862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Zty-0000cd-OK for incoming@patchwork.ozlabs.org; Mon, 18 Feb 2013 18:13:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7ZtV-0008Th-Dh for qemu-devel@nongnu.org; Mon, 18 Feb 2013 18:13:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7ZtP-00083Z-H5 for qemu-devel@nongnu.org; Mon, 18 Feb 2013 18:13:09 -0500 Received: from mail-pb0-f51.google.com ([209.85.160.51]:62590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7ZtP-000836-BD for qemu-devel@nongnu.org; Mon, 18 Feb 2013 18:13:03 -0500 Received: by mail-pb0-f51.google.com with SMTP id un15so1883427pbc.24 for ; Mon, 18 Feb 2013 15:13:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=mW8RpyoSRh+1EnE1d7vgBqZODX+lo8HCmDah0l7fjoI=; b=CjSMcev/OI3SS54DiLprL2b2mXhoR8lChSu/mFOIFIh6wzE9ul/jeVENBqTY3sNViI w4Dx0VcRG21OuIvIywmNG07p7j0YRyj97syY5rs7WyFd7fZrmLoh9mHjmQnfxD+tJ/Vw S4We1Ipf8fWYhkh5Aa4Q3iSay2LGZhhvJFa5WpXTSW/eWH7W+l53V9pJfHyxxSn09dWu tBYzO0Mo1CK/xazD+9K4jRj/nFvkOtk1Y9E8HMbmWK6EGuj+lpQ72a3i3MkmI1w6vePx ySJ9KpLkFwp3an/ad5eweuC4DKWx/IXkOSJKChkrMda7EYVtNTCuULwRibpYpp7YJk9W vZNA== X-Received: by 10.68.211.103 with SMTP id nb7mr23368114pbc.140.1361229182797; Mon, 18 Feb 2013 15:13:02 -0800 (PST) Received: from nzhmlwks0118.et.endace.com. ([210.7.32.45]) by mx.google.com with ESMTPS id ab1sm15775579pbd.37.2013.02.18.15.13.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Feb 2013 15:13:02 -0800 (PST) From: Alexey Korolev To: qemu-devel@nongnu.org, mst@redhat.com Date: Tue, 19 Feb 2013 12:12:49 +1300 Message-Id: <1361229171-23902-3-git-send-email-akorolex@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1361229171-23902-1-git-send-email-akorolex@gmail.com> References: <1361229171-23902-1-git-send-email-akorolex@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.51 Subject: [Qemu-devel] [PATCH 2/3] Remove may_overlap flag from MemoryRegion structure 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 This patch removes may_overlap flag from MemoryRegion structure as it is no longer used. If we want to add a region which must never be overlapped we can set memory region priority to MR_PRIORITY_EXCLUSIVE. Warning will be printed if two memory regions are competing for the same address range and have exclusive priority. Since may_overlap is abandoned, memory_region_add_subregion and memory_region_add_subregion_common become equvalent so memory_region_add_subregion_common is removed. Signed-off-by: Alexey Korolev --- include/exec/memory.h | 1 - memory.c | 21 +++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 162bdba..203318a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -142,7 +142,6 @@ struct MemoryRegion { MemoryRegion *alias; hwaddr alias_offset; unsigned priority; - bool may_overlap; QTAILQ_HEAD(subregions, MemoryRegion) subregions; QTAILQ_ENTRY(MemoryRegion) subregions_link; QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; diff --git a/memory.c b/memory.c index ec5aa57..d151f8d 100644 --- a/memory.c +++ b/memory.c @@ -806,7 +806,6 @@ void memory_region_init(MemoryRegion *mr, mr->rom_device = false; mr->destructor = memory_region_destructor_none; mr->priority = MR_PRIORITY_LOW; - mr->may_overlap = false; mr->alias = NULL; QTAILQ_INIT(&mr->subregions); memset(&mr->subregions_link, 0, sizeof mr->subregions_link); @@ -1306,9 +1305,9 @@ void memory_region_del_eventfd(MemoryRegion *mr, memory_region_transaction_commit(); } -static void memory_region_add_subregion_common(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion) +void memory_region_add_subregion(MemoryRegion *mr, + hwaddr offset, + MemoryRegion *subregion) { MemoryRegion *other; @@ -1318,7 +1317,8 @@ static void memory_region_add_subregion_common(MemoryRegion *mr, subregion->parent = mr; subregion->addr = offset; QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { - if (subregion->may_overlap || other->may_overlap) { + if (other->priority != MR_PRIORITY_EXCLUSIVE + || subregion->priority != MR_PRIORITY_EXCLUSIVE) { continue; } if (int128_gt(int128_make64(offset), @@ -1327,7 +1327,6 @@ static void memory_region_add_subregion_common(MemoryRegion *mr, int128_make64(other->addr))) { continue; } -#if 0 printf("warning: subregion collision %llx/%llx (%s) " "vs %llx/%llx (%s)\n", (unsigned long long)offset, @@ -1336,7 +1335,6 @@ static void memory_region_add_subregion_common(MemoryRegion *mr, (unsigned long long)other->addr, (unsigned long long)int128_get64(other->size), other->name); -#endif } QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { if (subregion->priority >= other->priority) { @@ -1350,15 +1348,6 @@ done: memory_region_transaction_commit(); } - -void memory_region_add_subregion(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion) -{ - subregion->may_overlap = false; - subregion->priority = 0; - memory_region_add_subregion_common(mr, offset, subregion); -} void memory_region_del_subregion(MemoryRegion *mr, MemoryRegion *subregion) {