mm: add zblock allocator
zblock is a special purpose allocator for storing compressed pages. It
stores integer number of same size objects per its block. These blocks
consist of several physical pages (2**n, i. e. 1/2/4/8).
With zblock, it is possible to densely arrange objects of various sizes
resulting in low internal fragmentation. Also this allocator tries to
fill incomplete blocks instead of adding new ones, in many cases providing
a compression ratio comparable to zmalloc's.
zblock is also in most cases superior to zsmalloc with regard to average
performance and worst execution times, thus allowing for better response
time and real-time characteristics of the whole system.
High memory and page migration are currently not supported by zblock.
Test results (zstd compressor, 8 core Ryzen 9 VM, make bzImage):
- zblock:
real 6m52.621s
user 33m41.771s
sys 6m28.825s
Zswap: 162328 kB
Zswapped: 754468 kB
zswpin 93851
zswpout 542481
zswpwb 935
- zsmalloc:
real 7m4.355s
user 34m37.538s
sys 6m22.086s
zswpin 101243
zswpout 448217
zswpwb 640
Zswap: 175704 kB
Zswapped: 778692 kB
[akpm@linux-foundation.org: fix build]
[akpm@linux-foundation.org: export try_alloc_pages_noprof() to modules for CONFIG_ZBLOCK=m]
[akpm@linux-foundation.org: try_alloc_pages() was renamed]
[akpm@linux-foundation.org: fix kerneldoc for zblock_create_pool()]
[igor.b@beldev.am: add debugfs]
Link: https://lkml.kernel.org/r/20250428064924.53496-1-igor.b@beldev.am
[igor.b@beldev.am: avoid failing the build]
Link: https://lkml.kernel.org/r/20250428065727.57990-1-igor.b@beldev.am
[akpm@linux-foundation.org: s/#warn/#warning/]
[igor.b@beldev.am: use vmalloc for page allocations]
Link: https://lkml.kernel.org/r/20250506220329.2355482-1-vitaly.wool@konsulko.se
[vitaly.wool@konsulko.se: make active_list rcu_list]
Link: https://lkml.kernel.org/r/20250508122925.2600217-1-vitaly.wool@konsulko.se
Link: https://lkml.kernel.org/r/20250412154207.2152667-1-vitaly.wool@konsulko.se
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
Signed-off-by: Igor Belousov <igor.b@beldev.am>
Tested-by: Igor Belousov <igor.b@beldev.am>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
7 files changed