lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1464919731-13255-1-git-send-email-minchan@kernel.org>
Date:	Fri,  3 Jun 2016 11:08:51 +0900
From:	Minchan Kim <minchan@...nel.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Minchan Kim <minchan@...nel.org>,
	Sangseok Lee <sangseok.lee@....com>,
	Chanho Min <chanho.min@....com>,
	Chan Gyun Jeong <chan.jeong@....com>
Subject: [PATCH] mm: add NR_ZSMALLOC to vmstat

Now, zram is very popular for some of embedded world(e.g., TV, mobile
phone). On those system, zsmalloc 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 tracking down system behavior by
memory usage.

Cc: Sangseok Lee <sangseok.lee@....com>
Cc: Chanho Min <chanho.min@....com>
Cc: Chan Gyun Jeong <chan.jeong@....com>
Signed-off-by: Minchan Kim <minchan@...nel.org>
---
 include/linux/mmzone.h | 3 +++
 mm/vmstat.c            | 4 +++-
 mm/zsmalloc.c          | 7 ++++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 3388ccbab7d6..971d4c9f2550 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -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 */
+#ifdef CONFIG_ZSMALLOC
+	NR_ZSMALLOC,
+#endif
 #ifdef CONFIG_NUMA
 	NUMA_HIT,		/* allocated in intended node */
 	NUMA_MISS,		/* allocated in non intended node */
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 1b585f8e3088..3701905f3eb4 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -730,7 +730,9 @@ const char * const vmstat_text[] = {
 	"nr_dirtied",
 	"nr_written",
 	"nr_pages_scanned",
-
+#ifdef CONFIG_ZSMALLOC
+	"nr_zsmalloc",
+#endif
 #ifdef CONFIG_NUMA
 	"numa_hit",
 	"numa_miss",
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index a80100db16d6..8e71ec4f8005 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1022,6 +1022,7 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class,
 		reset_page(page);
 		unlock_page(page);
 		put_page(page);
+		dec_zone_page_state(page, NR_ZSMALLOC);
 		page = next;
 	} while (page != NULL);
 
@@ -1149,11 +1150,15 @@ static struct zspage *alloc_zspage(struct zs_pool *pool,
 
 		page = alloc_page(gfp);
 		if (!page) {
-			while (--i >= 0)
+			while (--i >= 0) {
 				__free_page(pages[i]);
+				dec_zone_page_state(page, NR_ZSMALLOC);
+			}
 			cache_free_zspage(pool, zspage);
 			return NULL;
 		}
+
+		inc_zone_page_state(page, NR_ZSMALLOC);
 		pages[i] = page;
 	}
 
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ