Skip to contentSkip to conversation

mm: add NR_ZSMALLOC to vmstat

PATCH Applied Minchan Kim 3 participants 6 messages Jun 3, 2016 – Jun 9, 2016

Subsystems (4)
lore
Share & tools
lore

Minchan Kim

author maintainer
#0 lore raw

PATCH 1/1 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 <[email protected]>
Cc Chanho Min <[email protected]>
Cc Chan Gyun Jeong <[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 +3 -0
index 3388ccbab7d6..971d4c9f2550 100644
@@ -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 */
mm/vmstat.c +3 -1
index 1b585f8e3088..3701905f3eb4 100644
@@ -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",
mm/zsmalloc.c +6 -1
index a80100db16d6..8e71ec4f8005 100644
@@ -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;
 	}
 
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 8 lines · Minchan Kim

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.

Hello,

may be use zsmalloc stats file instead? as far as I know, you keep zsmalloc stats enabled in production anyway.

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author maintainer
#2 lore raw

Hello,

Quoted 7 lines · Sergey Senozhatsky
Quoted 6 lines · Minchan Kim

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.

Quoted 7 lines
Quoted 2 lines

With zsmalloc in vmstat, it helps tracking down system behavior by memory usage.

Hello,

may be use zsmalloc stats file instead? as far as I know, you keep zsmalloc stats enabled in production anyway.

It doesn't support per-zone stat which is important to show the fragmentation of the zone, for exmaple.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

Hello,

Quoted 11 lines · Minchan Kim
Quoted 10 lines · Sergey Senozhatsky
Quoted 8 lines · Minchan Kim

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.

Quoted 7 lines
Quoted 4 lines

Hello,

may be use zsmalloc stats file instead? as far as I know, you keep zsmalloc stats enabled in production anyway.

It doesn't support per-zone stat which is important to show the fragmentation of the zone, for exmaple.

Ah, I see.

*just an idea*

may be zbud and z3fold folks will be interested as well, so may be more generic name and define... um, my head doesn't work toay.. ZALLOC... ZPOOLALLOC... hm.. I think you got the idea.

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author maintainer
#4 lore raw

Hi Sergey,

Quoted 19 lines · Sergey Senozhatsky

Hello,

Quoted 16 lines · Minchan Kim
Quoted 14 lines · Sergey Senozhatsky
Quoted 8 lines · Minchan Kim

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.

Hello,

may be use zsmalloc stats file instead? as far as I know, you keep zsmalloc stats enabled in production anyway.

Quoted 8 lines
Quoted 2 lines

It doesn't support per-zone stat which is important to show the fragmentation of the zone, for exmaple.

Ah, I see.

*just an idea*

may be zbud and z3fold folks will be interested as well, so may

First motivation of stat came from fragmentation problem from zsmalloc which caused by storing many thin zpages in a pageframe and across two pageframes while zswap limits the limitation by design.

Second motivation is zsmalloc can allocate page from HIGH/movable zones so I want to know how distribution zsmalloced pages is. However, zbud doesn't.

Lastly, zswap is designed for short-lived with backed storage so I guess it shouldn't be a problem.

http://marc.info/?l=linux-mm&m=136570894925571&w=2
http://marc.info/?l=linux-kernel&m=136571103026450&w=2

Quote from Seth
"

Quoted 6 lines

Compaction - compaction would basically involve creating a virtual address space of sorts, which zsmalloc is capable of through its API with handles, not pointer. However, as Dan points out this requires a structure the maintain the mappings and adds to complexity. Additionally, the need for compaction diminishes as the allocations are short-lived with frontswap backends doing writeback and cleancache backends shrinking.

Of course I say this, but for zram, this can be important as the allocations can't be moved out of memory and, therefore, are long lived. I was speaking from the zswap perspective.
"

Quoted 2 lines

be more generic name and define... um, my head doesn't work toay.. ZALLOC... ZPOOLALLOC... hm.. I think you got the idea.

Having said that, generic name is better rather than zsmalloc. Thanks. I want to use *zspage* which is term from the beginning of zprojects. :)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

Hello Minchan,

On (06/07/16 10:43), Minchan Kim wrote:
[..]

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

It doesn't support per-zone stat which is important to show the fragmentation of the zone, for exmaple.

Ah, I see.

*just an idea*

may be zbud and z3fold folks will be interested as well, so may

Quoted 7 lines

First motivation of stat came from fragmentation problem from zsmalloc which caused by storing many thin zpages in a pageframe and across two pageframes while zswap limits the limitation by design.

Second motivation is zsmalloc can allocate page from HIGH/movable zones so I want to know how distribution zsmalloced pages is. However, zbud doesn't.

good points.
well, my "motivation" was "on 64-bit systems high zone is empty, so those are zones below the high zone that we are interested in".

[..]

Quoted 5 lines
Quoted 2 lines

be more generic name and define... um, my head doesn't work toay.. ZALLOC... ZPOOLALLOC... hm.. I think you got the idea.

Having said that, generic name is better rather than zsmalloc. Thanks. I want to use *zspage* which is term from the beginning of zprojects. :)

thanks!

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>