Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753488AbdDKDSf (ORCPT ); Mon, 10 Apr 2017 23:18:35 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36382 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbdDKDSD (ORCPT ); Mon, 10 Apr 2017 23:18:03 -0400 From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: Rik van Riel , Johannes Weiner , mgorman@techsingularity.net, Laura Abbott , Minchan Kim , Marek Szyprowski , Michal Nazarewicz , "Aneesh Kumar K . V" , Vlastimil Babka , Russell King , Will Deacon , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Joonsoo Kim Subject: [PATCH v7 6/7] mm/cma: remove per zone CMA stat Date: Tue, 11 Apr 2017 12:17:19 +0900 Message-Id: <1491880640-9944-7-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491880640-9944-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1491880640-9944-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4136 Lines: 137 From: Joonsoo Kim Now, all reserved pages for CMA region are belong to the ZONE_CMA so we don't need to maintain CMA stat in other zones. Remove it. Reviewed-by: Aneesh Kumar K.V Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- fs/proc/meminfo.c | 2 +- include/linux/cma.h | 7 +++++++ include/linux/mmzone.h | 1 - mm/cma.c | 15 +++++++++++++++ mm/page_alloc.c | 7 +++---- mm/vmstat.c | 1 - 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 8a42849..0ca6f38 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -151,7 +151,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) #ifdef CONFIG_CMA show_val_kb(m, "CmaTotal: ", totalcma_pages); show_val_kb(m, "CmaFree: ", - global_page_state(NR_FREE_CMA_PAGES)); + cma_get_free()); #endif hugetlb_report_meminfo(m); diff --git a/include/linux/cma.h b/include/linux/cma.h index 03f32d0..2433d5e 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -32,4 +32,11 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, gfp_t gfp_mask); extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); + +#ifdef CONFIG_CMA +extern unsigned long cma_get_free(void); +#else +static inline unsigned long cma_get_free(void) { return 0; } +#endif + #endif diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index efb69b1..5e1d8ba 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -118,7 +118,6 @@ enum zone_stat_item { NUMA_LOCAL, /* allocation from local node */ NUMA_OTHER, /* allocation from other node */ #endif - NR_FREE_CMA_PAGES, NR_VM_ZONE_STAT_ITEMS }; enum node_stat_item { diff --git a/mm/cma.c b/mm/cma.c index 91dd85a..adfda1c 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -54,6 +54,21 @@ unsigned long cma_get_size(const struct cma *cma) return cma->count << PAGE_SHIFT; } +unsigned long cma_get_free(void) +{ + struct zone *zone; + unsigned long freecma = 0; + + for_each_populated_zone(zone) { + if (!is_zone_cma(zone)) + continue; + + freecma += zone_page_state(zone, NR_FREE_PAGES); + } + + return freecma; +} + static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, int align_order) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 33a1b69..7d61469 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -4502,7 +4503,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) global_page_state(NR_BOUNCE), global_page_state(NR_FREE_PAGES), free_pcp, - global_page_state(NR_FREE_CMA_PAGES)); + cma_get_free()); for_each_online_pgdat(pgdat) { if (show_mem_node_skip(filter, pgdat->node_id, nodemask)) @@ -4586,7 +4587,6 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) " bounce:%lukB" " free_pcp:%lukB" " local_pcp:%ukB" - " free_cma:%lukB" "\n", zone->name, K(zone_page_state(zone, NR_FREE_PAGES)), @@ -4608,8 +4608,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) K(zone_page_state(zone, NR_PAGETABLE)), K(zone_page_state(zone, NR_BOUNCE)), K(free_pcp), - K(this_cpu_read(zone->pageset->pcp.count)), - K(zone_page_state(zone, NR_FREE_CMA_PAGES))); + K(this_cpu_read(zone->pageset->pcp.count))); printk("lowmem_reserve[]:"); for (i = 0; i < MAX_NR_ZONES; i++) printk(KERN_CONT " %ld", zone->lowmem_reserve[i]); diff --git a/mm/vmstat.c b/mm/vmstat.c index 3c3aac2..9467b56 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -951,7 +951,6 @@ const char * const vmstat_text[] = { "numa_local", "numa_other", #endif - "nr_free_cma", /* Node-based counters */ "nr_inactive_anon", -- 2.7.4