Commit f3fe6512 authored by Con Kolivas's avatar Con Kolivas Committed by Linus Torvalds

[PATCH] mm: add populated_zone() helper

There are numerous places we check whether a zone is populated or not.

Provide a helper function to check for populated zones and convert all
checks for zone->present_pages.
Signed-off-by: default avatarCon Kolivas <kernel@kolivas.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 80bfed90
...@@ -388,6 +388,11 @@ static inline struct zone *next_zone(struct zone *zone) ...@@ -388,6 +388,11 @@ static inline struct zone *next_zone(struct zone *zone)
#define for_each_zone(zone) \ #define for_each_zone(zone) \
for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone)) for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone))
static inline int populated_zone(struct zone *zone)
{
return (!!zone->present_pages);
}
static inline int is_highmem_idx(int idx) static inline int is_highmem_idx(int idx)
{ {
return (idx == ZONE_HIGHMEM); return (idx == ZONE_HIGHMEM);
......
...@@ -1358,7 +1358,7 @@ void show_free_areas(void) ...@@ -1358,7 +1358,7 @@ void show_free_areas(void)
show_node(zone); show_node(zone);
printk("%s per-cpu:", zone->name); printk("%s per-cpu:", zone->name);
if (!zone->present_pages) { if (!populated_zone(zone)) {
printk(" empty\n"); printk(" empty\n");
continue; continue;
} else } else
...@@ -1435,7 +1435,7 @@ void show_free_areas(void) ...@@ -1435,7 +1435,7 @@ void show_free_areas(void)
show_node(zone); show_node(zone);
printk("%s: ", zone->name); printk("%s: ", zone->name);
if (!zone->present_pages) { if (!populated_zone(zone)) {
printk("empty\n"); printk("empty\n");
continue; continue;
} }
...@@ -2134,7 +2134,7 @@ static int frag_show(struct seq_file *m, void *arg) ...@@ -2134,7 +2134,7 @@ static int frag_show(struct seq_file *m, void *arg)
int order; int order;
for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
if (!zone->present_pages) if (!populated_zone(zone))
continue; continue;
spin_lock_irqsave(&zone->lock, flags); spin_lock_irqsave(&zone->lock, flags);
...@@ -2167,7 +2167,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg) ...@@ -2167,7 +2167,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) { for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) {
int i; int i;
if (!zone->present_pages) if (!populated_zone(zone))
continue; continue;
spin_lock_irqsave(&zone->lock, flags); spin_lock_irqsave(&zone->lock, flags);
......
...@@ -897,7 +897,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc) ...@@ -897,7 +897,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc)
for (i = 0; zones[i] != NULL; i++) { for (i = 0; zones[i] != NULL; i++) {
struct zone *zone = zones[i]; struct zone *zone = zones[i];
if (zone->present_pages == 0) if (!populated_zone(zone))
continue; continue;
if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
...@@ -1069,7 +1069,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order) ...@@ -1069,7 +1069,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order)
for (i = pgdat->nr_zones - 1; i >= 0; i--) { for (i = pgdat->nr_zones - 1; i >= 0; i--) {
struct zone *zone = pgdat->node_zones + i; struct zone *zone = pgdat->node_zones + i;
if (zone->present_pages == 0) if (!populated_zone(zone))
continue; continue;
if (zone->all_unreclaimable && if (zone->all_unreclaimable &&
...@@ -1106,7 +1106,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order) ...@@ -1106,7 +1106,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order)
struct zone *zone = pgdat->node_zones + i; struct zone *zone = pgdat->node_zones + i;
int nr_slab; int nr_slab;
if (zone->present_pages == 0) if (!populated_zone(zone))
continue; continue;
if (zone->all_unreclaimable && priority != DEF_PRIORITY) if (zone->all_unreclaimable && priority != DEF_PRIORITY)
...@@ -1258,7 +1258,7 @@ void wakeup_kswapd(struct zone *zone, int order) ...@@ -1258,7 +1258,7 @@ void wakeup_kswapd(struct zone *zone, int order)
{ {
pg_data_t *pgdat; pg_data_t *pgdat;
if (zone->present_pages == 0) if (!populated_zone(zone))
return; return;
pgdat = zone->zone_pgdat; pgdat = zone->zone_pgdat;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment