From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755410AbbGTWsS (ORCPT ); Mon, 20 Jul 2015 18:48:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41502 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbbGTWsR (ORCPT ); Mon, 20 Jul 2015 18:48:17 -0400 Date: Mon, 20 Jul 2015 15:48:16 -0700 From: Andrew Morton To: Vishnu Pratap Singh Cc: linux@rasmusvillemoes.dk, riel@redhat.com, isimatu.yasuaki@jp.fujitsu.com, aquini@redhat.com, linux-kernel@vger.kernel.org, cpgs@samsung.com, vishu13285@gmail.com, pintu.k@samsung.com, rohit.kr@samsung.com Subject: Re: [PATCH] lib/show_mem.c: correct reserved memory calculation Message-Id: <20150720154816.685e70f38e6d0238e3efef91@linux-foundation.org> In-Reply-To: <1437383665-29874-1-git-send-email-vishnu.ps@samsung.com> References: <1437383665-29874-1-git-send-email-vishnu.ps@samsung.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Jul 2015 14:44:25 +0530 Vishnu Pratap Singh wrote: > CMA reserved memory is not part of total reserved memory. > Currently when we print the total reserve memory it considers > cma as part of reserve memory and do minus of totalcma_pages > from reserved, which is wrong. In cases where total reserved > is less than cma reserved we will get negative values & while > printing we print as unsigned and we will get a very large value. > > Below is the show mem output on X86 ubuntu based system where > CMA reserved is 100MB (25600 pages) & total reserved is ~40MB(10316 pages). > And reserve memory shows a large value because of this bug. > > Before: > [ 127.066430] 898908 pages RAM > [ 127.066432] 671682 pages HighMem/MovableOnly > [ 127.066434] 4294952012 pages reserved > [ 127.066436] 25600 pages cma reserved > > After: > [ 44.663129] 898908 pages RAM > [ 44.663130] 671682 pages HighMem/MovableOnly > [ 44.663130] 10316 pages reserved > [ 44.663131] 25600 pages cma reserved > > Also this patch change printk to pr_info. The pr_info change was irritating - it makes it quite hard to see the functional change. Please don't mix changes like this, unless the unrelated changes are trivial and don't hamper review. This is what the patch actually does: --- a/lib/show_mem.c~lib-show_memc-correct-reserved-memory-calculation +++ a/lib/show_mem.c @@ -38,11 +38,9 @@ void show_mem(unsigned int filter) printk("%lu pages RAM\n", total); printk("%lu pages HighMem/MovableOnly\n", highmem); + printk("%lu pages reserved\n", reserved); #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 #ifdef CONFIG_QUICKLIST printk("%lu pages in pagetable cache\n", _