Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

zram: update documentation

Several documentation changes.

First, we never mentioned any errors and never required any
error checks in documentation.

Second, mention that there is another way to configure and
manage zram devices -- zramctl, provided by util-linux.

Third, add a bit of clarification on why `mem_used_max' attr
is RW and correct some typos.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Sergey SENOZHATSKY and committed by
Jonathan Corbet
3657c20d 1c0032c8

+40 -4
+40 -4
Documentation/blockdev/zram.txt
··· 14 14 15 15 * Usage 16 16 17 + There are several ways to configure and manage zram device(-s): 18 + a) using zram and zram_control sysfs attributes 19 + b) using zramctl utility, provided by util-linux (util-linux@vger.kernel.org). 20 + 21 + In this document we will describe only 'manual' zram configuration steps, 22 + IOW, zram and zram_control sysfs attributes. 23 + 24 + In order to get a better idea about zramctl please consult util-linux 25 + documentation, zramctl man-page or `zramctl --help'. Please be informed 26 + that zram maintainers do not develop/maintain util-linux or zramctl, should 27 + you have any questions please contact util-linux@vger.kernel.org 28 + 17 29 Following shows a typical sequence of steps for using zram. 30 + 31 + WARNING 32 + ======= 33 + For the sake of simplicity we skip error checking parts in most of the 34 + examples below. However, it is your sole responsibility to handle errors. 35 + 36 + zram sysfs attributes always return negative values in case of errors. 37 + The list of possible return codes: 38 + -EBUSY -- an attempt to modify an attribute that cannot be changed once 39 + the device has been initialised. Please reset device first; 40 + -ENOMEM -- zram was not able to allocate enough memory to fulfil your 41 + needs; 42 + -EINVAL -- invalid input has been provided. 43 + 44 + If you use 'echo', the returned value that is changed by 'echo' utility, 45 + and, in general case, something like: 46 + 47 + echo 3 > /sys/block/zram0/max_comp_streams 48 + if [ $? -ne 0 ]; 49 + handle_error 50 + fi 51 + 52 + should suffice. 18 53 19 54 1) Load Module: 20 55 modprobe zram num_devices=4 ··· 82 47 83 48 3) Select compression algorithm 84 49 Using comp_algorithm device attribute one can see available and 85 - currently selected (shown in square brackets) compression algortithms, 50 + currently selected (shown in square brackets) compression algorithms, 86 51 change selected compression algorithm (once the device is initialised 87 52 there is no way to change compression algorithm). 88 53 ··· 154 119 8) Stats: 155 120 Per-device statistics are exported as various nodes under /sys/block/zram<id>/ 156 121 157 - A brief description of exported device attritbutes. For more details please 122 + A brief description of exported device attributes. For more details please 158 123 read Documentation/ABI/testing/sysfs-block-zram. 159 124 160 125 Name access description ··· 175 140 orig_data_size RO uncompressed size of data stored in this disk 176 141 compr_data_size RO compressed size of data stored in this disk 177 142 mem_used_total RO the amount of memory allocated for this disk 178 - mem_used_max RW the maximum amount memory zram have consumed to 179 - store compressed data 143 + mem_used_max RW the maximum amount of memory zram have consumed to 144 + store the data (to reset this counter to the actual 145 + current value, write 1 to this attribute) 180 146 mem_limit RW the maximum amount of memory ZRAM can use to store 181 147 the compressed data 182 148 pages_compacted RO the number of pages freed during compaction