Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbdHaPoO (ORCPT ); Thu, 31 Aug 2017 11:44:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36292 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751794AbdHaPoL (ORCPT ); Thu, 31 Aug 2017 11:44:11 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pintu Kumar , Vishnu Pratap Singh , Michal Nazarewicz , Rafael Aquini , Jerome Marchand , Marek Szyprowski , Joonsoo Kim , Andrew Morton , Linus Torvalds Subject: [PATCH 3.18 11/24] mm: cma: split cma-reserved in dmesg log Date: Thu, 31 Aug 2017 17:43:47 +0200 Message-Id: <20170831154105.751197878@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831154105.116844281@linuxfoundation.org> References: <20170831154105.116844281@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3381 Lines: 94 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pintu Kumar commit e48322abb061d75096fe52d71886b237e7ae7bfb upstream. When the system boots up, in the dmesg logs we can see the memory statistics along with total reserved as below. Memory: 458840k/458840k available, 65448k reserved, 0K highmem When CMA is enabled, still the total reserved memory remains the same. However, the CMA memory is not considered as reserved. But, when we see /proc/meminfo, the CMA memory is part of free memory. This creates confusion. This patch corrects the problem by properly subtracting the CMA reserved memory from the total reserved memory in dmesg logs. Below is the dmesg snapshot from an arm based device with 512MB RAM and 12MB single CMA region. Before this change: Memory: 458840k/458840k available, 65448k reserved, 0K highmem After this change: Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem Signed-off-by: Pintu Kumar Signed-off-by: Vishnu Pratap Singh Acked-by: Michal Nazarewicz Cc: Rafael Aquini Cc: Jerome Marchand Cc: Marek Szyprowski Cc: Joonsoo Kim Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/cma.h | 1 + mm/cma.c | 1 + mm/page_alloc.c | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -15,6 +15,7 @@ struct cma; +extern unsigned long totalcma_pages; extern phys_addr_t cma_get_base(struct cma *cma); extern unsigned long cma_get_size(struct cma *cma); --- a/mm/cma.c +++ b/mm/cma.c @@ -338,6 +338,7 @@ int __init cma_declare_contiguous(phys_a if (ret) goto err; + totalcma_pages += (size / PAGE_SIZE); pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M, &base); return 0; --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_coun unsigned long totalram_pages __read_mostly; unsigned long totalreserve_pages __read_mostly; +unsigned long totalcma_pages __read_mostly; /* * When calculating the number of globally allowed dirty pages, there * is a certain number of per-zone reserves that should not be @@ -5522,7 +5523,7 @@ void __init mem_init_print_info(const ch printk("Memory: %luK/%luK available " "(%luK kernel code, %luK rwdata, %luK rodata, " - "%luK init, %luK bss, %luK reserved" + "%luK init, %luK bss, %luK reserved, %luK cma-reserved" #ifdef CONFIG_HIGHMEM ", %luK highmem" #endif @@ -5530,7 +5531,8 @@ void __init mem_init_print_info(const ch nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10), codesize >> 10, datasize >> 10, rosize >> 10, (init_data_size + init_code_size) >> 10, bss_size >> 10, - (physpages - totalram_pages) << (PAGE_SHIFT-10), + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10), + totalcma_pages << (PAGE_SHIFT-10), #ifdef CONFIG_HIGHMEM totalhigh_pages << (PAGE_SHIFT-10), #endif