From patchwork Wed May 6 10:11:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 6348441 Return-Path: X-Original-To: patchwork-linux-arm@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 8E7EEBEEE1 for ; Wed, 6 May 2015 10:21:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F45D202A1 for ; Wed, 6 May 2015 10:21:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83F0E20270 for ; Wed, 6 May 2015 10:21:03 +0000 (UTC) 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 1YpwOU-0002MQ-AZ; Wed, 06 May 2015 10:17:34 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpwIq-0005Z7-MX for linux-arm-kernel@lists.infradead.org; Wed, 06 May 2015 10:11:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=5qAKP63/2G9PWF8Yinp3lbND+HccHX3LJctSGL9AiG0=; b=jyiIQO3VeFwVJjfJDnw1WrGlRvWI+zuU0AOOL6xwrlRzX/8omzS7lSksAmye1dsWfwDTPgk1ZO+Nhlm9K+PmJZISBZ6x8BCQrbqQyQ5+3FttJhetO6DptM3oTUlpcSDUHQpNqd1aPZzPxA52euPljtociUmMes0Pw19tXn9Wurg=; Received: from n2100.arm.linux.org.uk ([fd8f:7570:feb6:1:214:fdff:fe10:4f86]:35059) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1YpwIJ-0003u3-M2; Wed, 06 May 2015 11:11:11 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1YpwIF-0004ij-40; Wed, 06 May 2015 11:11:07 +0100 Date: Wed, 6 May 2015 11:11:05 +0100 From: Russell King - ARM Linux To: Stefan Agner Subject: Re: Memory size unaligned to section boundary Message-ID: <20150506101104.GD2067@n2100.arm.linux.org.uk> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150506_031145_121022_4A24D706 X-CRM114-Status: GOOD ( 21.97 ) X-Spam-Score: -0.1 (/) Cc: hdegoede@redhat.com, js07.lee@gmail.com, grygorii.strashko@linaro.org, linux-arm-kernel@lists.infradead.org, r.sricharan@ti.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 On Thu, Apr 23, 2015 at 03:19:45PM +0200, Stefan Agner wrote: > Hi, > > It seems to me that I hit an issue in low memory mapping (map_lowmem). > I'm using a custom memory size, which leads to an freeze on Linux 4.0 > and also with Linus master on two tested ARMv7-A SoC's (Freescale Vybrid > and NVIDIA Tegra 3): > > With mem=259744K > [ 0.000000] Booting Linux on physical CPU 0x0 > [ 0.000000] Linux version 4.0.0-00189-ga4d2a4c3-dirty > (ags@trochilidae) (gcc version 4.8.3 20140401 (prerelease) (Linaro GCC > 4.8-2014.04) ) #506 Thu Apr 23 14:13:21 CEST 2015 > [ 0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), > cr=10c5387d > [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing > instruction cache > [ 0.000000] Machine model: Toradex Colibri VF61 on Colibri Evaluation > Board > [ 0.000000] bootconsole [earlycon0] enabled > [ 0.000000] cma: Reserved 16 MiB at 0x8e400000 > [ 0.000000] Memory policy: Data cache writeback > > > I dug a bit more into that, and it unveiled that when creating the > mapping for the non-kernel_x part (if (kernel_x_end < end) in > map_lowmem), the unaligned section at the end leads to the freeze. In > alloc_init_pmd, if the memory end is section unaligned, alloc_init_pte > gets called which allocates a PTE outside of the initialized region (in > early_alloc_aligned). The system freezes at the call of memset in > early_alloc_aligned function. > > With some debug print, this can be better illustrated: > [ 0.000000] pgd 800063f0, addr 8fc00000, end 8fda8000, next 8fda8000 > [ 0.000000] pud 800063f0, addr 8fc00000, end 8fda8000, next 8fda8000 > [ 0.000000] pmd 800063f0, addr 8fc00000, next 8fda8000 > => actual end of memory ^^^^^^^^ > [ 0.000000] alloc_init_pte > [ 0.000000] set_pte_ext, pte 00000000, addr 8fc00000, end 8fda8000 > [ 0.000000] early_pte_alloc > [ 0.000000] early_alloc_aligned, 00001000, ptr 8fcff000, align > 00001000 > => PTE allocated outside of initialized area ^^^^^^^^ Right, and the question is why does that happen - and the answer is this: /* * Round the memblock limit down to a section size. This * helps to ensure that we will allocate memory from the * last full section, which should be mapped. */ if (memblock_limit) memblock_limit = round_down(memblock_limit, SECTION_SIZE); That should round down by 2x SECTION_SIZE to ensure that we don't start allocating the L2 page table in a section which isn't mapped. Please try this patch: arch/arm/mm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 4e6ef896c619..387becac5c86 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1142,7 +1142,7 @@ void __init sanity_check_meminfo(void) * last full section, which should be mapped. */ if (memblock_limit) - memblock_limit = round_down(memblock_limit, SECTION_SIZE); + memblock_limit = round_down(memblock_limit, 2 * SECTION_SIZE); if (!memblock_limit) memblock_limit = arm_lowmem_limit;