linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ankita Garg <ankita@in.ibm.com>
To: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	linux-pm@lists.linux-foundation.org
Cc: ankita@in.ibm.com, svaidy@linux.vnet.ibm.com, thomas.abraham@linaro.org
Subject: [PATCH 05/10] mm: Create zonelists
Date: Fri, 27 May 2011 18:01:33 +0530	[thread overview]
Message-ID: <1306499498-14263-6-git-send-email-ankita@in.ibm.com> (raw)
In-Reply-To: <1306499498-14263-1-git-send-email-ankita@in.ibm.com>

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 <ankita@in.ibm.com>
---
 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 &&
-- 
1.7.4


  parent reply	other threads:[~2011-05-27 12:32 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-27 12:31 [PATCH 00/10] mm: Linux VM Infrastructure to support Memory Power Management Ankita Garg
2011-05-27 12:31 ` [PATCH 01/10] mm: Introduce the memory regions data structure Ankita Garg
2011-05-27 15:30   ` Dave Hansen
2011-05-27 18:20     ` Vaidyanathan Srinivasan
2011-05-27 21:31       ` Dave Hansen
2011-05-29  8:16         ` Ankita Garg
2011-05-31 17:34           ` Dave Hansen
2011-06-02  8:54             ` Ankita Garg
2011-05-27 12:31 ` [PATCH 02/10] mm: Helper routines Ankita Garg
2011-05-27 12:31 ` [PATCH 03/10] mm: Init zones inside memory regions Ankita Garg
2011-05-27 12:31 ` [PATCH 04/10] mm: Refer to zones from " Ankita Garg
2011-05-27 12:31 ` Ankita Garg [this message]
2011-05-27 12:31 ` [PATCH 06/10] mm: Verify zonelists Ankita Garg
2011-05-27 12:31 ` [PATCH 07/10] mm: Modify vmstat Ankita Garg
2011-05-27 12:31 ` [PATCH 08/10] mm: Modify vmscan Ankita Garg
2011-05-27 12:31 ` [PATCH 09/10] mm: Reflect memory region changes in zoneinfo Ankita Garg
2011-05-27 12:31 ` [PATCH 10/10] mm: Create memory regions at boot-up Ankita Garg
2011-05-28 14:39   ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-28  7:56 ` [PATCH 00/10] mm: Linux VM Infrastructure to support Memory Power Management Andrew Morton
2011-05-28 13:16   ` Ankita Garg
2011-06-09 18:52   ` Paul E. McKenney
2011-06-10  0:51     ` Kyungmin Park
2011-06-10 15:11       ` Paul E. McKenney
2011-06-10 15:59         ` Matthew Garrett
2011-06-10 16:55           ` Paul E. McKenney
2011-06-10 17:05             ` Matthew Garrett
2011-06-10 17:19               ` Paul E. McKenney
2011-06-10 17:23                 ` Matthew Garrett
2011-06-10 17:52                   ` Paul E. McKenney
2011-06-10 18:08                     ` Matthew Garrett
2011-06-10 18:47                       ` Paul E. McKenney
2011-06-10 19:23                         ` Matthew Garrett
2011-06-10 19:37                           ` Paul E. McKenney
2011-06-10 20:12                             ` Matthew Garrett
2011-06-11  3:02                             ` Arjan van de Ven
2011-06-11 17:06                               ` Paul E. McKenney
2011-06-11 17:26                                 ` Arjan van de Ven
2011-06-12 23:07                                   ` Paul E. McKenney
2011-06-13 14:28                                     ` Arjan van de Ven
2011-06-13 23:04                                       ` Paul E. McKenney
2011-06-14  8:51                               ` Ankita Garg
2011-06-15 16:53                               ` Ankita Garg
2011-06-18  4:08                                 ` Arjan van de Ven
2011-06-10 17:33                 ` Ankita Garg
2011-06-11 17:08                   ` Paul E. McKenney
2011-07-12  5:31   ` amit kachhap
2011-06-13  4:47 ` KAMEZAWA Hiroyuki
2011-06-16  4:20   ` Ankita Garg
2011-06-16  9:12     ` KAMEZAWA Hiroyuki
2011-06-17 15:28       ` Ankita Garg
2011-06-19 23:53         ` KAMEZAWA Hiroyuki
2011-06-16 16:04     ` Dave Hansen
2011-06-17 10:03       ` Ankita Garg
2011-06-29 13:00 ` Ankita Garg
2011-06-29 17:06   ` Dave Hansen
2011-06-29 17:42     ` Ankita Garg
2011-06-29 17:59       ` Dave Hansen
2011-06-29 18:17         ` Vaidyanathan Srinivasan
2011-06-30  4:37           ` Ankita Garg
2011-06-29 20:11         ` Andi Kleen
2011-06-30  5:11           ` Ankita Garg
2011-06-29 18:07     ` Vaidyanathan Srinivasan
2011-07-06  8:45   ` Pekka Enberg
2011-07-06  9:01     ` Pekka Enberg
2011-07-06 16:50       ` Vaidyanathan Srinivasan
2011-07-06 16:41     ` Vaidyanathan Srinivasan
2011-07-06 20:20     ` david
2011-07-07  4:54       ` Ankita Garg
2011-07-07 18:00       ` Pekka Enberg
2011-07-08  1:32         ` david

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306499498-14263-6-git-send-email-ankita@in.ibm.com \
    --to=ankita@in.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=svaidy@linux.vnet.ibm.com \
    --cc=thomas.abraham@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).