From patchwork Thu Mar 26 11:46:12 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: 6098121 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 461509F2A9 for ; Thu, 26 Mar 2015 11:53:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FC4B203B7 for ; Thu, 26 Mar 2015 11:53:12 +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 2CD83203A5 for ; Thu, 26 Mar 2015 11:53:11 +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 1Yb6IT-0000Go-8v; Thu, 26 Mar 2015 11:50:01 +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 1Yb6FV-0006so-An for linux-arm-kernel@lists.infradead.org; Thu, 26 Mar 2015 11:46:59 +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=d1l/wqV32H629lt4wFGIYmiYTdfvrZ7bF6v3LglYUYA=; b=qXhiqOvqaQYa960eBBKcvm94EXtHkr9aLJ+snwFYh54qEY8hvKSTWYuJlh0AllWaGfrJycN4bGan9b6ATfggAwGO8e9BHeLQ17eu3CWw4F555Sb/md+6klrHBLtPnYq5ewhH93UhfKgP2iwLyqlcnRBTjwPkS0ijrbJ+G6a5Uyw=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:48260) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Yb6Es-0005zv-6l; Thu, 26 Mar 2015 11:46:18 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1Yb6En-0001xJ-EK; Thu, 26 Mar 2015 11:46:13 +0000 Date: Thu, 26 Mar 2015 11:46:12 +0000 From: Russell King - ARM Linux To: Gregory Fong Subject: Re: [PATCH] ARM: print cma-reserved pages from show_mem Message-ID: <20150326114612.GD8656@n2100.arm.linux.org.uk> References: <1423092164-9145-1-git-send-email-gregory.0xf0@gmail.com> <54D40DAF.4080609@codeaurora.org> <54D534FB.1090101@codeaurora.org> <20150210113230.GJ8656@n2100.arm.linux.org.uk> 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-20150326_044657_810175_B03E63CC X-CRM114-Status: GOOD ( 35.50 ) X-Spam-Score: -0.1 (/) Cc: Florian Fainelli , Laura Abbott , Kees Cook , Nicolas Pitre , Catalin Marinas , open list , vishnu.ps@samsung.com, Johannes Weiner , Marek Szyprowski , Mel Gorman , "linux-arm-kernel@lists.infradead.org" , Yalin Wang 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 Mon, Mar 23, 2015 at 02:08:12AM -0700, Gregory Fong wrote: > Hello, > > On Tue, Feb 10, 2015 at 3:32 AM, Russell King - ARM Linux > wrote: > > On Mon, Feb 09, 2015 at 11:55:54AM -0800, Gregory Fong wrote: > >> On Fri, Feb 6, 2015 at 1:41 PM, Laura Abbott wrote: > >> > So it looks like the lib/show_mem.c does something different > >> > #ifdef CONFIG_CMA > >> > printk("%lu pages reserved\n", (reserved - totalcma_pages)); > >> > printk("%lu pages cma reserved\n", totalcma_pages); > >> > #else > >> > printk("%lu pages reserved\n", reserved); > >> > #endif > >> > > >> > > >> > No need to change the name, instead I'd say fix up arm to match what > >> > the generic showmem is doing. > >> > >> The trouble is that lib/show_mem.c and ARM's show_mem use the > >> 'reserved' variable to hold different info, which was not a problem I > >> was aiming to tackle here, and am not sure I understand what's going > >> on well enough to do so. But let's give it a shot: > >> > >> In lib/show_mem.c, reserved is calculated by iterating over all online > >> nodes, then increasing reserved by (zone->present_pages - > >> zone->managed_pages). This count includes CMA pages and so when > >> reserved pages is printed it should be 'reserved' - totalcma_pages, as > >> it currently is. > > > > So, some digging is needed into why the generic version is different. > > You have to remember that many of the algorithms for this kind of thing > > were based on the x86 implementation, so differences like this are > > probably down to ARM being annoyingly overlooked or ignored when generic > > changes happen. > > > > Revisiting this finally, it looks like this was changed by Mel about a > year and a half ago in commit c78e93630d15b5f5774213aad9bdc9f52473a89b > "mm: do not walk all of system memory during show_mem"[1], which > removes the pfn walk and gets this info from struct zone instead, > saving a lot of time. Is there any reason to not to change the ARM > show_mem to do this as well? With that, I'm not sure I understand why > there would need to be an ARM-specific implementation at all anymore, > but maybe I'm missing something. Looking at Mel's commit, I don't see a reason why we couldn't use that solution - it gets rid of walking the page array, which has been fraught in the past due to ARM having platforms which have holes in their physical memory. We could try that solution - I don't see much downside to it. Most of that information is as debug information for MM stuff anyway, and IMHO it doesn't make much sense for it to be different between architectures. Maybe we should just switch to using the generic version? 8<=== From: Russell King Subject: [PATCH] ARM: switch to use the generic show_mem() implementation Switch ARM to use the generic show_mem() implementation, which displays the statistics from the mm zone rather than walking the page arrays. Signed-off-by: Russell King Acked-by: Mel Gorman Tested-by: Gregory Fong --- arch/arm/mm/init.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 1609b022a72f..ae369c1066e6 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -86,55 +86,6 @@ static int __init parse_tag_initrd2(const struct tag *tag) __tagtable(ATAG_INITRD2, parse_tag_initrd2); -/* - * This keeps memory configuration data used by a couple memory - * initialization functions, as well as show_mem() for the skipping - * of holes in the memory map. It is populated by arm_add_memory(). - */ -void show_mem(unsigned int filter) -{ - int free = 0, total = 0, reserved = 0; - int shared = 0, cached = 0, slab = 0; - struct memblock_region *reg; - - printk("Mem-info:\n"); - show_free_areas(filter); - - for_each_memblock (memory, reg) { - unsigned int pfn1, pfn2; - struct page *page, *end; - - pfn1 = memblock_region_memory_base_pfn(reg); - pfn2 = memblock_region_memory_end_pfn(reg); - - page = pfn_to_page(pfn1); - end = pfn_to_page(pfn2 - 1) + 1; - - do { - total++; - if (PageReserved(page)) - reserved++; - else if (PageSwapCache(page)) - cached++; - else if (PageSlab(page)) - slab++; - else if (!page_count(page)) - free++; - else - shared += page_count(page) - 1; - pfn1++; - page = pfn_to_page(pfn1); - } while (pfn1 < pfn2); - } - - printk("%d pages of RAM\n", total); - printk("%d free pages\n", free); - printk("%d reserved pages\n", reserved); - printk("%d slab pages\n", slab); - printk("%d pages shared\n", shared); - printk("%d pages swap cached\n", cached); -} - static void __init find_limits(unsigned long *min, unsigned long *max_low, unsigned long *max_high) {