Skip to content

Implement MTE tag compression for swapped pages

Alexander Potapenko linux-arm-kernel lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 0 repliesNew

v9 from the cover letter

- split off the stats collection code into a separate patch in the series (as suggested by Yury Norov)

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7lib/bitmap: add bitmap_{read,write}()include/linux/bitmap.h+77 -00 replies
2/7lib/test_bitmap: add tests for bitmap_{read,write}()lib/test_bitmap.c+172 -70 replies
3/7lib/test_bitmap: use pr_info() for non-error messageslib/test_bitmap.c+5 -50 replies
4/7arm64: mte: implement CONFIG_ARM64_MTE_COMPDocumentation/arch/arm64/index.rst Documentation/arch/arm64/mte-tag-compression.rst arch/arm64/Kconfig +4 more+478 -00 replies
5/7arm64: mte: add a test for MTE tags compressionarch/arm64/Kconfig arch/arm64/mm/Makefile arch/arm64/mm/test_mtecomp.c+376 -00 replies
6/7arm64: mte: add compression support to mteswap.carch/arm64/mm/mteswap.c+17 -20 replies
7/7arm64: mte: implement CONFIG_ARM64_MTE_SWAP_STATSDocumentation/arch/arm64/mte-tag-compression.rst arch/arm64/Kconfig arch/arm64/mm/mteswap.c+118 -20 replies

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchAndy ShevchenkoYury NorovCatalin Marinas
1/7R-b A-b
2/7R-b A-b
3/7A-b
4/7A-b
5/7A-b
6/7R-b
7/7R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH v10-mte 0/7] Implement MTE tag compression for swapped pages

Currently, when MTE pages are swapped out, the tags are kept in the memory, occupying PAGE_SIZE/32 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 algorithm suggested by Evgenii Stepanov and implemented in this patch series is able to efficiently compress fixed-size tag buffers, resulting in practical compression ratio of 2x. In many cases it is possible to store the compressed data in 63-bit Xarray values, resulting in no extra memory allocations.

To implement compression/decompression, we also extend <linux/bitmap.h> with methods to read/write bit values at arbitrary places in the map.

This patch series depends on "lib/bitmap: add bitmap_{read,write}()"
(https://lore.kernel.org/linux-arm-kernel/[email protected]/T/)
that is mailed separately.

v11-mte:
- address Yury's comments

v10-mte:
- add the bitmap_read()/bitmap_write() patches
(https://lore.kernel.org/lkml/[email protected]/)
back to this series
- add Acked-by: tags to MTE patches

v9:
- split off the stats collection code into a separate patch in the series (as suggested by Yury Norov)

v8:
- split off the bitmap_read()/bitmap_write() series
- simplified the compression logic (only compress data if it fits into a pointer)

v7:
- fixed comments by Yury Norov, Andy Shevchenko, Rasmus Villemoes
- added perf tests for bitmap_read()/bitmap_write()
- more efficient bitmap_write() implementation (meant to be sent in v5)

v6:
- fixed comments by Yury Norov
- fixed handling of sizes divisible by MTE_GRANULES_PER_PAGE / 2 (caught while testing on a real device)

v5:
- fixed comments by Andy Shevchenko, Catalin Marinas, and Yury Norov
- added support for 16K- and 64K pages
- more efficient bitmap_write() implementation

v4:
- fixed a bunch of comments by Andy Shevchenko and Yury Norov
- added Documentation/arch/arm64/mte-tag-compression.rst

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 (6):
lib/test_bitmap: add tests for bitmap_{read,write}() lib/test_bitmap: use pr_info() for non-error messages
arm64: mte: implement CONFIG_ARM64_MTE_COMP
arm64: mte: add a test for MTE tags compression
arm64: mte: add compression support to mteswap.c
arm64: mte: implement CONFIG_ARM64_MTE_SWAP_STATS

Syed Nayyar Waris (1):
lib/bitmap: add bitmap_{read,write}()

 Documentation/arch/arm64/index.rst            |   1 +
 .../arch/arm64/mte-tag-compression.rst        | 166 ++++++++
 arch/arm64/Kconfig                            |  37 ++
 arch/arm64/include/asm/mtecomp.h              |  39 ++
 arch/arm64/mm/Makefile                        |   2 +
 arch/arm64/mm/mtecomp.c                       | 260 +++++++++++++
 arch/arm64/mm/mtecomp.h                       |  12 +
 arch/arm64/mm/mteswap.c                       | 110 +++++-
 arch/arm64/mm/test_mtecomp.c                  | 364 ++++++++++++++++++
 include/linux/bitmap.h                        |  77 ++++
 lib/test_bitmap.c                             | 185 ++++++++-
 11 files changed, 1240 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/arch/arm64/mte-tag-compression.rst
 create mode 100644 arch/arm64/include/asm/mtecomp.h
 create mode 100644 arch/arm64/mm/mtecomp.c
 create mode 100644 arch/arm64/mm/mtecomp.h
 create mode 100644 arch/arm64/mm/test_mtecomp.c
Signature · 1 line
2.43.0.472.g3155946c3a-goog