From patchwork Fri May 27 12:31:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankita Garg X-Patchwork-Id: 824152 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 p4RD3oQL010722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 27 May 2011 13:04:12 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPwEq-0006aZ-KA; Fri, 27 May 2011 12:34:26 +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 1QPwEV-0002RC-M9; Fri, 27 May 2011 12:33:39 +0000 Received: from e28smtp04.in.ibm.com ([122.248.162.4]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPwD1-0002Ja-6U for linux-arm-kernel@lists.infradead.org; Fri, 27 May 2011 12:32:15 +0000 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp04.in.ibm.com (8.14.4/8.13.1) with ESMTP id p4RCVtYK010799 for ; Fri, 27 May 2011 18:01:55 +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 p4RCVt0T4354198 for ; Fri, 27 May 2011 18:01:55 +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 p4RCVq0o003624 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 p4RCVqo4003574; 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 05/10] mm: Create zonelists Date: Fri, 27 May 2011 18:01:33 +0530 Message-Id: <1306499498-14263-6-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_083207_989417_05DEA17B X-CRM114-Status: GOOD ( 16.88 ) 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.4 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 13:04:15 +0000 (UTC) The default zonelist that is node ordered contains all zones from within a node and then all zones from the next node and so on. By introducing memory regions, the primary aim is to group memory allocations to a given area of memory together. The modified zonelists thus contain all zones from one region, followed by all zones from the next region and so on. This ensures that all the memory in one region is allocated before going over to the next region, unless targetted memory allocations are performed. Signed-off-by: Ankita Garg --- mm/page_alloc.c | 62 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 38 insertions(+), 24 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3c48635..da8b045 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2668,20 +2668,26 @@ static int build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, int nr_zones, enum zone_type zone_type) { struct zone *zone; + int nid = pgdat->node_id; + int i; + enum zone_type z_type = zone_type; BUG_ON(zone_type >= MAX_NR_ZONES); zone_type++; - do { - zone_type--; - zone = pgdat->node_zones + zone_type; - if (populated_zone(zone)) { - zoneref_set_zone(zone, - &zonelist->_zonerefs[nr_zones++]); - check_highest_zone(zone_type); - } - - } while (zone_type); + for_each_mem_region_in_nid(i, nid) { + mem_region_t *mem_region = &pgdat->mem_regions[i]; + do { + zone_type--; + zone = mem_region->zones + zone_type; + if (populated_zone(zone)) { + zoneref_set_zone(zone, + &zonelist->_zonerefs[nr_zones++]); + check_highest_zone(zone_type); + } + } while (zone_type); + zone_type = z_type + 1; + } return nr_zones; } @@ -2898,7 +2904,7 @@ static int node_order[MAX_NUMNODES]; static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes) { - int pos, j, node; + int pos, j, node, p; int zone_type; /* needs to be signed */ struct zone *z; struct zonelist *zonelist; @@ -2922,7 +2928,7 @@ static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes) static int default_zonelist_order(void) { - int nid, zone_type; + int nid, zone_type, i; unsigned long low_kmem_size,total_size; struct zone *z; int average_size; @@ -2937,12 +2943,16 @@ static int default_zonelist_order(void) total_size = 0; for_each_online_node(nid) { for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) { - z = &NODE_DATA(nid)->node_zones[zone_type]; - if (populated_zone(z)) { - if (zone_type < ZONE_NORMAL) - low_kmem_size += z->present_pages; - total_size += z->present_pages; - } else if (zone_type == ZONE_NORMAL) { + for_each_mem_region_in_nid(i, nid) { + mem_region_t *mem_region = &(NODE_DATA(nid)->mem_regions[i]); + z = &mem_region->zones[zone_type]; + if (populated_zone(z)) { + if (zone_type < ZONE_NORMAL) + low_kmem_size += + z->present_pages; + + total_size += z->present_pages; + } else if (zone_type == ZONE_NORMAL) { /* * If any node has only lowmem, then node order * is preferred to allow kernel allocations @@ -2950,7 +2960,8 @@ static int default_zonelist_order(void) * on other nodes when there is an abundance of * lowmem available to allocate from. */ - return ZONELIST_ORDER_NODE; + return ZONELIST_ORDER_NODE; + } } } } @@ -2968,11 +2979,14 @@ static int default_zonelist_order(void) low_kmem_size = 0; total_size = 0; for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) { - z = &NODE_DATA(nid)->node_zones[zone_type]; - if (populated_zone(z)) { - if (zone_type < ZONE_NORMAL) - low_kmem_size += z->present_pages; - total_size += z->present_pages; + for_each_mem_region_in_nid(i, nid) { + mem_region_t *mem_region = &(NODE_DATA(nid)->mem_regions[i]); + z = &mem_region->zones[zone_type]; + if (populated_zone(z)) { + if (zone_type < ZONE_NORMAL) + low_kmem_size += z->present_pages; + total_size += z->present_pages; + } } } if (low_kmem_size &&