Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755484AbbBLHdG (ORCPT ); Thu, 12 Feb 2015 02:33:06 -0500 Received: from LGEMRELSE7Q.lge.com ([156.147.1.151]:41979 "EHLO lgemrelse7q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbbBLHaM (ORCPT ); Thu, 12 Feb 2015 02:30:12 -0500 X-Original-SENDERIP: 10.177.222.153 X-Original-MAILFROM: iamjoonsoo.kim@lge.com From: Joonsoo Kim To: Andrew Morton Cc: Rik van Riel , Johannes Weiner , Mel Gorman , Laura Abbott , Minchan Kim , Heesub Shin , Marek Szyprowski , Michal Nazarewicz , "Aneesh Kumar K.V" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hui Zhu , Gioh Kim , Bartlomiej Zolnierkiewicz , Ritesh Harjani , Vlastimil Babka , Joonsoo Kim Subject: [RFC 09/16] mm/cma: introduce cma_total_pages() for future use Date: Thu, 12 Feb 2015 16:32:13 +0900 Message-Id: <1423726340-4084-10-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1423726340-4084-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1423726340-4084-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: 2028 Lines: 70 In the following patches, total reserved page count is needed to initialize ZONE_CMA. This is the preparation step for that. Signed-off-by: Joonsoo Kim --- include/linux/cma.h | 9 +++++++++ mm/cma.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/cma.h b/include/linux/cma.h index a93438b..aeaea90 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -15,6 +15,9 @@ struct cma; +#ifdef CONFIG_CMA +extern unsigned long cma_total_pages(unsigned long node_start_pfn, + unsigned long node_end_pfn); extern phys_addr_t cma_get_base(struct cma *cma); extern unsigned long cma_get_size(struct cma *cma); @@ -27,4 +30,10 @@ extern int cma_init_reserved_mem(phys_addr_t base, struct cma **res_cma); extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align); extern bool cma_release(struct cma *cma, struct page *pages, int count); + +#else +static inline unsigned long cma_total_pages(unsigned long node_start_pfn, + unsigned long node_end_pfn) { return 0; } + +#endif /* CONFIG_CMA */ #endif diff --git a/mm/cma.c b/mm/cma.c index c35ceef..f817b91 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -40,6 +40,23 @@ struct cma cma_areas[MAX_CMA_AREAS]; unsigned cma_area_count; static DEFINE_MUTEX(cma_mutex); +unsigned long cma_total_pages(unsigned long node_start_pfn, + unsigned long node_end_pfn) +{ + int i; + unsigned long total_pages = 0; + + for (i = 0; i < cma_area_count; i++) { + struct cma *cma = &cma_areas[i]; + + if (node_start_pfn <= cma->base_pfn && + cma->base_pfn < node_end_pfn) + total_pages += cma->count; + } + + return total_pages; +} + phys_addr_t cma_get_base(struct cma *cma) { return PFN_PHYS(cma->base_pfn); -- 1.7.9.5 -- 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/