diff options
-rw-r--r-- | include/linux/mempolicy.h | 4 | ||||
-rw-r--r-- | mm/mempolicy.c | 11 | ||||
-rw-r--r-- | mm/page_alloc.c | 27 |
3 files changed, 27 insertions, 15 deletions
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 72440f0a443..09f0f575ddf 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h | |||
@@ -162,9 +162,9 @@ extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, | |||
162 | unsigned long addr); | 162 | unsigned long addr); |
163 | extern unsigned slab_node(struct mempolicy *policy); | 163 | extern unsigned slab_node(struct mempolicy *policy); |
164 | 164 | ||
165 | extern int policy_zone; | 165 | extern enum zone_type policy_zone; |
166 | 166 | ||
167 | static inline void check_highest_zone(int k) | 167 | static inline void check_highest_zone(enum zone_type k) |
168 | { | 168 | { |
169 | if (k > policy_zone) | 169 | if (k > policy_zone) |
170 | policy_zone = k; | 170 | policy_zone = k; |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 9870624d72a..7da4142ce96 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -105,7 +105,7 @@ static struct kmem_cache *sn_cache; | |||
105 | 105 | ||
106 | /* Highest zone. An specific allocation for a zone below that is not | 106 | /* Highest zone. An specific allocation for a zone below that is not |
107 | policied. */ | 107 | policied. */ |
108 | int policy_zone = ZONE_DMA; | 108 | enum zone_type policy_zone = ZONE_DMA; |
109 | 109 | ||
110 | struct mempolicy default_policy = { | 110 | struct mempolicy default_policy = { |
111 | .refcnt = ATOMIC_INIT(1), /* never free it */ | 111 | .refcnt = ATOMIC_INIT(1), /* never free it */ |
@@ -137,7 +137,8 @@ static int mpol_check_policy(int mode, nodemask_t *nodes) | |||
137 | static struct zonelist *bind_zonelist(nodemask_t *nodes) | 137 | static struct zonelist *bind_zonelist(nodemask_t *nodes) |
138 | { | 138 | { |
139 | struct zonelist *zl; | 139 | struct zonelist *zl; |
140 | int num, max, nd, k; | 140 | int num, max, nd; |
141 | enum zone_type k; | ||
141 | 142 | ||
142 | max = 1 + MAX_NR_ZONES * nodes_weight(*nodes); | 143 | max = 1 + MAX_NR_ZONES * nodes_weight(*nodes); |
143 | zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL); | 144 | zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL); |
@@ -148,12 +149,16 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes) | |||
148 | lower zones etc. Avoid empty zones because the memory allocator | 149 | lower zones etc. Avoid empty zones because the memory allocator |
149 | doesn't like them. If you implement node hot removal you | 150 | doesn't like them. If you implement node hot removal you |
150 | have to fix that. */ | 151 | have to fix that. */ |
151 | for (k = policy_zone; k >= 0; k--) { | 152 | k = policy_zone; |
153 | while (1) { | ||
152 | for_each_node_mask(nd, *nodes) { | 154 | for_each_node_mask(nd, *nodes) { |
153 | struct zone *z = &NODE_DATA(nd)->node_zones[k]; | 155 | struct zone *z = &NODE_DATA(nd)->node_zones[k]; |
154 | if (z->present_pages > 0) | 156 | if (z->present_pages > 0) |
155 | zl->zones[num++] = z; | 157 | zl->zones[num++] = z; |
156 | } | 158 | } |
159 | if (k == 0) | ||
160 | break; | ||
161 | k--; | ||
157 | } | 162 | } |
158 | zl->zones[num] = NULL; | 163 | zl->zones[num] = NULL; |
159 | return zl; | 164 | return zl; |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 25f39865e32..9c44b9a39d3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -637,7 +637,8 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, | |||
637 | */ | 637 | */ |
638 | void drain_node_pages(int nodeid) | 638 | void drain_node_pages(int nodeid) |
639 | { | 639 | { |
640 | int i, z; | 640 | int i; |
641 | enum zone_type z; | ||
641 | unsigned long flags; | 642 | unsigned long flags; |
642 | 643 | ||
643 | for (z = 0; z < MAX_NR_ZONES; z++) { | 644 | for (z = 0; z < MAX_NR_ZONES; z++) { |
@@ -1158,7 +1159,8 @@ EXPORT_SYMBOL(nr_free_pages); | |||
1158 | #ifdef CONFIG_NUMA | 1159 | #ifdef CONFIG_NUMA |
1159 | unsigned int nr_free_pages_pgdat(pg_data_t *pgdat) | 1160 | unsigned int nr_free_pages_pgdat(pg_data_t *pgdat) |
1160 | { | 1161 | { |
1161 | unsigned int i, sum = 0; | 1162 | unsigned int sum = 0; |
1163 | enum zone_type i; | ||
1162 | 1164 | ||
1163 | for (i = 0; i < MAX_NR_ZONES; i++) | 1165 | for (i = 0; i < MAX_NR_ZONES; i++) |
1164 | sum += pgdat->node_zones[i].free_pages; | 1166 | sum += pgdat->node_zones[i].free_pages; |
@@ -1358,21 +1360,22 @@ void show_free_areas(void) | |||
1358 | * Add all populated zones of a node to the zonelist. | 1360 | * Add all populated zones of a node to the zonelist. |
1359 | */ | 1361 | */ |
1360 | static int __meminit build_zonelists_node(pg_data_t *pgdat, | 1362 | static int __meminit build_zonelists_node(pg_data_t *pgdat, |
1361 | struct zonelist *zonelist, int nr_zones, int zone_type) | 1363 | struct zonelist *zonelist, int nr_zones, enum zone_type zone_type) |
1362 | { | 1364 | { |
1363 | struct zone *zone; | 1365 | struct zone *zone; |
1364 | 1366 | ||
1365 | BUG_ON(zone_type >= MAX_NR_ZONES); | 1367 | BUG_ON(zone_type >= MAX_NR_ZONES); |
1368 | zone_type++; | ||
1366 | 1369 | ||
1367 | do { | 1370 | do { |
1371 | zone_type--; | ||
1368 | zone = pgdat->node_zones + zone_type; | 1372 | zone = pgdat->node_zones + zone_type; |
1369 | if (populated_zone(zone)) { | 1373 | if (populated_zone(zone)) { |
1370 | zonelist->zones[nr_zones++] = zone; | 1374 | zonelist->zones[nr_zones++] = zone; |
1371 | check_highest_zone(zone_type); | 1375 | check_highest_zone(zone_type); |
1372 | } | 1376 | } |
1373 | zone_type--; | ||
1374 | 1377 | ||
1375 | } while (zone_type >= 0); | 1378 | } while (zone_type); |
1376 | return nr_zones; | 1379 | return nr_zones; |
1377 | } | 1380 | } |
1378 | 1381 | ||
@@ -1441,10 +1444,11 @@ static int __meminit find_next_best_node(int node, nodemask_t *used_node_mask) | |||
1441 | 1444 | ||
1442 | static void __meminit build_zonelists(pg_data_t *pgdat) | 1445 | static void __meminit build_zonelists(pg_data_t *pgdat) |
1443 | { | 1446 | { |
1444 | int i, j, k, node, local_node; | 1447 | int i, j, node, local_node; |
1445 | int prev_node, load; | 1448 | int prev_node, load; |
1446 | struct zonelist *zonelist; | 1449 | struct zonelist *zonelist; |
1447 | nodemask_t used_mask; | 1450 | nodemask_t used_mask; |
1451 | enum zone_type k; | ||
1448 | 1452 | ||
1449 | /* initialize zonelists */ | 1453 | /* initialize zonelists */ |
1450 | for (i = 0; i < GFP_ZONETYPES; i++) { | 1454 | for (i = 0; i < GFP_ZONETYPES; i++) { |
@@ -1628,7 +1632,7 @@ static void __init calculate_zone_totalpages(struct pglist_data *pgdat, | |||
1628 | unsigned long *zones_size, unsigned long *zholes_size) | 1632 | unsigned long *zones_size, unsigned long *zholes_size) |
1629 | { | 1633 | { |
1630 | unsigned long realtotalpages, totalpages = 0; | 1634 | unsigned long realtotalpages, totalpages = 0; |
1631 | int i; | 1635 | enum zone_type i; |
1632 | 1636 | ||
1633 | for (i = 0; i < MAX_NR_ZONES; i++) | 1637 | for (i = 0; i < MAX_NR_ZONES; i++) |
1634 | totalpages += zones_size[i]; | 1638 | totalpages += zones_size[i]; |
@@ -2116,7 +2120,7 @@ static void calculate_totalreserve_pages(void) | |||
2116 | { | 2120 | { |
2117 | struct pglist_data *pgdat; | 2121 | struct pglist_data *pgdat; |
2118 | unsigned long reserve_pages = 0; | 2122 | unsigned long reserve_pages = 0; |
2119 | int i, j; | 2123 | enum zone_type i, j; |
2120 | 2124 | ||
2121 | for_each_online_pgdat(pgdat) { | 2125 | for_each_online_pgdat(pgdat) { |
2122 | for (i = 0; i < MAX_NR_ZONES; i++) { | 2126 | for (i = 0; i < MAX_NR_ZONES; i++) { |
@@ -2149,7 +2153,7 @@ static void calculate_totalreserve_pages(void) | |||
2149 | static void setup_per_zone_lowmem_reserve(void) | 2153 | static void setup_per_zone_lowmem_reserve(void) |
2150 | { | 2154 | { |
2151 | struct pglist_data *pgdat; | 2155 | struct pglist_data *pgdat; |
2152 | int j, idx; | 2156 | enum zone_type j, idx; |
2153 | 2157 | ||
2154 | for_each_online_pgdat(pgdat) { | 2158 | for_each_online_pgdat(pgdat) { |
2155 | for (j = 0; j < MAX_NR_ZONES; j++) { | 2159 | for (j = 0; j < MAX_NR_ZONES; j++) { |
@@ -2158,9 +2162,12 @@ static void setup_per_zone_lowmem_reserve(void) | |||
2158 | 2162 | ||
2159 | zone->lowmem_reserve[j] = 0; | 2163 | zone->lowmem_reserve[j] = 0; |
2160 | 2164 | ||
2161 | for (idx = j-1; idx >= 0; idx--) { | 2165 | idx = j; |
2166 | while (idx) { | ||
2162 | struct zone *lower_zone; | 2167 | struct zone *lower_zone; |
2163 | 2168 | ||
2169 | idx--; | ||
2170 | |||
2164 | if (sysctl_lowmem_reserve_ratio[idx] < 1) | 2171 | if (sysctl_lowmem_reserve_ratio[idx] < 1) |
2165 | sysctl_lowmem_reserve_ratio[idx] = 1; | 2172 | sysctl_lowmem_reserve_ratio[idx] = 1; |
2166 | 2173 | ||