Commit d1ce749a authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

cma: count free CMA pages

Add NR_FREE_CMA_PAGES counter to be later used for checking watermark in
__zone_watermark_ok().  For simplicity and to avoid #ifdef hell make this
counter always available (not only when CONFIG_CMA=y).

[akpm@linux-foundation.org: use conventional migratetype naming]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2139cbe6
...@@ -142,6 +142,7 @@ enum zone_stat_item { ...@@ -142,6 +142,7 @@ enum zone_stat_item {
NUMA_OTHER, /* allocation from other node */ NUMA_OTHER, /* allocation from other node */
#endif #endif
NR_ANON_TRANSPARENT_HUGEPAGES, NR_ANON_TRANSPARENT_HUGEPAGES,
NR_FREE_CMA_PAGES,
NR_VM_ZONE_STAT_ITEMS }; NR_VM_ZONE_STAT_ITEMS };
/* /*
......
...@@ -253,6 +253,14 @@ static inline void refresh_zone_stat_thresholds(void) { } ...@@ -253,6 +253,14 @@ static inline void refresh_zone_stat_thresholds(void) { }
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
static inline void __mod_zone_freepage_state(struct zone *zone, int nr_pages,
int migratetype)
{
__mod_zone_page_state(zone, NR_FREE_PAGES, nr_pages);
if (is_migrate_cma(migratetype))
__mod_zone_page_state(zone, NR_FREE_CMA_PAGES, nr_pages);
}
extern const char * const vmstat_text[]; extern const char * const vmstat_text[];
#endif /* _LINUX_VMSTAT_H */ #endif /* _LINUX_VMSTAT_H */
...@@ -558,7 +558,8 @@ static inline void __free_one_page(struct page *page, ...@@ -558,7 +558,8 @@ static inline void __free_one_page(struct page *page,
if (page_is_guard(buddy)) { if (page_is_guard(buddy)) {
clear_page_guard_flag(buddy); clear_page_guard_flag(buddy);
set_page_private(page, 0); set_page_private(page, 0);
__mod_zone_page_state(zone, NR_FREE_PAGES, 1 << order); __mod_zone_freepage_state(zone, 1 << order,
migratetype);
} else { } else {
list_del(&buddy->lru); list_del(&buddy->lru);
zone->free_area[order].nr_free--; zone->free_area[order].nr_free--;
...@@ -677,6 +678,8 @@ static void free_pcppages_bulk(struct zone *zone, int count, ...@@ -677,6 +678,8 @@ static void free_pcppages_bulk(struct zone *zone, int count,
/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */
__free_one_page(page, zone, 0, mt); __free_one_page(page, zone, 0, mt);
trace_mm_page_pcpu_drain(page, 0, mt); trace_mm_page_pcpu_drain(page, 0, mt);
if (is_migrate_cma(mt))
__mod_zone_page_state(zone, NR_FREE_CMA_PAGES, 1);
} while (--to_free && --batch_free && !list_empty(list)); } while (--to_free && --batch_free && !list_empty(list));
} }
__mod_zone_page_state(zone, NR_FREE_PAGES, count); __mod_zone_page_state(zone, NR_FREE_PAGES, count);
...@@ -692,7 +695,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order, ...@@ -692,7 +695,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order,
__free_one_page(page, zone, order, migratetype); __free_one_page(page, zone, order, migratetype);
if (unlikely(migratetype != MIGRATE_ISOLATE)) if (unlikely(migratetype != MIGRATE_ISOLATE))
__mod_zone_page_state(zone, NR_FREE_PAGES, 1 << order); __mod_zone_freepage_state(zone, 1 << order, migratetype);
spin_unlock(&zone->lock); spin_unlock(&zone->lock);
} }
...@@ -815,7 +818,8 @@ static inline void expand(struct zone *zone, struct page *page, ...@@ -815,7 +818,8 @@ static inline void expand(struct zone *zone, struct page *page,
set_page_guard_flag(&page[size]); set_page_guard_flag(&page[size]);
set_page_private(&page[size], high); set_page_private(&page[size], high);
/* Guard pages are not available for any usage */ /* Guard pages are not available for any usage */
__mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << high)); __mod_zone_freepage_state(zone, -(1 << high),
migratetype);
continue; continue;
} }
#endif #endif
...@@ -1141,6 +1145,9 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, ...@@ -1141,6 +1145,9 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
} }
set_page_private(page, mt); set_page_private(page, mt);
list = &page->lru; list = &page->lru;
if (is_migrate_cma(mt))
__mod_zone_page_state(zone, NR_FREE_CMA_PAGES,
-(1 << order));
} }
__mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order)); __mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order));
spin_unlock(&zone->lock); spin_unlock(&zone->lock);
...@@ -1412,7 +1419,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype) ...@@ -1412,7 +1419,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
mt = get_pageblock_migratetype(page); mt = get_pageblock_migratetype(page);
if (unlikely(mt != MIGRATE_ISOLATE)) if (unlikely(mt != MIGRATE_ISOLATE))
__mod_zone_page_state(zone, NR_FREE_PAGES, -(1UL << order)); __mod_zone_freepage_state(zone, -(1UL << order), mt);
if (alloc_order != order) if (alloc_order != order)
expand(zone, page, alloc_order, order, expand(zone, page, alloc_order, order,
...@@ -1516,7 +1523,8 @@ struct page *buffered_rmqueue(struct zone *preferred_zone, ...@@ -1516,7 +1523,8 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
spin_unlock(&zone->lock); spin_unlock(&zone->lock);
if (!page) if (!page)
goto failed; goto failed;
__mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); __mod_zone_freepage_state(zone, -(1 << order),
get_pageblock_migratetype(page));
} }
__count_zone_vm_events(PGALLOC, zone, 1 << order); __count_zone_vm_events(PGALLOC, zone, 1 << order);
...@@ -2890,7 +2898,8 @@ void show_free_areas(unsigned int filter) ...@@ -2890,7 +2898,8 @@ void show_free_areas(unsigned int filter)
" unevictable:%lu" " unevictable:%lu"
" dirty:%lu writeback:%lu unstable:%lu\n" " dirty:%lu writeback:%lu unstable:%lu\n"
" free:%lu slab_reclaimable:%lu slab_unreclaimable:%lu\n" " free:%lu slab_reclaimable:%lu slab_unreclaimable:%lu\n"
" mapped:%lu shmem:%lu pagetables:%lu bounce:%lu\n", " mapped:%lu shmem:%lu pagetables:%lu bounce:%lu\n"
" free_cma:%lu\n",
global_page_state(NR_ACTIVE_ANON), global_page_state(NR_ACTIVE_ANON),
global_page_state(NR_INACTIVE_ANON), global_page_state(NR_INACTIVE_ANON),
global_page_state(NR_ISOLATED_ANON), global_page_state(NR_ISOLATED_ANON),
...@@ -2907,7 +2916,8 @@ void show_free_areas(unsigned int filter) ...@@ -2907,7 +2916,8 @@ void show_free_areas(unsigned int filter)
global_page_state(NR_FILE_MAPPED), global_page_state(NR_FILE_MAPPED),
global_page_state(NR_SHMEM), global_page_state(NR_SHMEM),
global_page_state(NR_PAGETABLE), global_page_state(NR_PAGETABLE),
global_page_state(NR_BOUNCE)); global_page_state(NR_BOUNCE),
global_page_state(NR_FREE_CMA_PAGES));
for_each_populated_zone(zone) { for_each_populated_zone(zone) {
int i; int i;
...@@ -2939,6 +2949,7 @@ void show_free_areas(unsigned int filter) ...@@ -2939,6 +2949,7 @@ void show_free_areas(unsigned int filter)
" pagetables:%lukB" " pagetables:%lukB"
" unstable:%lukB" " unstable:%lukB"
" bounce:%lukB" " bounce:%lukB"
" free_cma:%lukB"
" writeback_tmp:%lukB" " writeback_tmp:%lukB"
" pages_scanned:%lu" " pages_scanned:%lu"
" all_unreclaimable? %s" " all_unreclaimable? %s"
...@@ -2968,6 +2979,7 @@ void show_free_areas(unsigned int filter) ...@@ -2968,6 +2979,7 @@ void show_free_areas(unsigned int filter)
K(zone_page_state(zone, NR_PAGETABLE)), K(zone_page_state(zone, NR_PAGETABLE)),
K(zone_page_state(zone, NR_UNSTABLE_NFS)), K(zone_page_state(zone, NR_UNSTABLE_NFS)),
K(zone_page_state(zone, NR_BOUNCE)), K(zone_page_state(zone, NR_BOUNCE)),
K(zone_page_state(zone, NR_FREE_CMA_PAGES)),
K(zone_page_state(zone, NR_WRITEBACK_TEMP)), K(zone_page_state(zone, NR_WRITEBACK_TEMP)),
zone->pages_scanned, zone->pages_scanned,
(zone->all_unreclaimable ? "yes" : "no") (zone->all_unreclaimable ? "yes" : "no")
......
...@@ -77,11 +77,12 @@ int set_migratetype_isolate(struct page *page) ...@@ -77,11 +77,12 @@ int set_migratetype_isolate(struct page *page)
out: out:
if (!ret) { if (!ret) {
unsigned long nr_pages; unsigned long nr_pages;
int migratetype = get_pageblock_migratetype(page);
set_pageblock_isolate(page); set_pageblock_isolate(page);
nr_pages = move_freepages_block(zone, page, MIGRATE_ISOLATE); nr_pages = move_freepages_block(zone, page, MIGRATE_ISOLATE);
__mod_zone_page_state(zone, NR_FREE_PAGES, -nr_pages); __mod_zone_freepage_state(zone, -nr_pages, migratetype);
} }
spin_unlock_irqrestore(&zone->lock, flags); spin_unlock_irqrestore(&zone->lock, flags);
...@@ -100,7 +101,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype) ...@@ -100,7 +101,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE) if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE)
goto out; goto out;
nr_pages = move_freepages_block(zone, page, migratetype); nr_pages = move_freepages_block(zone, page, migratetype);
__mod_zone_page_state(zone, NR_FREE_PAGES, nr_pages); __mod_zone_freepage_state(zone, nr_pages, migratetype);
restore_pageblock_isolate(page, migratetype); restore_pageblock_isolate(page, migratetype);
out: out:
spin_unlock_irqrestore(&zone->lock, flags); spin_unlock_irqrestore(&zone->lock, flags);
......
...@@ -722,6 +722,7 @@ const char * const vmstat_text[] = { ...@@ -722,6 +722,7 @@ const char * const vmstat_text[] = {
"numa_other", "numa_other",
#endif #endif
"nr_anon_transparent_hugepages", "nr_anon_transparent_hugepages",
"nr_free_cma",
"nr_dirty_threshold", "nr_dirty_threshold",
"nr_dirty_background_threshold", "nr_dirty_background_threshold",
......
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