diff options
author | Jiang Liu <liuj97@gmail.com> | 2012-12-12 16:52:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 20:38:34 -0500 |
commit | 9feedc9d831e18ae6d0d15aa562e5e46ba53647b (patch) | |
tree | cb26ff54b0f02c4905772288b27f99b8b384ad6d /mm/vmstat.c | |
parent | c2d23f919bafcbc2259f5257d9a7d729802f0e3a (diff) |
mm: introduce new field "managed_pages" to struct zone
Currently a zone's present_pages is calcuated as below, which is
inaccurate and may cause trouble to memory hotplug.
spanned_pages - absent_pages - memmap_pages - dma_reserve.
During fixing bugs caused by inaccurate zone->present_pages, we found
zone->present_pages has been abused. The field zone->present_pages may
have different meanings in different contexts:
1) pages existing in a zone.
2) pages managed by the buddy system.
For more discussions about the issue, please refer to:
http://lkml.org/lkml/2012/11/5/866
https://patchwork.kernel.org/patch/1346751/
This patchset tries to introduce a new field named "managed_pages" to
struct zone, which counts "pages managed by the buddy system". And revert
zone->present_pages to count "physical pages existing in a zone", which
also keep in consistence with pgdat->node_present_pages.
We will set an initial value for zone->managed_pages in function
free_area_init_core() and will adjust it later if the initial value is
inaccurate.
For DMA/normal zones, the initial value is set to:
(spanned_pages - absent_pages - memmap_pages - dma_reserve)
Later zone->managed_pages will be adjusted to the accurate value when the
bootmem allocator frees all free pages to the buddy system in function
free_all_bootmem_node() and free_all_bootmem().
The bootmem allocator doesn't touch highmem pages, so highmem zones'
managed_pages is set to the accurate value "spanned_pages - absent_pages"
in function free_area_init_core() and won't be updated anymore.
This patch also adds a new field "managed_pages" to /proc/zoneinfo
and sysrq showmem.
[akpm@linux-foundation.org: small comment tweaks]
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Maciej Rutecki <maciej.rutecki@gmail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Cc: "Rafael J . Wysocki" <rjw@sisk.pl>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Minchan Kim <minchan@kernel.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r-- | mm/vmstat.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c index 9a4a522c0b0f..df14808f0a36 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -994,14 +994,16 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, | |||
994 | "\n high %lu" | 994 | "\n high %lu" |
995 | "\n scanned %lu" | 995 | "\n scanned %lu" |
996 | "\n spanned %lu" | 996 | "\n spanned %lu" |
997 | "\n present %lu", | 997 | "\n present %lu" |
998 | "\n managed %lu", | ||
998 | zone_page_state(zone, NR_FREE_PAGES), | 999 | zone_page_state(zone, NR_FREE_PAGES), |
999 | min_wmark_pages(zone), | 1000 | min_wmark_pages(zone), |
1000 | low_wmark_pages(zone), | 1001 | low_wmark_pages(zone), |
1001 | high_wmark_pages(zone), | 1002 | high_wmark_pages(zone), |
1002 | zone->pages_scanned, | 1003 | zone->pages_scanned, |
1003 | zone->spanned_pages, | 1004 | zone->spanned_pages, |
1004 | zone->present_pages); | 1005 | zone->present_pages, |
1006 | zone->managed_pages); | ||
1005 | 1007 | ||
1006 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) | 1008 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) |
1007 | seq_printf(m, "\n %-12s %lu", vmstat_text[i], | 1009 | seq_printf(m, "\n %-12s %lu", vmstat_text[i], |