From patchwork Fri May 27 12:31:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankita Garg X-Patchwork-Id: 824452 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4REwulm028400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 27 May 2011 14:59:16 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p4REuuKw025931; Fri, 27 May 2011 07:56:56 -0700 Received: from e28smtp05.in.ibm.com (e28smtp05.in.ibm.com [122.248.162.5]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p4RCW14W014673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 27 May 2011 05:32:05 -0700 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp05.in.ibm.com (8.14.4/8.13.1) with ESMTP id p4RCVvKA018186 for ; Fri, 27 May 2011 18:01:57 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4RCVv384489250 for ; Fri, 27 May 2011 18:01:57 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4RCVrZg003742 for ; Fri, 27 May 2011 22:31:54 +1000 Received: from rollercoaster.ibm.com ([9.124.35.203]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4RCVqo9003574; Fri, 27 May 2011 22:31:53 +1000 From: Ankita Garg To: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org Date: Fri, 27 May 2011 18:01:38 +0530 Message-Id: <1306499498-14263-11-git-send-email-ankita@in.ibm.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1306499498-14263-1-git-send-email-ankita@in.ibm.com> References: <1306499498-14263-1-git-send-email-ankita@in.ibm.com> Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-4.662 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 X-Mailman-Approved-At: Fri, 27 May 2011 07:56:15 -0700 Cc: thomas.abraham@linaro.org, ankita@in.ibm.com Subject: [linux-pm] [PATCH 10/10] mm: Create memory regions at boot-up X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 27 May 2011 14:59:16 +0000 (UTC) Memory regions are created at boot up time, from the information obtained from the firmware. This patchset was developed on ARM platform, on which at present u-boot bootloader does not export information about memory units that can be independently power managed. For the purpose of demonstration, 2 hard coded memory regions are created, of 256MB each on the Panda board with 512MB RAM. Signed-off-by: Ankita Garg --- include/linux/mmzone.h | 8 +++----- mm/page_alloc.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index bc3e3fd..5dbe1e1 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -627,14 +627,12 @@ typedef struct mem_region_list_data { */ struct bootmem_data; typedef struct pglist_data { -/* The linkage to node_zones is now removed. The new hierarchy introduced - * is pg_data_t -> mem_region -> zones - * struct zone node_zones[MAX_NR_ZONES]; - */ struct zonelist node_zonelists[MAX_ZONELISTS]; int nr_zones; #ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */ - struct page *node_mem_map; + strs pg_data_t -> mem_region -> zones + * struct zone node_zones[MAX_NR_ZONES]; + */uct page *node_mem_map; #ifdef CONFIG_CGROUP_MEM_RES_CTLR struct page_cgroup *node_page_cgroup; #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index da8b045..3d994e8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4285,6 +4285,34 @@ static inline int pageblock_default_order(unsigned int order) #endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ +#define REGIONS_SIZE (512 << 20) >> PAGE_SHIFT + +static void init_node_memory_regions(struct pglist_data *pgdat) +{ + int cnt = 0; + unsigned long i; + unsigned long start_pfn = pgdat->node_start_pfn; + unsigned long spanned_pages = pgdat->node_spanned_pages; + unsigned long total = 0; + + for (i = start_pfn; i < start_pfn + spanned_pages; i+= REGIONS_SIZE) { + mem_region_t *mem_region = &pgdat->mem_regions[cnt]; + + mem_region->start_pfn = i; + if ((spanned_pages - total) <= REGIONS_SIZE) { + mem_region->spanned_pages = spanned_pages - total; + } + else + mem_region->spanned_pages = REGIONS_SIZE; + + mem_region->node = pgdat->node_id; + mem_region->region = cnt; + pgdat->nr_mem_regions++; + total += mem_region->spanned_pages; + cnt++; + } +} + /* * Set up the zone data structures: * - mark all pages reserved @@ -4447,6 +4475,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, (unsigned long)pgdat->node_mem_map); #endif + init_node_memory_regions(pgdat); free_area_init_core(pgdat, zones_size, zholes_size); }