mm: add NR_ZSMALLOC to vmstat
[email protected]
maintainerPATCH 77/126 mm: add NR_ZSMALLOC to vmstat
From: Minchan Kim <[email protected]>
Subject: 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]
[[email protected]: fix build with CONFIG_ZSMALLOC=m]
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]>
---
include/linux/mmzone.h | 3 +++ mm/vmstat.c | 4 +++- mm/zsmalloc.c | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-)
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-add-nr_zsmalloc-to-vmstat +3 -0
@@ -140,6 +140,9 @@ enum zone_stat_item {NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ NR_PAGES_SCANNED ,/* pages scanned since last reclaim */ +#if IS_ENABLED(CONFIG_ZSMALLOC) +NR_ZSPAGES ,/* allocated in zsmalloc */ +#endif #ifdef CONFIG_NUMANUMA_HIT ,/* allocated in intended node */ NUMA_MISS, /* allocated in non intended node */
mm/vmstat.c renamed from mm/vmstat.c~mm-add-nr_zsmalloc-to-vmstat +3 -1
@@ -718,7 +718,9 @@ const char * const vmstat_text[] = {"nr_dirtied" ,"nr_written" ,"nr_pages_scanned" , - +#if IS_ENABLED(CONFIG_ZSMALLOC) +"nr_zspages" , +#endif #ifdef CONFIG_NUMA"numa_hit" , "numa_miss",
mm/zsmalloc.c renamed from mm/zsmalloc.c~mm-add-nr_zsmalloc-to-vmstat +6 -1
@@ -1007,6 +1007,7 @@ static void __free_zspage(struct zs_pool next =get_next_page (page);reset_page (page);unlock_page (page); +dec_zone_page_state (page,NR_ZSPAGES );put_page (page); page = next; }while (page !=NULL );
@@ -1137,11 +1138,15 @@ static struct zspage *alloc_zspage(struc page =alloc_page (gfp);if (!page) { -while (--i >=0 ) +while (--i >=0 ) { +dec_zone_page_state (pages[i],NR_ZSPAGES );__free_page (pages[i]); + }cache_free_zspage (pool, zspage);return NULL ; } + +inc_zone_page_state (page,NR_ZSPAGES ); pages[i] = page; }
_