From patchwork Wed Sep 25 23:14:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 2945961 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F11849F288 for ; Wed, 25 Sep 2013 23:30:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 234CB20372 for ; Wed, 25 Sep 2013 23:30:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4DE020379 for ; Wed, 25 Sep 2013 23:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754795Ab3IYXST (ORCPT ); Wed, 25 Sep 2013 19:18:19 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:56286 "EHLO e28smtp06.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754775Ab3IYXSR (ORCPT ); Wed, 25 Sep 2013 19:18:17 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Sep 2013 04:48:15 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Sep 2013 04:48:13 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 45BFDE0055; Thu, 26 Sep 2013 04:49:17 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8PNKRaO42336454; Thu, 26 Sep 2013 04:50:28 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8PNI9Xm007092; Thu, 26 Sep 2013 04:48:11 +0530 Received: from srivatsabhat.in.ibm.com ([9.79.250.85]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8PNI5KW006816; Thu, 26 Sep 2013 04:48:06 +0530 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v4 02/40] mm: Initialize node memory regions during boot To: akpm@linux-foundation.org, mgorman@suse.de, dave@sr71.net, hannes@cmpxchg.org, tony.luck@intel.com, matthew.garrett@nebula.com, riel@redhat.com, arjan@linux.intel.com, srinivas.pandruvada@linux.intel.com, willy@linux.intel.com, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, paulmck@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com, andi@firstfloor.org, isimatu.yasuaki@jp.fujitsu.com, santosh.shilimkar@ti.com, kosaki.motohiro@gmail.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 26 Sep 2013 04:44:03 +0530 Message-ID: <20130925231358.26184.34871.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130925231250.26184.31438.stgit@srivatsabhat.in.ibm.com> References: <20130925231250.26184.31438.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13092523-9574-0000-0000-000009CD095C Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Initialize the node's memory-regions structures with the information about the region-boundaries, at boot time. Based-on-patch-by: Ankita Garg Signed-off-by: Srivatsa S. Bhat --- include/linux/mm.h | 4 ++++ mm/page_alloc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/mm.h b/include/linux/mm.h index 8b6e55e..223be46 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -620,6 +620,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) #define LAST_NID_MASK ((1UL << LAST_NID_WIDTH) - 1) #define ZONEID_MASK ((1UL << ZONEID_SHIFT) - 1) +/* Hard-code memory region size to be 512 MB for now. */ +#define MEM_REGION_SHIFT (29 - PAGE_SHIFT) +#define MEM_REGION_SIZE (1UL << MEM_REGION_SHIFT) + static inline enum zone_type page_zonenum(const struct page *page) { return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0ee638f..26835c4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4858,6 +4858,33 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat) #endif /* CONFIG_FLAT_NODE_MEM_MAP */ } +static void __meminit init_node_memory_regions(struct pglist_data *pgdat) +{ + int nid = pgdat->node_id; + unsigned long start_pfn = pgdat->node_start_pfn; + unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; + struct node_mem_region *region; + unsigned long i, absent; + int idx; + + for (i = start_pfn, idx = 0; i < end_pfn; + i += region->spanned_pages, idx++) { + + region = &pgdat->node_regions[idx]; + region->pgdat = pgdat; + region->start_pfn = i; + region->spanned_pages = min(MEM_REGION_SIZE, end_pfn - i); + region->end_pfn = region->start_pfn + region->spanned_pages; + + absent = __absent_pages_in_range(nid, region->start_pfn, + region->end_pfn); + + region->present_pages = region->spanned_pages - absent; + } + + pgdat->nr_node_regions = idx; +} + void __paginginit free_area_init_node(int nid, unsigned long *zones_size, unsigned long node_start_pfn, unsigned long *zholes_size) { @@ -4886,6 +4913,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, free_area_init_core(pgdat, start_pfn, end_pfn, zones_size, zholes_size); + init_node_memory_regions(pgdat); } #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP