From patchwork Fri May 2 15:17:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 29554 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B385B202E7 for ; Fri, 2 May 2014 15:19:31 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rp18sf24665949iec.5 for ; Fri, 02 May 2014 08:19:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=3hX8pgwogPwUp2tPSma5TXkNPT8/RcrSi2U//ny1C4E=; b=OQgWNZVPtrqTY2CDJHmsmkxKqAVtBg+0g9Xf6IsygkqqLNi6WNqX67eNfyD5TiM81R ziUFOYGWHrIJBz4s1BkEzwRI9b+j7fTI8FSwqaSv2RatVrFMj0MmSM8w/V7STIfOoLkQ blYUBg7cizy/Ui3PqUn6hbKiqdW7y2wrfvacv6IAs1az7BwdfMVcIZxevUes59ExAtRq I2kgiiVJux8EWjUygFD6jGdpHXGctzXhpG/nuo3nJUvF1+bRxjl+kn/XeYC+DVDilrld dEhvVt6HkJ+q9xR4d+3jhUs6VUkT+qiKimPiGcx48FRuaZJJJPW65RbvTh1GaCvPacMC PTsw== X-Gm-Message-State: ALoCoQmNBU2zqEd9uc8LpI++wWJwvF7c7O72zoHZhvpO0hUQkUx29yOBjLw/4kV2jm6j9s20TzHh X-Received: by 10.43.139.201 with SMTP id ix9mr7026096icc.30.1399043971195; Fri, 02 May 2014 08:19:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.200 with SMTP id m66ls1467763qge.83.gmail; Fri, 02 May 2014 08:19:31 -0700 (PDT) X-Received: by 10.221.69.68 with SMTP id yb4mr443387vcb.49.1399043971033; Fri, 02 May 2014 08:19:31 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id xo2si6774896vec.62.2014.05.02.08.19.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 May 2014 08:19:31 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so4615905veb.32 for ; Fri, 02 May 2014 08:19:31 -0700 (PDT) X-Received: by 10.52.2.229 with SMTP id 5mr11562675vdx.24.1399043970951; Fri, 02 May 2014 08:19:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp110554vcb; Fri, 2 May 2014 08:19:30 -0700 (PDT) X-Received: by 10.224.131.132 with SMTP id x4mr22991077qas.97.1399043970087; Fri, 02 May 2014 08:19:30 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k50si14266131qge.25.2014.05.02.08.19.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 May 2014 08:19:30 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WgFE0-0000oG-MX; Fri, 02 May 2014 15:18:08 +0000 Received: from mail-wg0-f50.google.com ([74.125.82.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WgFDx-0000lW-HG for linux-arm-kernel@lists.infradead.org; Fri, 02 May 2014 15:18:06 +0000 Received: by mail-wg0-f50.google.com with SMTP id k14so3828074wgh.9 for ; Fri, 02 May 2014 08:17:40 -0700 (PDT) X-Received: by 10.180.228.42 with SMTP id sf10mr3468815wic.48.1399043860088; Fri, 02 May 2014 08:17:40 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id fu10sm5443964wib.11.2014.05.02.08.17.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 May 2014 08:17:39 -0700 (PDT) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2] arm64: mm: Create gigabyte kernel logical mappings where possible Date: Fri, 2 May 2014 16:17:09 +0100 Message-Id: <1399043829-9036-1-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140502_081805_763881_EF81A233 X-CRM114-Status: GOOD ( 15.12 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.50 listed in list.dnswl.org] Cc: catalin.marinas@arm.com, Steve Capper , jays.lee@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 We have the capability to map 1GB level 1 blocks when using a 4K granule. This patch adjusts the create_mapping logic s.t. when mapping physical memory on boot, we attempt to use a 1GB block if both the VA and PA start and end are 1GB aligned. This both reduces the levels of lookup required to resolve a kernel logical address, as well as reduces TLB pressure on cores that support 1GB TLB entries. Signed-off-by: Steve Capper --- Changed in V2: free the original pmd table from swapper_pg_dir if we replace it with a block pud entry. Catalin, pud_pfn would give us the pud pointed to by a huge pud. (so will resolve to a gigabyte aligned address when << PAGE_SHIFTed). What we want is the pointer to the pmd table. I've opted to go for pmd_offset as it's easier to gauge intent. (I know we convert from PA->VA->PA, but this will probably compile out, and is done once on boot...). I've tested this with 3 and 4 levels on the Model (and a load of debug printing that I've removed from the patch). Cheers, diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 4d29332..2ced5f6 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -234,7 +234,30 @@ static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, pud = pud_offset(pgd, addr); do { next = pud_addr_end(addr, end); - alloc_init_pmd(pud, addr, next, phys); + + /* + * For 4K granule only, attempt to put down a 1GB block + */ + if ((PAGE_SHIFT == 12) && + ((addr | next | phys) & ~PUD_MASK) == 0) { + pud_t old_pud = *pud; + set_pud(pud, __pud(phys | prot_sect_kernel)); + + /* + * If we have an old value for a pud, it will + * be pointing to a pmd table that we no longer + * need (from swapper_pg_dir). + * + * Look up the old pmd table and free it. + */ + if (!pud_none(old_pud)) { + phys_addr_t table = __pa(pmd_offset(&old_pud, 0)); + memblock_free(table, PAGE_SIZE); + flush_tlb_all(); + } + } else { + alloc_init_pmd(pud, addr, next, phys); + } phys += next - addr; } while (pud++, addr = next, addr != end); }