Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752760AbaJTHl2 (ORCPT ); Mon, 20 Oct 2014 03:41:28 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:13612 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556AbaJTHlY (ORCPT ); Mon, 20 Oct 2014 03:41:24 -0400 X-AuditID: cbfee691-f79b86d000004a5a-70-5444bc91fbc0 From: Pintu Kumar To: akpm@linux-foundation.org, hannes@cmpxchg.org, riel@redhat.com, mgorman@suse.de, vdavydov@parallels.com, nasa4836@gmail.com, ddstreet@ieee.org, m.szyprowski@samsung.com, pintu.k@samsung.com, mina86@mina86.com, iamjoonsoo.kim@lge.com, aneesh.kumar@linux.vnet.ibm.com, lauraa@codeaurora.org, gioh.kim@lge.com, rientjes@google.com, vbabka@suse.cz, sasha.levin@oracle.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: cpgs@samsung.com, pintu_agarwal@yahoo.com, vishnu.ps@samsung.com, rohit.kr@samsung.com, ed.savinay@samsung.com Subject: [PATCH] mm: cma: split cma-reserved in dmesg log Date: Mon, 20 Oct 2014 13:03:10 +0530 Message-id: <1413790391-31686-1-git-send-email-pintu.k@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0hTYRjHe3fOzo7S4LS0XhVDzIqkLC/TV7SIFHm/WEHiB/ugax1UvLJN SfSDZa1mOqYz0hIbXsj7dFpahukUVEwypqUOzTJn5q3rVGarudG338P/z///wPPQhGCMdKeT 02WsJF2U6k05k80uQbknS15Gxpz+KPdFldpmCi2sVJFoWX8cjct7SFTdo+Eg081fADXpolHD vQIKdSnKecjwopJCc81/uahlcJaH1OsmgDRDt7hI/kZFIeXmAA+Z14w89GdCSyJ5bTsHLRXc JlHNoJFAj24oATI8rSBQmXIWnIN4YHWDwAZlMQc/fzjLwxpdFl5U9XOw7kcpDxeuTXDwcL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M0kLCGMePsxk2MBbckK248+sPYwPhapIuRk0NCwERi3rMlrBC2 mMSFe+vZuhi5OIQEFjFKTD0+gxHC6WGSaP/8gxGkik1AXeLHm99gCRGB9cwS65f+YANJMAuU SDy/fQTMFhawlGi7fRDMZhFQlXj8+x/YCl4BZ4kJJzcA2RxA6xQk5kyymcDIvYCRYRWjaGpB ckFxUnquoV5xYm5xaV66XnJ+7iZGcKJ4JrWDcWWDxSFGAQ5GJR7eHWYuIUKsiWXFlbmHGCU4 mJVEeP9lAIV4UxIrq1KL8uOLSnNSiw8xmgItn8gsJZqcD0xieSXxhsYm5qbGppYmFiZmlkri vAdarQOFBNITS1KzU1MLUotg+pg4OKUaGKWq/N4cfZ+3hqHy5etVM3WO+99rk2lnKtEt9PlS 9GVGVajzwUpFz3dud5PXT/Drn/2urCRbfuWiK+avG7aYv3zXZ/x15u1pIaolW/Z/Mj/afLdr YfXxyivROsI1a44/Dyj59kHguljTPUYHybU1gRx9XsncXm1bzXuZ7LlUrlWx/dV/eTolQoml OCPRUIu5qDgRAGztki0qAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 substracting the CMA reserved memory from the total reserved memory in dmesg logs. Below is the dmesg snaphot 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 --- include/linux/swap.h | 3 +++ mm/cma.c | 2 ++ mm/page_alloc.c | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/include/linux/swap.h b/include/linux/swap.h index 37a585b..beb84be 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -295,6 +295,9 @@ static inline void workingset_node_shadows_dec(struct radix_tree_node *node) /* linux/mm/page_alloc.c */ extern unsigned long totalram_pages; extern unsigned long totalreserve_pages; +#ifdef CONFIG_CMA +extern unsigned long totalcma_pages; +#endif extern unsigned long dirty_balance_reserve; extern unsigned long nr_free_buffer_pages(void); extern unsigned long nr_free_pagecache_pages(void); diff --git a/mm/cma.c b/mm/cma.c index 963bc4a..73fe7be 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -45,6 +45,7 @@ struct cma { static struct cma cma_areas[MAX_CMA_AREAS]; static unsigned cma_area_count; static DEFINE_MUTEX(cma_mutex); +unsigned long totalcma_pages __read_mostly; phys_addr_t cma_get_base(struct cma *cma) { @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base, if (ret) goto err; + totalcma_pages += (size / PAGE_SIZE); pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M, (unsigned long)base); return 0; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index dd73f9a..c6165ac 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str) pr_info("Memory: %luK/%luK available " "(%luK kernel code, %luK rwdata, %luK rodata, " "%luK init, %luK bss, %luK reserved" +#ifdef CONFIG_CMA + ", %luK cma-reserved" +#endif #ifdef CONFIG_HIGHMEM ", %luK highmem" #endif @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str) 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, +#ifdef CONFIG_CMA + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10), + totalcma_pages << (PAGE_SHIFT-10), +#else (physpages - totalram_pages) << (PAGE_SHIFT-10), +#endif #ifdef CONFIG_HIGHMEM totalhigh_pages << (PAGE_SHIFT-10), #endif -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/