mm/highmem: make nr_free_highpages() handles all highmem zones by itself
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>
Fri, 20 May 2016 00:12:26 +0000 (17:12 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 May 2016 02:12:14 +0000 (19:12 -0700)
nr_free_highpages() manually adds statistics per each highmem zone and
returns a total value for them.  Whenever we add a new highmem zone, we
need to consider this function and it's really troublesome.  Make it
handle all highmem zones by itself.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/highmem.c

index 123bcd3ed4f209ba3710d9bfcaf8725d0a105534..50b4ca6787f08e75037c81c853bfb5d22b1cbd36 100644 (file)
@@ -112,16 +112,12 @@ EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx);
 
 unsigned int nr_free_highpages (void)
 {
-       pg_data_t *pgdat;
+       struct zone *zone;
        unsigned int pages = 0;
 
-       for_each_online_pgdat(pgdat) {
-               pages += zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
-                       NR_FREE_PAGES);
-               if (zone_movable_is_highmem())
-                       pages += zone_page_state(
-                                       &pgdat->node_zones[ZONE_MOVABLE],
-                                       NR_FREE_PAGES);
+       for_each_populated_zone(zone) {
+               if (is_highmem(zone))
+                       pages += zone_page_state(zone, NR_FREE_PAGES);
        }
 
        return pages;