4sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget-/translations/zh_CN/admin-guide/blockdev/zrammodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/zh_TW/admin-guide/blockdev/zrammodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/it_IT/admin-guide/blockdev/zrammodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/ja_JP/admin-guide/blockdev/zrammodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/ko_KR/admin-guide/blockdev/zrammodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/sp_SP/admin-guide/blockdev/zrammodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h(zram: Compressed RAM-based block devicesh]h(zram: Compressed RAM-based block devices}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhG/var/lib/git/docbuild/linux/Documentation/admin-guide/blockdev/zram.rsthKubh)}(hhh](h)}(h Introductionh]h Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXjThe zram module creates RAM-based block devices named /dev/zram ( = 0, 1, ...). Pages written to these disks are compressed and stored in memory itself. These disks allow very fast I/O and compression provides good amounts of memory savings. Some of the use cases include /tmp storage, use as swap disks, various caches under /var and maybe many more. :)h]hXjThe zram module creates RAM-based block devices named /dev/zram ( = 0, 1, ...). Pages written to these disks are compressed and stored in memory itself. These disks allow very fast I/O and compression provides good amounts of memory savings. Some of the use cases include /tmp storage, use as swap disks, various caches under /var and maybe many more. :)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h_Statistics for individual zram devices are exported through sysfs nodes at /sys/block/zram/h]h_Statistics for individual zram devices are exported through sysfs nodes at /sys/block/zram/}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h] introductionah ]h"] introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hUsageh]hUsage}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(h?There are several ways to configure and manage zram device(-s):h]h?There are several ways to configure and manage zram device(-s):}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhenumerated_list)}(hhh](h list_item)}(h,using zram and zram_control sysfs attributesh]h)}(hjh]h,using zram and zram_control sysfs attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hLusing zramctl utility, provided by util-linux (util-linux@vger.kernel.org). h]h)}(hKusing zramctl utility, provided by util-linux (util-linux@vger.kernel.org).h](h/using zramctl utility, provided by util-linux (}(hj/hhhNhNubh reference)}(hutil-linux@vger.kernel.orgh]hutil-linux@vger.kernel.org}(hj9hhhNhNubah}(h]h ]h"]h$]h&]refuri!mailto:util-linux@vger.kernel.orguh1j7hj/ubh).}(hj/hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj+ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtype loweralphaprefixhsuffix)uh1j hhhhhhhKubh)}(hvIn this document we will describe only 'manual' zram configuration steps, IOW, zram and zram_control sysfs attributes.h]hzIn this document we will describe only ‘manual’ zram configuration steps, IOW, zram and zram_control sysfs attributes.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXIn order to get a better idea about zramctl please consult util-linux documentation, zramctl man-page or `zramctl --help`. Please be informed that zram maintainers do not develop/maintain util-linux or zramctl, should you have any questions please contact util-linux@vger.kernel.orgh](hiIn order to get a better idea about zramctl please consult util-linux documentation, zramctl man-page or }(hjrhhhNhNubhtitle_reference)}(h`zramctl --help`h]hzramctl --help}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjrubh. Please be informed that zram maintainers do not develop/maintain util-linux or zramctl, should you have any questions please contact }(hjrhhhNhNubj8)}(hutil-linux@vger.kernel.orgh]hutil-linux@vger.kernel.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]refuri!mailto:util-linux@vger.kernel.orguh1j7hjrubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h;Following shows a typical sequence of steps for using zram.h]h;Following shows a typical sequence of steps for using zram.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hhhhubeh}(h]usageah ]h"]usageah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hWARNINGh]hWARNING}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK$ubh)}(hFor the sake of simplicity we skip error checking parts in most of the examples below. However, it is your sole responsibility to handle errors.h]hFor the sake of simplicity we skip error checking parts in most of the examples below. However, it is your sole responsibility to handle errors.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjhhubh)}(hizram sysfs attributes always return negative values in case of errors. The list of possible return codes:h]hizram sysfs attributes always return negative values in case of errors. The list of possible return codes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hjhhubhtable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK>uh1jhjubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(h-EBUSYh]h-EBUSY}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hyan attempt to modify an attribute that cannot be changed once the device has been initialised. Please reset device first.h]hyan attempt to modify an attribute that cannot be changed once the device has been initialised. Please reset device first.}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hj*ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h-ENOMEMh]h-ENOMEM}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK/hjJubah}(h]h ]h"]h$]h&]uh1jhjGubj)}(hhh]h)}(hAzram was not able to allocate enough memory to fulfil your needs.h]hAzram was not able to allocate enough memory to fulfil your needs.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK/hjaubah}(h]h ]h"]h$]h&]uh1jhjGubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h-EINVALh]h-EINVAL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hjubah}(h]h ]h"]h$]h&]uh1jhj~ubj)}(hhh]h)}(h invalid input has been provided.h]h invalid input has been provided.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hjubah}(h]h ]h"]h$]h&]uh1jhj~ubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h-EAGAINh]h-EAGAIN}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h]re-try operation later (e.g. when attempting to run recompress and writeback simultaneously).h]h]re-try operation later (e.g. when attempting to run recompress and writeback simultaneously).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubh)}(hjIf you use 'echo', the returned value is set by the 'echo' utility, and, in general case, something like::h]hqIf you use ‘echo’, the returned value is set by the ‘echo’ utility, and, in general case, something like:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjhhubh literal_block)}(hXecho foo > /sys/block/zram0/comp_algorithm if [ $? -ne 0 ]; then handle_error fih]hXecho foo > /sys/block/zram0/comp_algorithm if [ $? -ne 0 ]; then handle_error fi}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1j hhhK9hjhhubh)}(hshould suffice.h]hshould suffice.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjhhubeh}(h]warningah ]h"]warningah$]h&]uh1hhhhhhhhK$ubh)}(hhh](h)}(h1) Load Moduleh]h1) Load Module}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj5hhhhhKAubj)}(hmodprobe zram num_devices=4h]hmodprobe zram num_devices=4}hjFsbah}(h]h ]h"]h$]h&]jjuh1j hhhKEhj5hhubh)}(h*This creates 4 devices: /dev/zram{0,1,2,3}h]h*This creates 4 devices: /dev/zram{0,1,2,3}}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhj5hhubh)}(hdnum_devices parameter is optional and tells zram how many devices should be pre-created. Default: 1.h]hdnum_devices parameter is optional and tells zram how many devices should be pre-created. Default: 1.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhj5hhubeh}(h] load-moduleah ]h"]1) load moduleah$]h&]uh1hhhhhhhhKAubh)}(hhh](h)}(h2) Select compression algorithmh]h2) Select compression algorithm}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjxhhhhhKMubh)}(hXUsing comp_algorithm device attribute one can see available and currently selected (shown in square brackets) compression algorithms, or change the selected compression algorithm (once the device is initialised there is no way to change compression algorithm).h]hXUsing comp_algorithm device attribute one can see available and currently selected (shown in square brackets) compression algorithms, or change the selected compression algorithm (once the device is initialised there is no way to change compression algorithm).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjxhhubh)}(h Examples::h]h Examples:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThjxhhubj)}(h#show supported compression algorithms cat /sys/block/zram0/comp_algorithm lzo [lz4] #select lzo compression algorithm echo lzo > /sys/block/zram0/comp_algorithmh]h#show supported compression algorithms cat /sys/block/zram0/comp_algorithm lzo [lz4] #select lzo compression algorithm echo lzo > /sys/block/zram0/comp_algorithm}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhKVhjxhhubh)}(hnFor the time being, the `comp_algorithm` content shows only compression algorithms that are supported by zram.h](hFor the time being, the }(hjhhhNhNubj{)}(h`comp_algorithm`h]hcomp_algorithm}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjubhF content shows only compression algorithms that are supported by zram.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK]hjxhhubeh}(h]select-compression-algorithmah ]h"]2) select compression algorithmah$]h&]uh1hhhhhhhhKMubh)}(hhh](h)}(h13) Set compression algorithm parameters: Optionalh]h13) Set compression algorithm parameters: Optional}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKaubh)}(hCompression algorithms may support specific parameters which can be tweaked for particular dataset. ZRAM has an `algorithm_params` device attribute which provides a per-algorithm params configuration.h](hpCompression algorithms may support specific parameters which can be tweaked for particular dataset. ZRAM has an }(hjhhhNhNubj{)}(h`algorithm_params`h]halgorithm_params}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjubhF device attribute which provides a per-algorithm params configuration.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKchjhhubh)}(hX[For example, several compression algorithms support `level` parameter. In addition, certain compression algorithms support pre-trained dictionaries, which significantly change algorithms' characteristics. In order to configure compression algorithm to use external pre-trained dictionary, pass full path to the `dict` along with other parameters::h](h4For example, several compression algorithms support }(hj hhhNhNubj{)}(h`level`h]hlevel}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhj ubh parameter. In addition, certain compression algorithms support pre-trained dictionaries, which significantly change algorithms’ characteristics. In order to configure compression algorithm to use external pre-trained dictionary, pass full path to the }(hj hhhNhNubj{)}(h`dict`h]hdict}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jzhj ubh along with other parameters:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKghjhhubj)}(hX#pass path to pre-trained zstd dictionary echo "algo=zstd dict=/etc/dictionary" > /sys/block/zram0/algorithm_params #same, but using algorithm priority echo "priority=1 dict=/etc/dictionary" > \ /sys/block/zram0/algorithm_params #pass path to pre-trained zstd dictionary and compression level echo "algo=zstd level=8 dict=/etc/dictionary" > \ /sys/block/zram0/algorithm_paramsh]hX#pass path to pre-trained zstd dictionary echo "algo=zstd dict=/etc/dictionary" > /sys/block/zram0/algorithm_params #same, but using algorithm priority echo "priority=1 dict=/etc/dictionary" > \ /sys/block/zram0/algorithm_params #pass path to pre-trained zstd dictionary and compression level echo "algo=zstd level=8 dict=/etc/dictionary" > \ /sys/block/zram0/algorithm_params}hj>sbah}(h]h ]h"]h$]h&]jjuh1j hhhKmhjhhubh)}(hXParameters are algorithm specific: not all algorithms support pre-trained dictionaries, not all algorithms support `level`. Furthermore, for certain algorithms `level` controls the compression level (the higher the value the better the compression ratio, it even can take negatives values for some algorithms), for other algorithms `level` is acceleration level (the higher the value the lower the compression ratio).h](hsParameters are algorithm specific: not all algorithms support pre-trained dictionaries, not all algorithms support }(hjLhhhNhNubj{)}(h`level`h]hlevel}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjLubh&. Furthermore, for certain algorithms }(hjLhhhNhNubj{)}(h`level`h]hlevel}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjLubh controls the compression level (the higher the value the better the compression ratio, it even can take negatives values for some algorithms), for other algorithms }(hjLhhhNhNubj{)}(h`level`h]hlevel}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjLubhN is acceleration level (the higher the value the lower the compression ratio).}(hjLhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKxhjhhubeh}(h]-set-compression-algorithm-parameters-optionalah ]h"]13) set compression algorithm parameters: optionalah$]h&]uh1hhhhhhhhKaubh)}(hhh](h)}(h4) Set Disksizeh]h4) Set Disksize}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hSet disk size by writing the value to sysfs node 'disksize'. The value can be either in bytes or you can use mem suffixes. Examples::h]hSet disk size by writing the value to sysfs node ‘disksize’. The value can be either in bytes or you can use mem suffixes. Examples:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h# Initialize /dev/zram0 with 50MB disksize echo $((50*1024*1024)) > /sys/block/zram0/disksize # Using mem suffixes echo 256K > /sys/block/zram0/disksize echo 512M > /sys/block/zram0/disksize echo 1G > /sys/block/zram0/disksizeh]h# Initialize /dev/zram0 with 50MB disksize echo $((50*1024*1024)) > /sys/block/zram0/disksize # Using mem suffixes echo 256K > /sys/block/zram0/disksize echo 512M > /sys/block/zram0/disksize echo 1G > /sys/block/zram0/disksize}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhKhjhhubh)}(hNote: There is little point creating a zram of greater than twice the size of memory since we expect a 2:1 compression ratio. Note that zram uses about 0.1% of the size of the disk when not in use so a huge zram is wasteful.h]hNote: There is little point creating a zram of greater than twice the size of memory since we expect a 2:1 compression ratio. Note that zram uses about 0.1% of the size of the disk when not in use so a huge zram is wasteful.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h] set-disksizeah ]h"]4) set disksizeah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h5) Set memory limit: Optionalh]h5) Set memory limit: Optional}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hSet memory limit by writing the value to sysfs node 'mem_limit'. The value can be either in bytes or you can use mem suffixes. In addition, you could change the value in runtime. Examples::h]hSet memory limit by writing the value to sysfs node ‘mem_limit’. The value can be either in bytes or you can use mem suffixes. In addition, you could change the value in runtime. Examples:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX# limit /dev/zram0 with 50MB memory echo $((50*1024*1024)) > /sys/block/zram0/mem_limit # Using mem suffixes echo 256K > /sys/block/zram0/mem_limit echo 512M > /sys/block/zram0/mem_limit echo 1G > /sys/block/zram0/mem_limit # To disable memory limit echo 0 > /sys/block/zram0/mem_limith]hX# limit /dev/zram0 with 50MB memory echo $((50*1024*1024)) > /sys/block/zram0/mem_limit # Using mem suffixes echo 256K > /sys/block/zram0/mem_limit echo 512M > /sys/block/zram0/mem_limit echo 1G > /sys/block/zram0/mem_limit # To disable memory limit echo 0 > /sys/block/zram0/mem_limit}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhKhjhhubeh}(h]set-memory-limit-optionalah ]h"]5) set memory limit: optionalah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h 6) Activateh]h 6) Activate}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj)}(hOmkswap /dev/zram0 swapon /dev/zram0 mkfs.ext4 /dev/zram1 mount /dev/zram1 /tmph]hOmkswap /dev/zram0 swapon /dev/zram0 mkfs.ext4 /dev/zram1 mount /dev/zram1 /tmp}hj!sbah}(h]h ]h"]h$]h&]jjuh1j hhhKhjhhubeh}(h]activateah ]h"] 6) activateah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h7) Add/remove zram devicesh]h7) Add/remove zram devices}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj7hhhhhKubh)}(hazram provides a control interface, which enables dynamic (on-demand) device addition and removal.h]hazram provides a control interface, which enables dynamic (on-demand) device addition and removal.}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj7hhubh)}(hIn order to add a new /dev/zramX device, perform a read operation on the hot_add attribute. This will return either the new device's device id (meaning that you can use /dev/zram) or an error code.h]hIn order to add a new /dev/zramX device, perform a read operation on the hot_add attribute. This will return either the new device’s device id (meaning that you can use /dev/zram) or an error code.}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj7hhubh)}(h Example::h]hExample:}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj7hhubj)}(h%cat /sys/class/zram-control/hot_add 1h]h%cat /sys/class/zram-control/hot_add 1}hjrsbah}(h]h ]h"]h$]h&]jjuh1j hhhKhj7hhubh)}(hKTo remove the existing /dev/zramX device (where X is a device id) execute::h]hJTo remove the existing /dev/zramX device (where X is a device id) execute:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj7hhubj)}(h+echo X > /sys/class/zram-control/hot_removeh]h+echo X > /sys/class/zram-control/hot_remove}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhKhj7hhubeh}(h]add-remove-zram-devicesah ]h"]7) add/remove zram devicesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h8) Statsh]h8) Stats}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hNPer-device statistics are exported as various nodes under /sys/block/zram/h]hNPer-device statistics are exported as various nodes under /sys/block/zram/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hA brief description of exported device attributes follows. For more details please read Documentation/ABI/testing/sysfs-block-zram.h]hA brief description of exported device attributes follows. For more details please read Documentation/ABI/testing/sysfs-block-zram.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK/uh1jhjubhthead)}(hhh]j )}(hhh](j)}(hhh]h)}(hNameh]hName}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(haccessh]haccess}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h descriptionh]h description}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj+ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j )}(hhh](j)}(hhh]h)}(hdisksizeh]hdisksize}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjTubah}(h]h ]h"]h$]h&]uh1jhjQubj)}(hhh]h)}(hRWh]hRW}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjkubah}(h]h ]h"]h$]h&]uh1jhjQubj)}(hhh]h)}(h#show and set the device's disk sizeh]h%show and set the device’s disk size}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjQubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(h initstateh]h initstate}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hROh]hRO}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h,shows the initialization state of the deviceh]h,shows the initialization state of the device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hreseth]hreset}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hWOh]hWO}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(htrigger device reseth]htrigger device reset}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(h mem_used_maxh]h mem_used_max}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj>ubah}(h]h ]h"]h$]h&]uh1jhj;ubj)}(hhh]h)}(hWOh]hWO}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubah}(h]h ]h"]h$]h&]uh1jhj;ubj)}(hhh]h)}(h,reset the `mem_used_max` counter (see later)h](h reset the }(hjohhhNhNubj{)}(h`mem_used_max`h]h mem_used_max}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjoubh counter (see later)}(hjohhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlubah}(h]h ]h"]h$]h&]uh1jhj;ubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(h mem_limith]h mem_limit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hWOh]hWO}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hPspecifies the maximum amount of memory ZRAM can use to store the compressed datah]hPspecifies the maximum amount of memory ZRAM can use to store the compressed data}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hwriteback_limith]hwriteback_limit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hWOh]hWO}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hYspecifies the maximum amount of write IO zram can write out to backing device as 4KB unith]hYspecifies the maximum amount of write IO zram can write out to backing device as 4KB unit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hwriteback_limit_enableh]hwriteback_limit_enable}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj:ubah}(h]h ]h"]h$]h&]uh1jhj7ubj)}(hhh]h)}(hRWh]hRW}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQubah}(h]h ]h"]h$]h&]uh1jhj7ubj)}(hhh]h)}(h$show and set writeback_limit featureh]h$show and set writeback_limit feature}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1jhj7ubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hcomp_algorithmh]hcomp_algorithm}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hRWh]hRW}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h)show and change the compression algorithmh]h)show and change the compression algorithm}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(halgorithm_paramsh]halgorithm_params}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hWOh]hWO}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h&setup compression algorithm parametersh]h&setup compression algorithm parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hcompacth]hcompact}(hj' hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ ubah}(h]h ]h"]h$]h&]uh1jhj! ubj)}(hhh]h)}(hWOh]hWO}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj; ubah}(h]h ]h"]h$]h&]uh1jhj! ubj)}(hhh]h)}(htrigger memory compactionh]htrigger memory compaction}(hjU hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjR ubah}(h]h ]h"]h$]h&]uh1jhj! ubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(h debug_stath]h debug_stat}(hju hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjr ubah}(h]h ]h"]h$]h&]uh1jhjo ubj)}(hhh]h)}(hROh]hRO}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjo ubj)}(hhh]h)}(h-this file is used for zram debugging purposesh]h-this file is used for zram debugging purposes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjo ubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(h backing_devh]h backing_dev}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hRWh]hRW}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h,set up backend storage for zram to write outh]h,set up backend storage for zram to write out}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjNubj )}(hhh](j)}(hhh]h)}(hidleh]hidle}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hWOh]hWO}(hj( hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj% ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hmark allocated slot as idleh]hmark allocated slot as idle}(hj? hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj< ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjNubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubh)}(hOUser space is advised to use the following files to read the device statistics.h]hOUser space is advised to use the following files to read the device statistics.}(hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hFile /sys/block/zram/stath]hFile /sys/block/zram/stat}(hjz hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hQRepresents block layer statistics. Read Documentation/block/stat.rst for details.h]hQRepresents block layer statistics. Read Documentation/block/stat.rst for details.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h File /sys/block/zram/io_stath]h File /sys/block/zram/io_stat}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe stat file represents device's I/O statistics not accounted by block layer and, thus, not available in zram/stat file. It consists of a single line of text and contains the following stats separated by whitespace:h]hThe stat file represents device’s I/O statistics not accounted by block layer and, thus, not available in zram/stat file. It consists of a single line of text and contains the following stats separated by whitespace:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh block_quote)}(hX============= ============================================================= failed_reads The number of failed reads failed_writes The number of failed writes invalid_io The number of non-page-size-aligned I/O requests notify_free Depending on device usage scenario it may account a) the number of pages freed because of swap slot free notifications b) the number of pages freed because of REQ_OP_DISCARD requests sent by bio. The former ones are sent to a swap block device when a swap slot is freed, which implies that this disk is being used as a swap disk. The latter ones are sent by filesystem mounted with discard option, whenever some data blocks are getting discarded. ============= ============================================================= h]j)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthK uh1jhj ubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK=uh1jhj ubj)}(hhh](j )}(hhh](j)}(hhh]h)}(h failed_readsh]h failed_reads}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hThe number of failed readsh]hThe number of failed reads}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h failed_writesh]h failed_writes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hThe number of failed writesh]hThe number of failed writes}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj& ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h invalid_ioh]h invalid_io}(hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjF ubah}(h]h ]h"]h$]h&]uh1jhjC ubj)}(hhh]h)}(h0The number of non-page-size-aligned I/O requestsh]h0The number of non-page-size-aligned I/O requests}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj] ubah}(h]h ]h"]h$]h&]uh1jhjC ubeh}(h]h ]h"]h$]h&]uh1j hj ubj )}(hhh](j)}(hhh]h)}(h notify_freeh]h notify_free}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj} ubah}(h]h ]h"]h$]h&]uh1jhjz ubj)}(hhh](h)}(h1Depending on device usage scenario it may accounth]h1Depending on device usage scenario it may account}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubj)}(hhh](j)}(hAthe number of pages freed because of swap slot free notificationsh]h)}(hAthe number of pages freed because of swap slot free notificationsh]hAthe number of pages freed because of swap slot free notifications}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hthe number of pages freed because of REQ_OP_DISCARD requests sent by bio. The former ones are sent to a swap block device when a swap slot is freed, which implies that this disk is being used as a swap disk. h]h)}(hthe number of pages freed because of REQ_OP_DISCARD requests sent by bio. The former ones are sent to a swap block device when a swap slot is freed, which implies that this disk is being used as a swap disk.h]hthe number of pages freed because of REQ_OP_DISCARD requests sent by bio. The former ones are sent to a swap block device when a swap slot is freed, which implies that this disk is being used as a swap disk.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]j_j`jahjbjcuh1j hj ubh)}(htThe latter ones are sent by filesystem mounted with discard option, whenever some data blocks are getting discarded.h]htThe latter ones are sent by filesystem mounted with discard option, whenever some data blocks are getting discarded.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubeh}(h]h ]h"]h$]h&]uh1jhjz ubeh}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]colsKuh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1j hhhKhjhhubh)}(h File /sys/block/zram/mm_stath]h File /sys/block/zram/mm_stat}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThe mm_stat file represents the device's mm statistics. It consists of a single line of text and contains the following stats separated by whitespace:h]hThe mm_stat file represents the device’s mm statistics. It consists of a single line of text and contains the following stats separated by whitespace:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj )}(hX================ ============================================================= orig_data_size uncompressed size of data stored in this disk. Unit: bytes compr_data_size compressed size of data stored in this disk mem_used_total the amount of memory allocated for this disk. This includes allocator fragmentation and metadata overhead, allocated for this disk. So, allocator space efficiency can be calculated using compr_data_size and this statistic. Unit: bytes mem_limit the maximum amount of memory ZRAM can use to store the compressed data mem_used_max the maximum amount of memory zram has consumed to store the data same_pages the number of same element filled pages written to this disk. No memory is allocated for such pages. pages_compacted the number of pages freed during compaction huge_pages the number of incompressible pages huge_pages_since the number of incompressible pages since zram set up ================ ============================================================= h]j)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj4 ubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK=uh1jhj4 ubj)}(hhh](j )}(hhh](j)}(hhh]h)}(horig_data_sizeh]horig_data_size}(hjT hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjQ ubah}(h]h ]h"]h$]h&]uh1jhjN ubj)}(hhh]h)}(h:uncompressed size of data stored in this disk. Unit: bytesh]h:uncompressed size of data stored in this disk. Unit: bytes}(hjk hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjh ubah}(h]h ]h"]h$]h&]uh1jhjN ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(hcompr_data_sizeh]hcompr_data_size}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h+compressed size of data stored in this diskh]h+compressed size of data stored in this disk}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(hmem_used_totalh]hmem_used_total}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hthe amount of memory allocated for this disk. This includes allocator fragmentation and metadata overhead, allocated for this disk. So, allocator space efficiency can be calculated using compr_data_size and this statistic. Unit: bytesh]hthe amount of memory allocated for this disk. This includes allocator fragmentation and metadata overhead, allocated for this disk. So, allocator space efficiency can be calculated using compr_data_size and this statistic. Unit: bytes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(h mem_limith]h mem_limit}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hFthe maximum amount of memory ZRAM can use to store the compressed datah]hFthe maximum amount of memory ZRAM can use to store the compressed data}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(h mem_used_maxh]h mem_used_max}(hj0 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj- ubah}(h]h ]h"]h$]h&]uh1jhj* ubj)}(hhh]h)}(h@the maximum amount of memory zram has consumed to store the datah]h@the maximum amount of memory zram has consumed to store the data}(hjG hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjD ubah}(h]h ]h"]h$]h&]uh1jhj* ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(h same_pagesh]h same_pages}(hjg hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjd ubah}(h]h ]h"]h$]h&]uh1jhja ubj)}(hhh]h)}(hdthe number of same element filled pages written to this disk. No memory is allocated for such pages.h]hdthe number of same element filled pages written to this disk. No memory is allocated for such pages.}(hj~ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj{ ubah}(h]h ]h"]h$]h&]uh1jhja ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(hpages_compactedh]hpages_compacted}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h+the number of pages freed during compactionh]h+the number of pages freed during compaction}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(h huge_pagesh]h huge_pages}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h"the number of incompressible pagesh]h"the number of incompressible pages}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjK ubj )}(hhh](j)}(hhh]h)}(hhuge_pages_sinceh]hhuge_pages_since}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h4the number of incompressible pages since zram set uph]h4the number of incompressible pages since zram set up}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjK ubeh}(h]h ]h"]h$]h&]uh1jhj4 ubeh}(h]h ]h"]h$]h&]colsKuh1jhj1 ubah}(h]h ]h"]h$]h&]uh1jhj- ubah}(h]h ]h"]h$]h&]uh1j hhhMhjhhubh)}(h File /sys/block/zram/bd_stath]h File /sys/block/zram/bd_stat}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThe bd_stat file represents a device's backing device statistics. It consists of a single line of text and contains the following stats separated by whitespace:h]hThe bd_stat file represents a device’s backing device statistics. It consists of a single line of text and contains the following stats separated by whitespace:}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj )}(hX============== ============================================================= bd_count size of data written in backing device. Unit: 4K bytes bd_reads the number of reads from backing device Unit: 4K bytes bd_writes the number of writes to backing device Unit: 4K bytes ============== ============================================================= h]j)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjyubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK=uh1jhjyubj)}(hhh](j )}(hhh](j)}(hhh]h)}(hbd_counth]hbd_count}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h6size of data written in backing device. Unit: 4K bytesh]h6size of data written in backing device. Unit: 4K bytes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(hbd_readsh]hbd_reads}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM#hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h6the number of reads from backing device Unit: 4K bytesh]h6the number of reads from backing device Unit: 4K bytes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM#hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h bd_writesh]h bd_writes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h5the number of writes to backing device Unit: 4K bytesh]h5the number of writes to backing device Unit: 4K bytes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1jhjyubeh}(h]h ]h"]h$]h&]colsKuh1jhjvubah}(h]h ]h"]h$]h&]uh1jhjrubah}(h]h ]h"]h$]h&]uh1j hhhM hjhhubeh}(h]statsah ]h"]8) statsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h 9) Deactivateh]h 9) Deactivate}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjYhhhhhM*ubj)}(h$swapoff /dev/zram0 umount /dev/zram1h]h$swapoff /dev/zram0 umount /dev/zram1}hjjsbah}(h]h ]h"]h$]h&]jjuh1j hhhM.hjYhhubeh}(h] deactivateah ]h"] 9) deactivateah$]h&]uh1hhhhhhhhM*ubh)}(hhh](h)}(h 10) Reseth]h 10) Reset}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM2ubj )}(hXWrite any positive value to 'reset' sysfs node:: echo 1 > /sys/block/zram0/reset echo 1 > /sys/block/zram1/reset This frees all the memory allocated for the given device and resets the disksize to zero. You must set the disksize again before reusing the device. h](h)}(h0Write any positive value to 'reset' sysfs node::h]h3Write any positive value to ‘reset’ sysfs node:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM4hjubj)}(h?echo 1 > /sys/block/zram0/reset echo 1 > /sys/block/zram1/reseth]h?echo 1 > /sys/block/zram0/reset echo 1 > /sys/block/zram1/reset}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhM6hjubh)}(hThis frees all the memory allocated for the given device and resets the disksize to zero. You must set the disksize again before reusing the device.h]hThis frees all the memory allocated for the given device and resets the disksize to zero. You must set the disksize again before reusing the device.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjubeh}(h]h ]h"]h$]h&]uh1j hhhM4hjhhubeh}(h]resetah ]h"] 10) resetah$]h&]uh1hhhhhhhhM2ubh)}(hhh](h)}(hOptional Featureh]hOptional Feature}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM>ubh)}(hhh](h)}(h writebackh]h writeback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMAubh)}(hWith CONFIG_ZRAM_WRITEBACK, zram can write idle/incompressible page to backing storage rather than keeping it in memory. To use the feature, admin should set up backing device via::h]hWith CONFIG_ZRAM_WRITEBACK, zram can write idle/incompressible page to backing storage rather than keeping it in memory. To use the feature, admin should set up backing device via:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMChjhhubj)}(h-echo /dev/sda5 > /sys/block/zramX/backing_devh]h-echo /dev/sda5 > /sys/block/zramX/backing_dev}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMGhjhhubh)}(hbefore disksize setting. It supports only partitions at this moment. If admin wants to use incompressible page writeback, they could do it via::h]hbefore disksize setting. It supports only partitions at this moment. If admin wants to use incompressible page writeback, they could do it via:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMIhjhhubj)}(h&echo huge > /sys/block/zramX/writebackh]h&echo huge > /sys/block/zramX/writeback}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMLhjhhubh)}(hLTo use idle page writeback, first, user need to declare zram pages as idle::h]hKTo use idle page writeback, first, user need to declare zram pages as idle:}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhjhhubj)}(h echo all > /sys/block/zramX/idleh]h echo all > /sys/block/zramX/idle}hj5sbah}(h]h ]h"]h$]h&]jjuh1j hhhMQhjhhubh)}(hXaFrom now on, any pages on zram are idle pages. The idle mark will be removed until someone requests access of the block. IOW, unless there is access request, those pages are still idle pages. Additionally, when CONFIG_ZRAM_TRACK_ENTRY_ACTIME is enabled pages can be marked as idle based on how long (in seconds) it's been since they were last accessed::h]hXbFrom now on, any pages on zram are idle pages. The idle mark will be removed until someone requests access of the block. IOW, unless there is access request, those pages are still idle pages. Additionally, when CONFIG_ZRAM_TRACK_ENTRY_ACTIME is enabled pages can be marked as idle based on how long (in seconds) it’s been since they were last accessed:}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjhhubj)}(h"echo 86400 > /sys/block/zramX/idleh]h"echo 86400 > /sys/block/zramX/idle}hjQsbah}(h]h ]h"]h$]h&]jjuh1j hhhMZhjhhubh)}(hoIn this example all pages which haven't been accessed in more than 86400 seconds (one day) will be marked idle.h]hqIn this example all pages which haven’t been accessed in more than 86400 seconds (one day) will be marked idle.}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjhhubh)}(hEAdmin can request writeback of those idle pages at right timing via::h]hDAdmin can request writeback of those idle pages at right timing via:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM_hjhhubj)}(h&echo idle > /sys/block/zramX/writebackh]h&echo idle > /sys/block/zramX/writeback}hj{sbah}(h]h ]h"]h$]h&]jjuh1j hhhMahjhhubh)}(hLWith the command, zram will writeback idle pages from memory to the storage.h]hLWith the command, zram will writeback idle pages from memory to the storage.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchjhhubh)}(hdAdditionally, if a user choose to writeback only huge and idle pages this can be accomplished with::h]hcAdditionally, if a user choose to writeback only huge and idle pages this can be accomplished with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMehjhhubj)}(h+echo huge_idle > /sys/block/zramX/writebackh]h+echo huge_idle > /sys/block/zramX/writeback}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhhjhhubh)}(hIf a user chooses to writeback only incompressible pages (pages that none of algorithms can compress) this can be accomplished with::h]hIf a user chooses to writeback only incompressible pages (pages that none of algorithms can compress) this can be accomplished with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMjhjhhubj)}(h0echo incompressible > /sys/block/zramX/writebackh]h0echo incompressible > /sys/block/zramX/writeback}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMmhjhhubh)}(hIf an admin wants to write a specific page in zram device to the backing device, they could write a page index into the interface::h]hIf an admin wants to write a specific page in zram device to the backing device, they could write a page index into the interface:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMohjhhubj)}(h3echo "page_index=1251" > /sys/block/zramX/writebackh]h3echo "page_index=1251" > /sys/block/zramX/writeback}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMrhjhhubh)}(hIf there are lots of write IO with flash device, potentially, it has flash wearout problem so that admin needs to design write limitation to guarantee storage health for entire product life.h]hIf there are lots of write IO with flash device, potentially, it has flash wearout problem so that admin needs to design write limitation to guarantee storage health for entire product life.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMthjhhubh)}(hTo overcome the concern, zram supports "writeback_limit" feature. The "writeback_limit_enable"'s default value is 0 so that it doesn't limit any writeback. IOW, if admin wants to apply writeback budget, they should enable writeback_limit_enable via::h]hXTo overcome the concern, zram supports “writeback_limit” feature. The “writeback_limit_enable“‘s default value is 0 so that it doesn’t limit any writeback. IOW, if admin wants to apply writeback budget, they should enable writeback_limit_enable via:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMxhjhhubj)}(h2$ echo 1 > /sys/block/zramX/writeback_limit_enableh]h2$ echo 1 > /sys/block/zramX/writeback_limit_enable}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhM}hjhhubh)}(hOnce writeback_limit_enable is set, zram doesn't allow any writeback until admin sets the budget via /sys/block/zramX/writeback_limit.h]hOnce writeback_limit_enable is set, zram doesn’t allow any writeback until admin sets the budget via /sys/block/zramX/writeback_limit.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h(If admin doesn't enable writeback_limit_enable, writeback_limit's value assigned via /sys/block/zramX/writeback_limit is meaningless.)h]h(If admin doesn’t enable writeback_limit_enable, writeback_limit’s value assigned via /sys/block/zramX/writeback_limit is meaningless.)}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hPIf admin wants to limit writeback as per-day 400M, they could do it like below::h]hOIf admin wants to limit writeback as per-day 400M, they could do it like below:}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h$ MB_SHIFT=20 $ 4K_SHIFT=12 $ echo $((400<>4K_SHIFT)) > \ /sys/block/zram0/writeback_limit. $ echo 1 > /sys/block/zram0/writeback_limit_enableh]h$ MB_SHIFT=20 $ 4K_SHIFT=12 $ echo $((400<>4K_SHIFT)) > \ /sys/block/zram0/writeback_limit. $ echo 1 > /sys/block/zram0/writeback_limit_enable}hj?sbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hgIf admins want to allow further write again once the budget is exhausted, they could do it like below::h]hfIf admins want to allow further write again once the budget is exhausted, they could do it like below:}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hP$ echo $((400<>4K_SHIFT)) > \ /sys/block/zram0/writeback_limith]hP$ echo $((400<>4K_SHIFT)) > \ /sys/block/zram0/writeback_limit}hj[sbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hHIf an admin wants to see the remaining writeback budget since last set::h]hGIf an admin wants to see the remaining writeback budget since last set:}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h&$ cat /sys/block/zramX/writeback_limith]h&$ cat /sys/block/zramX/writeback_limit}hjwsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(h=If an admin wants to disable writeback limit, they could do::h]h /sys/block/zramX/writeback_limit_enableh]h2$ echo 0 > /sys/block/zramX/writeback_limit_enable}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hThe writeback_limit count will reset whenever you reset zram (e.g., system reboot, echo 1 > /sys/block/zramX/reset) so keeping how many of writeback happened until you reset the zram to allocate extra writeback budget in next setting is user's job.h]hThe writeback_limit count will reset whenever you reset zram (e.g., system reboot, echo 1 > /sys/block/zramX/reset) so keeping how many of writeback happened until you reset the zram to allocate extra writeback budget in next setting is user’s job.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h|If admin wants to measure writeback count in a certain period, they could know it via /sys/block/zram0/bd_stat's 3rd column.h]h~If admin wants to measure writeback count in a certain period, they could know it via /sys/block/zram0/bd_stat’s 3rd column.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h] writebackah ]h"] writebackah$]h&]uh1hhjhhhhhMAubh)}(hhh](h)}(h recompressionh]h recompression}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hXYWith CONFIG_ZRAM_MULTI_COMP, zram can recompress pages using alternative (secondary) compression algorithms. The basic idea is that alternative compression algorithm can provide better compression ratio at a price of (potentially) slower compression/decompression speeds. Alternative compression algorithm can, for example, be more successful compressing huge pages (those that default algorithm failed to compress). Another application is idle pages recompression - pages that are cold and sit in the memory can be recompressed using more effective algorithm and, hence, reduce zsmalloc memory usage.h]hXYWith CONFIG_ZRAM_MULTI_COMP, zram can recompress pages using alternative (secondary) compression algorithms. The basic idea is that alternative compression algorithm can provide better compression ratio at a price of (potentially) slower compression/decompression speeds. Alternative compression algorithm can, for example, be more successful compressing huge pages (those that default algorithm failed to compress). Another application is idle pages recompression - pages that are cold and sit in the memory can be recompressed using more effective algorithm and, hence, reduce zsmalloc memory usage.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX With CONFIG_ZRAM_MULTI_COMP, zram supports up to 4 compression algorithms: one primary and up to 3 secondary ones. Primary zram compressor is explained in "3) Select compression algorithm", secondary algorithms are configured using recomp_algorithm device attribute.h]hXWith CONFIG_ZRAM_MULTI_COMP, zram supports up to 4 compression algorithms: one primary and up to 3 secondary ones. Primary zram compressor is explained in “3) Select compression algorithm”, secondary algorithms are configured using recomp_algorithm device attribute.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Example:::h]h Example::}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h#show supported recompression algorithms cat /sys/block/zramX/recomp_algorithm #1: lzo lzo-rle lz4 lz4hc [zstd] #2: lzo lzo-rle lz4 [lz4hc] zstdh]h#show supported recompression algorithms cat /sys/block/zramX/recomp_algorithm #1: lzo lzo-rle lz4 lz4hc [zstd] #2: lzo lzo-rle lz4 [lz4hc] zstd}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hX<Alternative compression algorithms are sorted by priority. In the example above, zstd is used as the first alternative algorithm, which has priority of 1, while lz4hc is configured as a compression algorithm with priority 2. Alternative compression algorithm's priority is provided during algorithms configuration:::h]hX=Alternative compression algorithms are sorted by priority. In the example above, zstd is used as the first alternative algorithm, which has priority of 1, while lz4hc is configured as a compression algorithm with priority 2. Alternative compression algorithm’s priority is provided during algorithms configuration::>}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h#select zstd recompression algorithm, priority 1 echo "algo=zstd priority=1" > /sys/block/zramX/recomp_algorithm #select deflate recompression algorithm, priority 2 echo "algo=deflate priority=2" > /sys/block/zramX/recomp_algorithmh]h#select zstd recompression algorithm, priority 1 echo "algo=zstd priority=1" > /sys/block/zramX/recomp_algorithm #select deflate recompression algorithm, priority 2 echo "algo=deflate priority=2" > /sys/block/zramX/recomp_algorithm}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hiAnother device attribute that CONFIG_ZRAM_MULTI_COMP enables is recompress, which controls recompression.h]hiAnother device attribute that CONFIG_ZRAM_MULTI_COMP enables is recompress, which controls recompression.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Examples:::h]h Examples::}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hX?#IDLE pages recompression is activated by `idle` mode echo "type=idle" > /sys/block/zramX/recompress #HUGE pages recompression is activated by `huge` mode echo "type=huge" > /sys/block/zram0/recompress #HUGE_IDLE pages recompression is activated by `huge_idle` mode echo "type=huge_idle" > /sys/block/zramX/recompressh]hX?#IDLE pages recompression is activated by `idle` mode echo "type=idle" > /sys/block/zramX/recompress #HUGE pages recompression is activated by `huge` mode echo "type=huge" > /sys/block/zram0/recompress #HUGE_IDLE pages recompression is activated by `huge_idle` mode echo "type=huge_idle" > /sys/block/zramX/recompress}hjFsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hThe number of idle pages can be significant, so user-space can pass a size threshold (in bytes) to the recompress knob: zram will recompress only pages of equal or greater size:::h]hThe number of idle pages can be significant, so user-space can pass a size threshold (in bytes) to the recompress knob: zram will recompress only pages of equal or greater size::}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h#recompress all pages larger than 3000 bytes echo "threshold=3000" > /sys/block/zramX/recompress #recompress idle pages larger than 2000 bytes echo "type=idle threshold=2000" > /sys/block/zramX/recompressh]h#recompress all pages larger than 3000 bytes echo "threshold=3000" > /sys/block/zramX/recompress #recompress idle pages larger than 2000 bytes echo "type=idle threshold=2000" > /sys/block/zramX/recompress}hjbsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(hbIt is also possible to limit the number of pages zram re-compression will attempt to recompress:::h]haIt is also possible to limit the number of pages zram re-compression will attempt to recompress::}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h@echo "type=huge_idle max_pages=42" > /sys/block/zramX/recompressh]h@echo "type=huge_idle max_pages=42" > /sys/block/zramX/recompress}hj~sbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubh)}(h5Recompression of idle pages requires memory tracking.h]h5Recompression of idle pages requires memory tracking.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hXFDuring re-compression for every page, that matches re-compression criteria, ZRAM iterates the list of registered alternative compression algorithms in order of their priorities. ZRAM stops either when re-compression was successful (re-compressed object is smaller in size than the original one) and matches re-compression criteria (e.g. size threshold) or when there are no secondary algorithms left to try. If none of the secondary algorithms can successfully re-compressed the page such a page is marked as incompressible, so ZRAM will not attempt to re-compress it in the future.h]hXFDuring re-compression for every page, that matches re-compression criteria, ZRAM iterates the list of registered alternative compression algorithms in order of their priorities. ZRAM stops either when re-compression was successful (re-compressed object is smaller in size than the original one) and matches re-compression criteria (e.g. size threshold) or when there are no secondary algorithms left to try. If none of the secondary algorithms can successfully re-compressed the page such a page is marked as incompressible, so ZRAM will not attempt to re-compress it in the future.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hXThis re-compression behaviour, when it iterates through the list of registered compression algorithms, increases our chances of finding the algorithm that successfully compresses a particular page. Sometimes, however, it is convenient (and sometimes even necessary) to limit recompression to only one particular algorithm so that it will not try any other algorithms. This can be achieved by providing a `algo` or `priority` parameter:::h](hXThis re-compression behaviour, when it iterates through the list of registered compression algorithms, increases our chances of finding the algorithm that successfully compresses a particular page. Sometimes, however, it is convenient (and sometimes even necessary) to limit recompression to only one particular algorithm so that it will not try any other algorithms. This can be achieved by providing a }(hjhhhNhNubj{)}(h`algo`h]halgo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjubh or }(hjhhhNhNubj{)}(h `priority`h]hpriority}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jzhjubh parameter::}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h#use zstd algorithm only (if registered) echo "type=huge algo=zstd" > /sys/block/zramX/recompress #use zstd algorithm only (if zstd was registered under priority 1) echo "type=huge priority=1" > /sys/block/zramX/recompressh]h#use zstd algorithm only (if registered) echo "type=huge algo=zstd" > /sys/block/zramX/recompress #use zstd algorithm only (if zstd was registered under priority 1) echo "type=huge priority=1" > /sys/block/zramX/recompress}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubeh}(h] recompressionah ]h"] recompressionah$]h&]uh1hhjhhhhhMubeh}(h]optional-featureah ]h"]optional featureah$]h&]uh1hhhhhhhhM>ubh)}(hhh](h)}(hmemory trackingh]hmemory tracking}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hWith CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the zram block. It could be useful to catch cold or incompressible pages of the process with*pagemap.h]hWith CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the zram block. It could be useful to catch cold or incompressible pages of the process with*pagemap.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h~If you enable the feature, you could see block state via /sys/kernel/debug/zram/zram0/block_state". The output is as follows::h]hIf you enable the feature, you could see block state via /sys/kernel/debug/zram/zram0/block_state”. The output is as follows:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hw300 75.033841 .wh... 301 63.806904 s..... 302 63.806919 ..hi.. 303 62.801919 ....r. 304 146.781902 ..hi.nh]hw300 75.033841 .wh... 301 63.806904 s..... 302 63.806919 ..hi.. 303 62.801919 ....r. 304 146.781902 ..hi.n}hj%sbah}(h]h ]h"]h$]h&]jjuh1j hhhMhjhhubhdefinition_list)}(hhh](hdefinition_list_item)}(h First column zram's block index.h](hterm)}(h First columnh]h First column}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhM hj:ubh definition)}(hhh]h)}(hzram's block index.h]hzram’s block index.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjPubah}(h]h ]h"]h$]h&]uh1jNhj:ubeh}(h]h ]h"]h$]h&]uh1j8hhhM hj5ubj9)}(h5Second column access time since the system was bootedh](j?)}(h Second columnh]h Second column}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjmubjO)}(hhh]h)}(h'access time since the system was bootedh]h'access time since the system was booted}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jNhjmubeh}(h]h ]h"]h$]h&]uh1j8hhhMhj5hhubj9)}(hXThird column state of the block: s: same page w: written page to backing store h: huge page i: idle page r: recompressed page (secondary compression algorithm) n: none (including secondary) of algorithms could compress it h](j?)}(h Third columnh]h Third column}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjubjO)}(hhh](h)}(hstate of the block:h]hstate of the block:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubj4)}(hhh](j9)}(h s: same pageh](j?)}(hs:h]hs:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjubjO)}(hhh]h)}(h same pageh]h same page}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jNhjubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubj9)}(h w: written page to backing storeh](j?)}(hw:h]hw:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjubjO)}(hhh]h)}(hwritten page to backing storeh]hwritten page to backing store}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jNhjubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubj9)}(h h: huge pageh](j?)}(hh:h]hh:}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhj ubjO)}(hhh]h)}(h huge pageh]h huge page}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj2ubah}(h]h ]h"]h$]h&]uh1jNhj ubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubj9)}(h i: idle pageh](j?)}(hi:h]hi:}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjOubjO)}(hhh]h)}(h idle pageh]h idle page}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjaubah}(h]h ]h"]h$]h&]uh1jNhjOubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubj9)}(h6r: recompressed page (secondary compression algorithm)h](j?)}(hr:h]hr:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhj~ubjO)}(hhh]h)}(h3recompressed page (secondary compression algorithm)h]h3recompressed page (secondary compression algorithm)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jNhj~ubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubj9)}(h>n: none (including secondary) of algorithms could compress it h](j?)}(hn:h]hn:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j>hhhMhjubjO)}(hhh]h)}(h:none (including secondary) of algorithms could compress ith]h:none (including secondary) of algorithms could compress it}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jNhjubeh}(h]h ]h"]h$]h&]uh1j8hhhMhjubeh}(h]h ]h"]h$]h&]uh1j3hjubeh}(h]h ]h"]h$]h&]uh1jNhjubeh}(h]h ]h"]h$]h&]uh1j8hhhMhj5hhubeh}(h]h ]h"]h$]h&]uh1j3hjhhhhhNubh)}(hFirst line of above example says 300th block is accessed at 75.033841sec and the block's state is huge so it is written back to the backing storage. It's a debugging feature so anyone shouldn't rely on it to work properly.h]hFirst line of above example says 300th block is accessed at 75.033841sec and the block’s state is huge so it is written back to the backing storage. It’s a debugging feature so anyone shouldn’t rely on it to work properly.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hjhhubh)}(hNitin Gupta ngupta@vflare.orgh](h Nitin Gupta }(hjhhhNhNubj8)}(hngupta@vflare.orgh]hngupta@vflare.org}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:ngupta@vflare.orguh1j7hjubeh}(h]h ]h"]h$]h&]uh1hhhhM&hjhhubeh}(h]memory-trackingah ]h"]memory trackingah$]h&]uh1hhhhhhhhMubeh}(h]'zram-compressed-ram-based-block-devicesah ]h"](zram: compressed ram-based block devicesah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjRerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j-j*hhjjj2j/jujrjjjjjjj j j4j1jjjVjSj}jzjjjjjjjjj%j"u nametypes}(j-hjj2jujjjj j4jjVj}jjjjj%uh}(j*hhhjhj/jjrj5jjxjjjjj jj1jjj7jSjjzjYjjjjjjjjj"ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.