diff options
-rw-r--r-- | include/linux/mmzone.h | 8 | ||||
-rw-r--r-- | kernel/power/snapshot.c | 9 | ||||
-rw-r--r-- | kernel/power/swsusp.c | 17 | ||||
-rw-r--r-- | mm/page_alloc.c | 26 | ||||
-rw-r--r-- | mm/vmscan.c | 4 | ||||
-rw-r--r-- | mm/vmstat.c | 11 |
6 files changed, 27 insertions, 48 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1aca6cebbb78..26ef24076b76 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -806,6 +806,14 @@ extern struct zone *next_zone(struct zone *zone); | |||
806 | zone; \ | 806 | zone; \ |
807 | zone = next_zone(zone)) | 807 | zone = next_zone(zone)) |
808 | 808 | ||
809 | #define for_each_populated_zone(zone) \ | ||
810 | for (zone = (first_online_pgdat())->node_zones; \ | ||
811 | zone; \ | ||
812 | zone = next_zone(zone)) \ | ||
813 | if (!populated_zone(zone)) \ | ||
814 | ; /* do nothing */ \ | ||
815 | else | ||
816 | |||
809 | static inline struct zone *zonelist_zone(struct zoneref *zoneref) | 817 | static inline struct zone *zonelist_zone(struct zoneref *zoneref) |
810 | { | 818 | { |
811 | return zoneref->zone; | 819 | return zoneref->zone; |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index f5fc2d7680f2..33e2e4a819f9 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -321,13 +321,10 @@ static int create_mem_extents(struct list_head *list, gfp_t gfp_mask) | |||
321 | 321 | ||
322 | INIT_LIST_HEAD(list); | 322 | INIT_LIST_HEAD(list); |
323 | 323 | ||
324 | for_each_zone(zone) { | 324 | for_each_populated_zone(zone) { |
325 | unsigned long zone_start, zone_end; | 325 | unsigned long zone_start, zone_end; |
326 | struct mem_extent *ext, *cur, *aux; | 326 | struct mem_extent *ext, *cur, *aux; |
327 | 327 | ||
328 | if (!populated_zone(zone)) | ||
329 | continue; | ||
330 | |||
331 | zone_start = zone->zone_start_pfn; | 328 | zone_start = zone->zone_start_pfn; |
332 | zone_end = zone->zone_start_pfn + zone->spanned_pages; | 329 | zone_end = zone->zone_start_pfn + zone->spanned_pages; |
333 | 330 | ||
@@ -804,8 +801,8 @@ static unsigned int count_free_highmem_pages(void) | |||
804 | struct zone *zone; | 801 | struct zone *zone; |
805 | unsigned int cnt = 0; | 802 | unsigned int cnt = 0; |
806 | 803 | ||
807 | for_each_zone(zone) | 804 | for_each_populated_zone(zone) |
808 | if (populated_zone(zone) && is_highmem(zone)) | 805 | if (is_highmem(zone)) |
809 | cnt += zone_page_state(zone, NR_FREE_PAGES); | 806 | cnt += zone_page_state(zone, NR_FREE_PAGES); |
810 | 807 | ||
811 | return cnt; | 808 | return cnt; |
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index a92c91451559..1ee6636414b2 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c | |||
@@ -229,17 +229,16 @@ int swsusp_shrink_memory(void) | |||
229 | size = count_data_pages() + PAGES_FOR_IO + SPARE_PAGES; | 229 | size = count_data_pages() + PAGES_FOR_IO + SPARE_PAGES; |
230 | tmp = size; | 230 | tmp = size; |
231 | size += highmem_size; | 231 | size += highmem_size; |
232 | for_each_zone (zone) | 232 | for_each_populated_zone(zone) { |
233 | if (populated_zone(zone)) { | 233 | tmp += snapshot_additional_pages(zone); |
234 | tmp += snapshot_additional_pages(zone); | 234 | if (is_highmem(zone)) { |
235 | if (is_highmem(zone)) { | 235 | highmem_size -= |
236 | highmem_size -= | ||
237 | zone_page_state(zone, NR_FREE_PAGES); | 236 | zone_page_state(zone, NR_FREE_PAGES); |
238 | } else { | 237 | } else { |
239 | tmp -= zone_page_state(zone, NR_FREE_PAGES); | 238 | tmp -= zone_page_state(zone, NR_FREE_PAGES); |
240 | tmp += zone->lowmem_reserve[ZONE_NORMAL]; | 239 | tmp += zone->lowmem_reserve[ZONE_NORMAL]; |
241 | } | ||
242 | } | 240 | } |
241 | } | ||
243 | 242 | ||
244 | if (highmem_size < 0) | 243 | if (highmem_size < 0) |
245 | highmem_size = 0; | 244 | highmem_size = 0; |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a3803ea8c27d..cbd532161f68 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -922,13 +922,10 @@ static void drain_pages(unsigned int cpu) | |||
922 | unsigned long flags; | 922 | unsigned long flags; |
923 | struct zone *zone; | 923 | struct zone *zone; |
924 | 924 | ||
925 | for_each_zone(zone) { | 925 | for_each_populated_zone(zone) { |
926 | struct per_cpu_pageset *pset; | 926 | struct per_cpu_pageset *pset; |
927 | struct per_cpu_pages *pcp; | 927 | struct per_cpu_pages *pcp; |
928 | 928 | ||
929 | if (!populated_zone(zone)) | ||
930 | continue; | ||
931 | |||
932 | pset = zone_pcp(zone, cpu); | 929 | pset = zone_pcp(zone, cpu); |
933 | 930 | ||
934 | pcp = &pset->pcp; | 931 | pcp = &pset->pcp; |
@@ -1879,10 +1876,7 @@ void show_free_areas(void) | |||
1879 | int cpu; | 1876 | int cpu; |
1880 | struct zone *zone; | 1877 | struct zone *zone; |
1881 | 1878 | ||
1882 | for_each_zone(zone) { | 1879 | for_each_populated_zone(zone) { |
1883 | if (!populated_zone(zone)) | ||
1884 | continue; | ||
1885 | |||
1886 | show_node(zone); | 1880 | show_node(zone); |
1887 | printk("%s per-cpu:\n", zone->name); | 1881 | printk("%s per-cpu:\n", zone->name); |
1888 | 1882 | ||
@@ -1922,12 +1916,9 @@ void show_free_areas(void) | |||
1922 | global_page_state(NR_PAGETABLE), | 1916 | global_page_state(NR_PAGETABLE), |
1923 | global_page_state(NR_BOUNCE)); | 1917 | global_page_state(NR_BOUNCE)); |
1924 | 1918 | ||
1925 | for_each_zone(zone) { | 1919 | for_each_populated_zone(zone) { |
1926 | int i; | 1920 | int i; |
1927 | 1921 | ||
1928 | if (!populated_zone(zone)) | ||
1929 | continue; | ||
1930 | |||
1931 | show_node(zone); | 1922 | show_node(zone); |
1932 | printk("%s" | 1923 | printk("%s" |
1933 | " free:%lukB" | 1924 | " free:%lukB" |
@@ -1967,12 +1958,9 @@ void show_free_areas(void) | |||
1967 | printk("\n"); | 1958 | printk("\n"); |
1968 | } | 1959 | } |
1969 | 1960 | ||
1970 | for_each_zone(zone) { | 1961 | for_each_populated_zone(zone) { |
1971 | unsigned long nr[MAX_ORDER], flags, order, total = 0; | 1962 | unsigned long nr[MAX_ORDER], flags, order, total = 0; |
1972 | 1963 | ||
1973 | if (!populated_zone(zone)) | ||
1974 | continue; | ||
1975 | |||
1976 | show_node(zone); | 1964 | show_node(zone); |
1977 | printk("%s: ", zone->name); | 1965 | printk("%s: ", zone->name); |
1978 | 1966 | ||
@@ -2784,11 +2772,7 @@ static int __cpuinit process_zones(int cpu) | |||
2784 | 2772 | ||
2785 | node_set_state(node, N_CPU); /* this node has a cpu */ | 2773 | node_set_state(node, N_CPU); /* this node has a cpu */ |
2786 | 2774 | ||
2787 | for_each_zone(zone) { | 2775 | for_each_populated_zone(zone) { |
2788 | |||
2789 | if (!populated_zone(zone)) | ||
2790 | continue; | ||
2791 | |||
2792 | zone_pcp(zone, cpu) = kmalloc_node(sizeof(struct per_cpu_pageset), | 2776 | zone_pcp(zone, cpu) = kmalloc_node(sizeof(struct per_cpu_pageset), |
2793 | GFP_KERNEL, node); | 2777 | GFP_KERNEL, node); |
2794 | if (!zone_pcp(zone, cpu)) | 2778 | if (!zone_pcp(zone, cpu)) |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 1bca60f0c527..301f057fd115 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2061,11 +2061,9 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio, | |||
2061 | struct zone *zone; | 2061 | struct zone *zone; |
2062 | unsigned long ret = 0; | 2062 | unsigned long ret = 0; |
2063 | 2063 | ||
2064 | for_each_zone(zone) { | 2064 | for_each_populated_zone(zone) { |
2065 | enum lru_list l; | 2065 | enum lru_list l; |
2066 | 2066 | ||
2067 | if (!populated_zone(zone)) | ||
2068 | continue; | ||
2069 | if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY) | 2067 | if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY) |
2070 | continue; | 2068 | continue; |
2071 | 2069 | ||
diff --git a/mm/vmstat.c b/mm/vmstat.c index 8cd81ea1ddc1..9826766f1274 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -135,11 +135,7 @@ static void refresh_zone_stat_thresholds(void) | |||
135 | int cpu; | 135 | int cpu; |
136 | int threshold; | 136 | int threshold; |
137 | 137 | ||
138 | for_each_zone(zone) { | 138 | for_each_populated_zone(zone) { |
139 | |||
140 | if (!zone->present_pages) | ||
141 | continue; | ||
142 | |||
143 | threshold = calculate_threshold(zone); | 139 | threshold = calculate_threshold(zone); |
144 | 140 | ||
145 | for_each_online_cpu(cpu) | 141 | for_each_online_cpu(cpu) |
@@ -301,12 +297,9 @@ void refresh_cpu_vm_stats(int cpu) | |||
301 | int i; | 297 | int i; |
302 | int global_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, }; | 298 | int global_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, }; |
303 | 299 | ||
304 | for_each_zone(zone) { | 300 | for_each_populated_zone(zone) { |
305 | struct per_cpu_pageset *p; | 301 | struct per_cpu_pageset *p; |
306 | 302 | ||
307 | if (!populated_zone(zone)) | ||
308 | continue; | ||
309 | |||
310 | p = zone_pcp(zone, cpu); | 303 | p = zone_pcp(zone, cpu); |
311 | 304 | ||
312 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) | 305 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) |