From patchwork Fri May 27 12:31:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankita Garg X-Patchwork-Id: 824042 Received: from bombadil.infradead.org (173-166-109-252-newengland.hfc.comcastbusiness.net [173.166.109.252]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4RCpI60008867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 27 May 2011 12:51:40 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPwE1-0006Pd-7T; Fri, 27 May 2011 12:33:10 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QPwDw-0002PG-BU; Fri, 27 May 2011 12:33:04 +0000 Received: from e28smtp08.in.ibm.com ([122.248.162.8]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPwD1-0002JY-8Z for linux-arm-kernel@lists.infradead.org; Fri, 27 May 2011 12:32:11 +0000 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp08.in.ibm.com (8.14.4/8.13.1) with ESMTP id p4RCOfen010212 for ; Fri, 27 May 2011 17:54:41 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4RCVrie4276382 for ; Fri, 27 May 2011 18:01:54 +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 p4RCVq0h003587 for ; Fri, 27 May 2011 22:31:53 +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 p4RCVqo0003574; Fri, 27 May 2011 22:31:52 +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 Subject: [PATCH 01/10] mm: Introduce the memory regions data structure Date: Fri, 27 May 2011 18:01:29 +0530 Message-Id: <1306499498-14263-2-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> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110527_083208_010722_147E90FE X-CRM114-Status: GOOD ( 16.92 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [122.248.162.8 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: svaidy@linux.vnet.ibm.com, thomas.abraham@linaro.org, ankita@in.ibm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 12:51:41 +0000 (UTC) Memory region data structure is created under a NUMA node. Each NUMA node can have multiple memory regions, depending upon the platform configuration for power management. Each memory region contains zones, which is the entity from which memory is allocated by the buddy allocator. ------------- | pg_data_t | ------------- | | ------ ------- v v ---------------- ---------------- | mem_region_t | | mem_region_t | ---------------- ---------------- ------------- | |...........| zone0 | .... v ------------- ----------------------------- | zone0 | zone1 | zone3 | ..| ----------------------------- Each memory region contains a zone array for the zones belonging to that region, in addition to other fields like node id, index of the region in the node, start pfn of the pages in that region and the number of pages spanned in the region. The zone array inside the regions is statically allocated at this point. ToDo: However, since the number of regions actually present on the system might be much smaller than the maximum allowed, dynamic bootmem allocation could be used to save memory. Signed-off-by: Ankita Garg --- include/linux/mmzone.h | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index e56f835..997a474 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -60,6 +60,7 @@ struct free_area { }; struct pglist_data; +struct mem_region_list_data; /* * zone->lock and zone->lru_lock are two of the hottest locks in the kernel. @@ -311,6 +312,7 @@ struct zone { unsigned long min_unmapped_pages; unsigned long min_slab_pages; #endif + int region; struct per_cpu_pageset __percpu *pageset; /* * free areas of different sizes @@ -399,6 +401,8 @@ struct zone { * Discontig memory support fields. */ struct pglist_data *zone_pgdat; + struct mem_region_list_data *zone_mem_region; + /* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ unsigned long zone_start_pfn; @@ -597,6 +601,19 @@ struct node_active_region { extern struct page *mem_map; #endif +typedef struct mem_region_list_data { + struct zone zones[MAX_NR_ZONES]; + int nr_zones; + + int node; + int region; + + unsigned long start_pfn; + unsigned long spanned_pages; +} mem_region_t; + +#define MAX_NR_REGIONS 16 + /* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM * (mostly NUMA machines?) to denote a higher-level memory zone than the @@ -610,7 +627,10 @@ extern struct page *mem_map; */ struct bootmem_data; typedef struct pglist_data { - struct zone node_zones[MAX_NR_ZONES]; +/* 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 */ @@ -632,6 +652,9 @@ typedef struct pglist_data { */ spinlock_t node_size_lock; #endif + mem_region_t mem_regions[MAX_NR_REGIONS]; + int nr_mem_regions; + unsigned long node_start_pfn; unsigned long node_present_pages; /* total number of physical pages */ unsigned long node_spanned_pages; /* total size of physical page