From patchwork Thu Jun 13 02:13:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2713151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C847F9F4BB for ; Thu, 13 Jun 2013 02:14:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA8FF20207 for ; Thu, 13 Jun 2013 02:14:05 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0EDC20204 for ; Thu, 13 Jun 2013 02:14:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Umx2z-0006Zx-Q7; Thu, 13 Jun 2013 02:13:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Umx2w-0005pz-Ox; Thu, 13 Jun 2013 02:13:54 +0000 Received: from mail-ye0-f202.google.com ([209.85.213.202]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Umx2t-0005p7-3t for linux-arm-kernel@lists.infradead.org; Thu, 13 Jun 2013 02:13:52 +0000 Received: by mail-ye0-f202.google.com with SMTP id r11so947934yen.5 for ; Wed, 12 Jun 2013 19:13:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=jJGl8CRUpNN4Cq5kFHU5b+UNYwPxFlL4AOZnSRs0kmo=; b=Vfueh9IhQA9bHuZ2h2cQkV3S2ZNqU8RKovFBkrQ9eNUyLC8uy63om/P+W1dFWyMIBJ AxpYZq5EzZJxJlbru4N+VLKGhmhWbTMY8WvkSwY0FrXncLiAZqvtEEc3hZwgu4cObl2h 0nNcW6npeeLuqHQwiSsKpel6Kc3kwL+MrMH21/zQ8ufpxzETr8wjE9BklMBjDUEsWTk8 sS8Hjhs6fyBO7WCmBc59aGSAyX7xxG4o/6xVenJEBau1FH0dH+W5B5g9ZjQQw9UUPIPe O2bnU41KTDGInYwVD87dX4L9rLrlhhmzBwcYhWTjooogJJnX4EZn3arVsw8jHEswafA/ kL9w== X-Received: by 10.236.110.168 with SMTP id u28mr11583034yhg.32.1371089607146; Wed, 12 Jun 2013 19:13:27 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id b23si1242863yhj.4.2013.06.12.19.13.27 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 12 Jun 2013 19:13:27 -0700 (PDT) Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.120.100]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 038FC31C034; Wed, 12 Jun 2013 19:13:27 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 90CA6160A23; Wed, 12 Jun 2013 19:13:26 -0700 (PDT) From: Colin Cross To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: convert max_pfn and max_low_pfn to be relative to PFN0 Date: Wed, 12 Jun 2013 19:13:23 -0700 Message-Id: <1371089603-22601-1-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.8.3 X-Gm-Message-State: ALoCoQn02JP+mGGT8mdaivE8KDVWjyeqEWPNAubbDsUPQTiQEXjAkVBiQ89f0YfBBuDK+aBocIi1VJTfMK05CVnszOmfAZIO5s0SMMyxLJnfWs3FT6X6oYe3f/nizWKQzgSkfzQEkVNfiWrUfo+NXvyC9gX7sztUkwRd3qOfI9oVc2po6UJLImGJcmjXfreEFWv/vc4Kp5K/CNSR7HkYE6rqj1AXFdUjIg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130612_221351_220108_5AE323A1 X-CRM114-Status: GOOD ( 16.99 ) X-Spam-Score: -2.8 (--) Cc: Russell King , open list , Colin Cross 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 ARM max_pfn and max_low_pfn have always been relative to the first valid PFN, apparently due to ancient kernels being unable to properly handle physical memory at addresses other than 0. A comment was added: Note: max_low_pfn and max_pfn reflect the number of _pages_ in the system, not the maximum PFN. which conflicts with the comment in include/linux/bootmem.h that says max_pfn is the highest page. Since then, the number of users of max_pfn has proliferated, and they all seem to assume that max_pfn is the highest valid pfn. The only user of max_low_pfn as a number of pfns instead of the highest pfn is kcore, which conflates max_low_pfn with the size of low memory, but it is not supported on ARM. Remove the PHYS_PFN_OFFSET subtraction from max_pfn and max_low_pfn, and fix up the rest of ARM mm init that adds it back again. This fixes reading page map counts and flags from /proc/kpagecount and /proc/kpageflags, which will return a short read when reading pfns that overlap with max_pfn, and return 0 when reading pfn max_pfn, making it impossible to read the flags and count for pfn max_pfn. From code inspection, I believe this will also improve block device performance where the bounce limit was set to BLK_BOUNCE_HIGH, which was bouncing unnecessarily for the top PHYS_PFN_OFFSET pages of low memory. Signed-off-by: Colin Cross --- arch/arm/mm/init.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) Boot tested on 3.4 and filled up all of memory without any issues. diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 9a5cdc0..b4e4051 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -415,16 +415,8 @@ void __init bootmem_init(void) */ arm_bootmem_free(min, max_low, max_high); - /* - * This doesn't seem to be used by the Linux memory manager any - * more, but is used by ll_rw_block. If we can get rid of it, we - * also get rid of some of the stuff above as well. - * - * Note: max_low_pfn and max_pfn reflect the number of _pages_ in - * the system, not the maximum PFN. - */ - max_low_pfn = max_low - PHYS_PFN_OFFSET; - max_pfn = max_high - PHYS_PFN_OFFSET; + max_low_pfn = max_low; + max_pfn = max_high; } /* @@ -530,7 +522,6 @@ static inline void free_area_high(unsigned long pfn, unsigned long end) static void __init free_highpages(void) { #ifdef CONFIG_HIGHMEM - unsigned long max_low = max_low_pfn + PHYS_PFN_OFFSET; struct memblock_region *mem, *res; /* set highmem page free */ @@ -539,12 +530,12 @@ static void __init free_highpages(void) unsigned long end = memblock_region_memory_end_pfn(mem); /* Ignore complete lowmem entries */ - if (end <= max_low) + if (end <= max_low_pfn) continue; /* Truncate partial highmem entries */ - if (start < max_low) - start = max_low; + if (start < max_low_pfn) + start = max_low_pfn; /* Find and exclude any reserved regions */ for_each_memblock(reserved, res) { @@ -591,7 +582,7 @@ void __init mem_init(void) extern u32 itcm_end; #endif - max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; + max_mapnr = pfn_to_page(max_pfn) - mem_map; /* this will put all unused low memory onto the freelists */ free_unused_memmap(&meminfo);