aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/blockdev
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2014-10-09 18:29:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:26:02 -0400
commit9ada9da9573f3460b156b7755c093e30b258eacb (patch)
tree45d38673aa9bc81b99131a3a3c5e1e97292bb5f5 /Documentation/blockdev
parent722cdc17232f0f684011407f7cf3c40d39457971 (diff)
zram: zram memory size limitation
Since zram has no control feature to limit memory usage, it makes hard to manage system memrory. This patch adds new knob "mem_limit" via sysfs to set up the a limit so that zram could fail allocation once it reaches the limit. In addition, user could change the limit in runtime so that he could manage the memory more dynamically. Initial state is no limit so it doesn't break old behavior. [akpm@linux-foundation.org: fix typo, per Sergey] Signed-off-by: Minchan Kim <minchan@kernel.org> Cc: Dan Streetman <ddstreet@ieee.org> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Jerome Marchand <jmarchan@redhat.com> Cc: <juno.choi@lge.com> Cc: <seungho1.park@lge.com> Cc: Luigi Semenzato <semenzato@google.com> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Seth Jennings <sjennings@variantweb.net> Cc: David Horner <ds2horner@gmail.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/blockdev')
-rw-r--r--Documentation/blockdev/zram.txt24
1 files changed, 20 insertions, 4 deletions
diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index 0595c3f56ccf..82c6a41116db 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -74,14 +74,30 @@ There is little point creating a zram of greater than twice the size of memory
74since we expect a 2:1 compression ratio. Note that zram uses about 0.1% of the 74since we expect a 2:1 compression ratio. Note that zram uses about 0.1% of the
75size of the disk when not in use so a huge zram is wasteful. 75size of the disk when not in use so a huge zram is wasteful.
76 76
775) Activate: 775) Set memory limit: Optional
78 Set memory limit by writing the value to sysfs node 'mem_limit'.
79 The value can be either in bytes or you can use mem suffixes.
80 In addition, you could change the value in runtime.
81 Examples:
82 # limit /dev/zram0 with 50MB memory
83 echo $((50*1024*1024)) > /sys/block/zram0/mem_limit
84
85 # Using mem suffixes
86 echo 256K > /sys/block/zram0/mem_limit
87 echo 512M > /sys/block/zram0/mem_limit
88 echo 1G > /sys/block/zram0/mem_limit
89
90 # To disable memory limit
91 echo 0 > /sys/block/zram0/mem_limit
92
936) Activate:
78 mkswap /dev/zram0 94 mkswap /dev/zram0
79 swapon /dev/zram0 95 swapon /dev/zram0
80 96
81 mkfs.ext4 /dev/zram1 97 mkfs.ext4 /dev/zram1
82 mount /dev/zram1 /tmp 98 mount /dev/zram1 /tmp
83 99
846) Stats: 1007) Stats:
85 Per-device statistics are exported as various nodes under 101 Per-device statistics are exported as various nodes under
86 /sys/block/zram<id>/ 102 /sys/block/zram<id>/
87 disksize 103 disksize
@@ -96,11 +112,11 @@ size of the disk when not in use so a huge zram is wasteful.
96 compr_data_size 112 compr_data_size
97 mem_used_total 113 mem_used_total
98 114
997) Deactivate: 1158) Deactivate:
100 swapoff /dev/zram0 116 swapoff /dev/zram0
101 umount /dev/zram1 117 umount /dev/zram1
102 118
1038) Reset: 1199) Reset:
104 Write any positive value to 'reset' sysfs node 120 Write any positive value to 'reset' sysfs node
105 echo 1 > /sys/block/zram0/reset 121 echo 1 > /sys/block/zram0/reset
106 echo 1 > /sys/block/zram1/reset 122 echo 1 > /sys/block/zram1/reset