Loading Documentation/ABI/obsolete/sysfs-block-zram 0 → 100644 +119 −0 Original line number Diff line number Diff line What: /sys/block/zram<id>/num_reads Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The num_reads file is read-only and specifies the number of reads (failed or successful) done on this device. Now accessible via zram<id>/stat node. What: /sys/block/zram<id>/num_writes Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The num_writes file is read-only and specifies the number of writes (failed or successful) done on this device. Now accessible via zram<id>/stat node. What: /sys/block/zram<id>/invalid_io Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The invalid_io file is read-only and specifies the number of non-page-size-aligned I/O requests issued to this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/failed_reads Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The failed_reads file is read-only and specifies the number of failed reads happened on this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/failed_writes Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The failed_writes file is read-only and specifies the number of failed writes happened on this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/notify_free Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The notify_free file is read-only. Depending on device usage scenario it may account a) the number of pages freed because of swap slot free notifications or b) the number of pages freed because of REQ_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. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/zero_pages Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The zero_pages file is read-only and specifies number of zero filled pages written to this disk. No memory is allocated for such pages. Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/orig_data_size Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The orig_data_size file is read-only and specifies uncompressed size of data stored in this disk. This excludes zero-filled pages (zero_pages) since no memory is allocated for them. Unit: bytes Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/compr_data_size Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The compr_data_size file is read-only and specifies compressed size of data stored in this disk. So, compression ratio can be calculated using orig_data_size and this statistic. Unit: bytes Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_used_total Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_used_total file is read-only and specifies the amount of memory, including 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 Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_used_max Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_used_max file is read/write and specifies the amount of maximum memory zram have consumed to store compressed data. For resetting the value, you should write "0". Otherwise, you could see -EINVAL. Unit: bytes Downgraded to write-only node: so it's possible to set new value only; its current value is stored in zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_limit Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_limit file is read/write and specifies the maximum amount of memory ZRAM can use to store the compressed data. The limit could be changed in run time and "0" means disable the limit. No limit is the initial state. Unit: bytes Downgraded to write-only node: so it's possible to set new value only; its current value is stored in zram<id>/mm_stat node. Documentation/ABI/testing/sysfs-block-zram +25 −0 Original line number Diff line number Diff line Loading @@ -141,3 +141,28 @@ Description: amount of memory ZRAM can use to store the compressed data. The limit could be changed in run time and "0" means disable the limit. No limit is the initial state. Unit: bytes What: /sys/block/zram<id>/compact Date: August 2015 Contact: Minchan Kim <minchan@kernel.org> Description: The compact file is write-only and trigger compaction for allocator zrm uses. The allocator moves some objects so that it could free fragment space. What: /sys/block/zram<id>/io_stat Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The io_stat file is read-only and accumulates device's I/O statistics not accounted by block layer. For example, failed_reads, failed_writes, etc. File format is similar to block layer statistics file format. What: /sys/block/zram<id>/mm_stat Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mm_stat file is read-only and represents device's mm statistics (orig_data_size, compr_data_size, etc.) in a format similar to block layer statistics file format. Documentation/blockdev/zram.txt +73 −14 Original line number Diff line number Diff line Loading @@ -98,20 +98,79 @@ size of the disk when not in use so a huge zram is wasteful. mount /dev/zram1 /tmp 7) Stats: Per-device statistics are exported as various nodes under /sys/block/zram<id>/ disksize num_reads num_writes Per-device statistics are exported as various nodes under /sys/block/zram<id>/ A brief description of exported device attritbutes. For more details please read Documentation/ABI/testing/sysfs-block-zram. Name access description ---- ------ ----------- disksize RW show and set the device's disk size initstate RO shows the initialization state of the device reset WO trigger device reset num_reads RO the number of reads failed_reads RO the number of failed reads num_write RO the number of writes failed_writes RO the number of failed writes invalid_io RO the number of non-page-size-aligned I/O requests max_comp_streams RW the number of possible concurrent compress operations comp_algorithm RW show and change the compression algorithm notify_free RO the number of notifications to free pages (either slot free notifications or REQ_DISCARD requests) zero_pages RO the number of zero filled pages written to this disk orig_data_size RO uncompressed size of data stored in this disk compr_data_size RO compressed size of data stored in this disk mem_used_total RO the amount of memory allocated for this disk mem_used_max RW the maximum amount memory zram have consumed to store compressed data mem_limit RW the maximum amount of memory ZRAM can use to store the compressed data num_migrated RO the number of objects migrated migrated by compaction WARNING ======= per-stat sysfs attributes are considered to be deprecated. The basic strategy is: -- the existing RW nodes will be downgraded to WO nodes (in linux 4.11) -- deprecated RO sysfs nodes will eventually be removed (in linux 4.11) The list of deprecated attributes can be found here: Documentation/ABI/obsolete/sysfs-block-zram Basically, every attribute that has its own read accessible sysfs node (e.g. num_reads) *AND* is accessible via one of the stat files (zram<id>/stat or zram<id>/io_stat or zram<id>/mm_stat) is considered to be deprecated. User space is advised to use the following files to read the device statistics. File /sys/block/zram<id>/stat Represents block layer statistics. Read Documentation/block/stat.txt for details. File /sys/block/zram<id>/io_stat The stat file represents device's I/O statistics not accounted by block layer and, thus, not available in zram<id>/stat file. It consists of a single line of text and contains the following stats separated by whitespace: failed_reads failed_writes invalid_io notify_free zero_pages File /sys/block/zram<id>/mm_stat The stat file represents device's mm statistics. It consists of a single line of text and contains the following stats separated by whitespace: orig_data_size compr_data_size mem_used_total mem_limit mem_used_max zero_pages num_migrated 8) Deactivate: swapoff /dev/zram0 Loading Documentation/vm/zsmalloc.txt 0 → 100644 +70 −0 Original line number Diff line number Diff line zsmalloc -------- This allocator is designed for use with zram. Thus, the allocator is supposed to work well under low memory conditions. In particular, it never attempts higher order page allocation which is very likely to fail under memory pressure. On the other hand, if we just use single (0-order) pages, it would suffer from very high fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy an entire page. This was one of the major issues with its predecessor (xvmalloc). To overcome these issues, zsmalloc allocates a bunch of 0-order pages and links them together using various 'struct page' fields. These linked pages act as a single higher-order page i.e. an object can span 0-order page boundaries. The code refers to these linked pages as a single entity called zspage. For simplicity, zsmalloc can only allocate objects of size up to PAGE_SIZE since this satisfies the requirements of all its current users (in the worst case, page is incompressible and is thus stored "as-is" i.e. in uncompressed form). For allocation requests larger than this size, failure is returned (see zs_malloc). Additionally, zs_malloc() does not return a dereferenceable pointer. Instead, it returns an opaque handle (unsigned long) which encodes actual location of the allocated object. The reason for this indirection is that zsmalloc does not keep zspages permanently mapped since that would cause issues on 32-bit systems where the VA region for kernel space mappings is very small. So, before using the allocating memory, the object has to be mapped using zs_map_object() to get a usable pointer and subsequently unmapped using zs_unmap_object(). stat ---- With CONFIG_ZSMALLOC_STAT, we could see zsmalloc internal information via /sys/kernel/debug/zsmalloc/<user name>. Here is a sample of stat output: # cat /sys/kernel/debug/zsmalloc/zram0/classes class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage .. .. 9 176 0 1 186 129 8 4 10 192 1 0 2880 2872 135 3 11 208 0 1 819 795 42 2 12 224 0 1 219 159 12 4 .. .. class: index size: object size zspage stores almost_empty: the number of ZS_ALMOST_EMPTY zspages(see below) almost_full: the number of ZS_ALMOST_FULL zspages(see below) obj_allocated: the number of objects allocated obj_used: the number of objects allocated to the user pages_used: the number of pages allocated for the class pages_per_zspage: the number of 0-order pages to make a zspage We assign a zspage to ZS_ALMOST_EMPTY fullness group when: n <= N / f, where n = number of allocated objects N = total number of objects zspage can store f = fullness_threshold_frac(ie, 4 at the moment) Similarly, we assign zspage to: ZS_ALMOST_FULL when n > N / f ZS_EMPTY when n == 0 ZS_FULL when n == N MAINTAINERS +1 −0 Original line number Diff line number Diff line Loading @@ -10475,6 +10475,7 @@ L: linux-mm@kvack.org S: Maintained F: mm/zsmalloc.c F: include/linux/zsmalloc.h F: Documentation/vm/zsmalloc.txt ZSWAP COMPRESSED SWAP CACHING M: Seth Jennings <sjennings@variantweb.net> Loading Loading
Documentation/ABI/obsolete/sysfs-block-zram 0 → 100644 +119 −0 Original line number Diff line number Diff line What: /sys/block/zram<id>/num_reads Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The num_reads file is read-only and specifies the number of reads (failed or successful) done on this device. Now accessible via zram<id>/stat node. What: /sys/block/zram<id>/num_writes Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The num_writes file is read-only and specifies the number of writes (failed or successful) done on this device. Now accessible via zram<id>/stat node. What: /sys/block/zram<id>/invalid_io Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The invalid_io file is read-only and specifies the number of non-page-size-aligned I/O requests issued to this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/failed_reads Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The failed_reads file is read-only and specifies the number of failed reads happened on this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/failed_writes Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The failed_writes file is read-only and specifies the number of failed writes happened on this device. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/notify_free Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The notify_free file is read-only. Depending on device usage scenario it may account a) the number of pages freed because of swap slot free notifications or b) the number of pages freed because of REQ_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. Now accessible via zram<id>/io_stat node. What: /sys/block/zram<id>/zero_pages Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The zero_pages file is read-only and specifies number of zero filled pages written to this disk. No memory is allocated for such pages. Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/orig_data_size Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The orig_data_size file is read-only and specifies uncompressed size of data stored in this disk. This excludes zero-filled pages (zero_pages) since no memory is allocated for them. Unit: bytes Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/compr_data_size Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The compr_data_size file is read-only and specifies compressed size of data stored in this disk. So, compression ratio can be calculated using orig_data_size and this statistic. Unit: bytes Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_used_total Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_used_total file is read-only and specifies the amount of memory, including 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 Now accessible via zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_used_max Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_used_max file is read/write and specifies the amount of maximum memory zram have consumed to store compressed data. For resetting the value, you should write "0". Otherwise, you could see -EINVAL. Unit: bytes Downgraded to write-only node: so it's possible to set new value only; its current value is stored in zram<id>/mm_stat node. What: /sys/block/zram<id>/mem_limit Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mem_limit file is read/write and specifies the maximum amount of memory ZRAM can use to store the compressed data. The limit could be changed in run time and "0" means disable the limit. No limit is the initial state. Unit: bytes Downgraded to write-only node: so it's possible to set new value only; its current value is stored in zram<id>/mm_stat node.
Documentation/ABI/testing/sysfs-block-zram +25 −0 Original line number Diff line number Diff line Loading @@ -141,3 +141,28 @@ Description: amount of memory ZRAM can use to store the compressed data. The limit could be changed in run time and "0" means disable the limit. No limit is the initial state. Unit: bytes What: /sys/block/zram<id>/compact Date: August 2015 Contact: Minchan Kim <minchan@kernel.org> Description: The compact file is write-only and trigger compaction for allocator zrm uses. The allocator moves some objects so that it could free fragment space. What: /sys/block/zram<id>/io_stat Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The io_stat file is read-only and accumulates device's I/O statistics not accounted by block layer. For example, failed_reads, failed_writes, etc. File format is similar to block layer statistics file format. What: /sys/block/zram<id>/mm_stat Date: August 2015 Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Description: The mm_stat file is read-only and represents device's mm statistics (orig_data_size, compr_data_size, etc.) in a format similar to block layer statistics file format.
Documentation/blockdev/zram.txt +73 −14 Original line number Diff line number Diff line Loading @@ -98,20 +98,79 @@ size of the disk when not in use so a huge zram is wasteful. mount /dev/zram1 /tmp 7) Stats: Per-device statistics are exported as various nodes under /sys/block/zram<id>/ disksize num_reads num_writes Per-device statistics are exported as various nodes under /sys/block/zram<id>/ A brief description of exported device attritbutes. For more details please read Documentation/ABI/testing/sysfs-block-zram. Name access description ---- ------ ----------- disksize RW show and set the device's disk size initstate RO shows the initialization state of the device reset WO trigger device reset num_reads RO the number of reads failed_reads RO the number of failed reads num_write RO the number of writes failed_writes RO the number of failed writes invalid_io RO the number of non-page-size-aligned I/O requests max_comp_streams RW the number of possible concurrent compress operations comp_algorithm RW show and change the compression algorithm notify_free RO the number of notifications to free pages (either slot free notifications or REQ_DISCARD requests) zero_pages RO the number of zero filled pages written to this disk orig_data_size RO uncompressed size of data stored in this disk compr_data_size RO compressed size of data stored in this disk mem_used_total RO the amount of memory allocated for this disk mem_used_max RW the maximum amount memory zram have consumed to store compressed data mem_limit RW the maximum amount of memory ZRAM can use to store the compressed data num_migrated RO the number of objects migrated migrated by compaction WARNING ======= per-stat sysfs attributes are considered to be deprecated. The basic strategy is: -- the existing RW nodes will be downgraded to WO nodes (in linux 4.11) -- deprecated RO sysfs nodes will eventually be removed (in linux 4.11) The list of deprecated attributes can be found here: Documentation/ABI/obsolete/sysfs-block-zram Basically, every attribute that has its own read accessible sysfs node (e.g. num_reads) *AND* is accessible via one of the stat files (zram<id>/stat or zram<id>/io_stat or zram<id>/mm_stat) is considered to be deprecated. User space is advised to use the following files to read the device statistics. File /sys/block/zram<id>/stat Represents block layer statistics. Read Documentation/block/stat.txt for details. File /sys/block/zram<id>/io_stat The stat file represents device's I/O statistics not accounted by block layer and, thus, not available in zram<id>/stat file. It consists of a single line of text and contains the following stats separated by whitespace: failed_reads failed_writes invalid_io notify_free zero_pages File /sys/block/zram<id>/mm_stat The stat file represents device's mm statistics. It consists of a single line of text and contains the following stats separated by whitespace: orig_data_size compr_data_size mem_used_total mem_limit mem_used_max zero_pages num_migrated 8) Deactivate: swapoff /dev/zram0 Loading
Documentation/vm/zsmalloc.txt 0 → 100644 +70 −0 Original line number Diff line number Diff line zsmalloc -------- This allocator is designed for use with zram. Thus, the allocator is supposed to work well under low memory conditions. In particular, it never attempts higher order page allocation which is very likely to fail under memory pressure. On the other hand, if we just use single (0-order) pages, it would suffer from very high fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy an entire page. This was one of the major issues with its predecessor (xvmalloc). To overcome these issues, zsmalloc allocates a bunch of 0-order pages and links them together using various 'struct page' fields. These linked pages act as a single higher-order page i.e. an object can span 0-order page boundaries. The code refers to these linked pages as a single entity called zspage. For simplicity, zsmalloc can only allocate objects of size up to PAGE_SIZE since this satisfies the requirements of all its current users (in the worst case, page is incompressible and is thus stored "as-is" i.e. in uncompressed form). For allocation requests larger than this size, failure is returned (see zs_malloc). Additionally, zs_malloc() does not return a dereferenceable pointer. Instead, it returns an opaque handle (unsigned long) which encodes actual location of the allocated object. The reason for this indirection is that zsmalloc does not keep zspages permanently mapped since that would cause issues on 32-bit systems where the VA region for kernel space mappings is very small. So, before using the allocating memory, the object has to be mapped using zs_map_object() to get a usable pointer and subsequently unmapped using zs_unmap_object(). stat ---- With CONFIG_ZSMALLOC_STAT, we could see zsmalloc internal information via /sys/kernel/debug/zsmalloc/<user name>. Here is a sample of stat output: # cat /sys/kernel/debug/zsmalloc/zram0/classes class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage .. .. 9 176 0 1 186 129 8 4 10 192 1 0 2880 2872 135 3 11 208 0 1 819 795 42 2 12 224 0 1 219 159 12 4 .. .. class: index size: object size zspage stores almost_empty: the number of ZS_ALMOST_EMPTY zspages(see below) almost_full: the number of ZS_ALMOST_FULL zspages(see below) obj_allocated: the number of objects allocated obj_used: the number of objects allocated to the user pages_used: the number of pages allocated for the class pages_per_zspage: the number of 0-order pages to make a zspage We assign a zspage to ZS_ALMOST_EMPTY fullness group when: n <= N / f, where n = number of allocated objects N = total number of objects zspage can store f = fullness_threshold_frac(ie, 4 at the moment) Similarly, we assign zspage to: ZS_ALMOST_FULL when n > N / f ZS_EMPTY when n == 0 ZS_FULL when n == N
MAINTAINERS +1 −0 Original line number Diff line number Diff line Loading @@ -10475,6 +10475,7 @@ L: linux-mm@kvack.org S: Maintained F: mm/zsmalloc.c F: include/linux/zsmalloc.h F: Documentation/vm/zsmalloc.txt ZSWAP COMPRESSED SWAP CACHING M: Seth Jennings <sjennings@variantweb.net> Loading