[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230717113709.328671-1-glider@google.com>
Date: Mon, 17 Jul 2023 13:37:03 +0200
From: Alexander Potapenko <glider@...gle.com>
To: glider@...gle.com, catalin.marinas@....com, will@...nel.org,
pcc@...gle.com, andreyknvl@...il.com,
andriy.shevchenko@...ux.intel.com, linux@...musvillemoes.dk,
yury.norov@...il.com
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
eugenis@...gle.com, syednwaris@...il.com, william.gray@...aro.org
Subject: [PATCH v3 0/5] Implement MTE tag compression for swapped pages
Currently, when MTE pages are swapped out, the tags are kept in the
memory, occupying 128 bytes per page. This is especially problematic
for devices that use zram-backed in-memory swap, because tags stored
uncompressed in the heap effectively reduce the available amount of
swap memory.
The RLE-based EA0 algorithm suggested by Evgenii Stepanov and
implemented in this patch series is able to efficiently compress
128-byte tag buffers, resulting in practical compression ratio between
2.5x and 20x. In most cases it is possible to store the compressed data
in 63-bit Xarray values, resulting in no extra memory allocations.
Our measurements show that EA0 provides better compression than existing
kernel compression algorithms (LZ4, LZO, LZ4HC, ZSTD) can offer, because
EA0 specifically targets 128-byte buffers.
To implement compression/decompression, we also extend <linux/bitmap.h>
with methods to set/get bit values at arbitrary places in the map.
We refactor arch/arm64/mm/mteswap.c to support both the compressed
(CONFIG_ARM64_MTE_COMP) and non-compressed case. For the former, in
addition to tag compression, we move tag allocation from kmalloc() to
separate kmem caches, providing greater locality and relaxing the
alignment requirements.
v3:
- as suggested by Andy Shevchenko, use
bitmap_get_value()/bitmap_set_value() written by Syed Nayyar Waris
- switched to unsigned long to reduce typecasts
- simplified the compression code
v2:
- as suggested by Yuri Norov, replace the poorly implemented struct
bitq with <linux/bitmap.h>
Alexander Potapenko (5):
lib/bitmap: add bitmap_{set,get}_value()
lib/test_bitmap: add tests for bitmap_{set,get}_value()
arm64: mte: implement CONFIG_ARM64_MTE_COMP
arm64: mte: add a test for MTE tags compression
arm64: mte: add compression support to mteswap.c
arch/arm64/Kconfig | 20 ++
arch/arm64/include/asm/mtecomp.h | 60 +++++
arch/arm64/mm/Makefile | 7 +
arch/arm64/mm/mtecomp.c | 406 +++++++++++++++++++++++++++++++
arch/arm64/mm/mteswap.c | 20 +-
arch/arm64/mm/mteswap.h | 12 +
arch/arm64/mm/mteswap_comp.c | 52 ++++
arch/arm64/mm/mteswap_nocomp.c | 38 +++
arch/arm64/mm/test_mtecomp.c | 177 ++++++++++++++
include/linux/bitmap.h | 57 +++++
lib/test_bitmap.c | 33 +++
11 files changed, 871 insertions(+), 11 deletions(-)
create mode 100644 arch/arm64/include/asm/mtecomp.h
create mode 100644 arch/arm64/mm/mtecomp.c
create mode 100644 arch/arm64/mm/mteswap.h
create mode 100644 arch/arm64/mm/mteswap_comp.c
create mode 100644 arch/arm64/mm/mteswap_nocomp.c
create mode 100644 arch/arm64/mm/test_mtecomp.c
--
2.41.0.255.g8b1d071c50-goog
Powered by blists - more mailing lists