From patchwork Fri Dec 20 01:41:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22660 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 514E723FC4 for ; Fri, 20 Dec 2013 01:41:28 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id lx4sf7699743iec.6 for ; Thu, 19 Dec 2013 17:41:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UBZx7xAZdj185Wriz990sZPno5CRx9AcOcLWjwTqG44=; b=cAfv9sq47Cxlu2c/IUYKb82arxqFtclNcB0KCijQ2zB2+FYbFA1rabblQs0F6Rb/kQ 0pamri6//IdmjoPonOhhFOq13Rpr8SE1bA7TUHCr7VwHhVjGLnJNkVWK3iQuonwbdq+F vope1W0/lPk98bBnN9wJSoGE4AWEwbgY+yBB+xWD89OF2lnTmvlYqOfWF3lDh8M50KAl O5KpKHHd6ewsiMwTnt8su02e0w7jsSL4pteuQruouzFryIHhn0KUIL/d0+l63j5Z6VqZ x/OMkA8J1H1ui3S7LBplldiXILqzmxdDPagJBuZd/7fFmwsGNPxxnr6HuQqsKFNXut0r AUZw== X-Gm-Message-State: ALoCoQkGRs0CcSuEGg48tGUji0UWe/zslTUvWC2jfaYaWgN3udgfm4wZwVPpUEphlvZGOtxLZkv0 X-Received: by 10.50.66.238 with SMTP id i14mr3058519igt.4.1387503688079; Thu, 19 Dec 2013 17:41:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.65 with SMTP id m1ls536606qed.91.gmail; Thu, 19 Dec 2013 17:41:27 -0800 (PST) X-Received: by 10.221.64.17 with SMTP id xg17mr3479537vcb.5.1387503687893; Thu, 19 Dec 2013 17:41:27 -0800 (PST) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id sx7si1103998vdc.29.2013.12.19.17.41.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 17:41:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id q12so1052032vbe.20 for ; Thu, 19 Dec 2013 17:41:27 -0800 (PST) X-Received: by 10.58.46.18 with SMTP id r18mr3395896vem.4.1387503687478; Thu, 19 Dec 2013 17:41:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp26817ved; Thu, 19 Dec 2013 17:41:25 -0800 (PST) X-Received: by 10.14.174.129 with SMTP id x1mr2621542eel.19.1387503685086; Thu, 19 Dec 2013 17:41:25 -0800 (PST) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id 5si6631742eei.81.2013.12.19.17.41.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 17:41:25 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id e53so773942eek.1 for ; Thu, 19 Dec 2013 17:41:24 -0800 (PST) X-Received: by 10.14.114.71 with SMTP id b47mr2783606eeh.26.1387503683982; Thu, 19 Dec 2013 17:41:23 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b41sm14140717eef.16.2013.12.19.17.41.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2013 17:41:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH v2] xen/arm: p2m: Don't create new table when the mapping is removed Date: Fri, 20 Dec 2013 01:41:20 +0000 Message-Id: <1387503680-2850-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When Xen is removing/relinquishing mapping, it will create second/third tables if they don't exist. Non-existent table means the address range was never mapped, so Xen can safely skip them. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Release: This is an improvement for Xen 4.4. It will save time during relinquish phase and avoid dummy allocation. The downside is the patch is modifying p2m loop which is used everywhere. Changes in v2: - Handle case where address is not {FIRST,SECOND}_SIZE aligned. We can't use ROUND macro because if the address is aligned, it doesn't add the size. So it will end up in an infinite loop. --- xen/arch/arm/p2m.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index d24a6fc..11f4714 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -246,10 +246,12 @@ static int create_p2m_entries(struct domain *d, cur_first_offset = ~0, cur_second_offset = ~0; unsigned long count = 0; + bool_t populate = (op == INSERT || op == ALLOCATE); spin_lock(&p2m->lock); - for(addr = start_gpaddr; addr < end_gpaddr; addr += PAGE_SIZE) + addr = start_gpaddr; + while ( addr < end_gpaddr ) { if ( cur_first_page != p2m_first_level_index(addr) ) { @@ -265,8 +267,15 @@ static int create_p2m_entries(struct domain *d, if ( !first[first_table_offset(addr)].p2m.valid ) { + if ( !populate ) + { + addr = (addr + FIRST_SIZE) & FIRST_MASK; + continue; + } + rc = p2m_create_table(d, &first[first_table_offset(addr)]); - if ( rc < 0 ) { + if ( rc < 0 ) + { printk("p2m_populate_ram: L1 failed\n"); goto out; } @@ -284,6 +293,12 @@ static int create_p2m_entries(struct domain *d, if ( !second[second_table_offset(addr)].p2m.valid ) { + if ( !populate ) + { + addr = (addr + SECOND_SIZE) & SECOND_MASK; + continue; + } + rc = p2m_create_table(d, &second[second_table_offset(addr)]); if ( rc < 0 ) { printk("p2m_populate_ram: L2 failed\n"); @@ -372,6 +387,9 @@ static int create_p2m_entries(struct domain *d, } count = 0; } + + /* Got the next page */ + addr += PAGE_SIZE; } if ( op == ALLOCATE || op == INSERT )