Skip to content

Commit 91537fe

Browse files
minchanktorvalds
authored andcommitted
mm: add NR_ZSMALLOC to vmstat
zram is very popular for some of the embedded world (e.g., TV, mobile phones). On those system, zsmalloc's consumed memory size is never trivial (one of example from real product system, total memory: 800M, zsmalloc consumed: 150M), so we have used this out of tree patch to monitor system memory behavior via /proc/vmstat. With zsmalloc in vmstat, it helps in tracking down system behavior due to memory usage. [[email protected]: zsmalloc: follow up zsmalloc vmstat] Link: http://lkml.kernel.org/r/20160607091737.GC23435@bbox [[email protected]: fix build with CONFIG_ZSMALLOC=m] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Minchan Kim <[email protected]> Cc: Sangseok Lee <[email protected]> Cc: Chanho Min <[email protected]> Cc: Chan Gyun Jeong <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8ea1d2a commit 91537fe

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

include/linux/mmzone.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ enum zone_stat_item {
140140
NR_DIRTIED, /* page dirtyings since bootup */
141141
NR_WRITTEN, /* page writings since bootup */
142142
NR_PAGES_SCANNED, /* pages scanned since last reclaim */
143+
#if IS_ENABLED(CONFIG_ZSMALLOC)
144+
NR_ZSPAGES, /* allocated in zsmalloc */
145+
#endif
143146
#ifdef CONFIG_NUMA
144147
NUMA_HIT, /* allocated in intended node */
145148
NUMA_MISS, /* allocated in non intended node */

mm/vmstat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,9 @@ const char * const vmstat_text[] = {
718718
"nr_dirtied",
719719
"nr_written",
720720
"nr_pages_scanned",
721-
721+
#if IS_ENABLED(CONFIG_ZSMALLOC)
722+
"nr_zspages",
723+
#endif
722724
#ifdef CONFIG_NUMA
723725
"numa_hit",
724726
"numa_miss",

mm/zsmalloc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class,
10071007
next = get_next_page(page);
10081008
reset_page(page);
10091009
unlock_page(page);
1010+
dec_zone_page_state(page, NR_ZSPAGES);
10101011
put_page(page);
10111012
page = next;
10121013
} while (page != NULL);
@@ -1137,11 +1138,15 @@ static struct zspage *alloc_zspage(struct zs_pool *pool,
11371138

11381139
page = alloc_page(gfp);
11391140
if (!page) {
1140-
while (--i >= 0)
1141+
while (--i >= 0) {
1142+
dec_zone_page_state(pages[i], NR_ZSPAGES);
11411143
__free_page(pages[i]);
1144+
}
11421145
cache_free_zspage(pool, zspage);
11431146
return NULL;
11441147
}
1148+
1149+
inc_zone_page_state(page, NR_ZSPAGES);
11451150
pages[i] = page;
11461151
}
11471152

0 commit comments

Comments
 (0)