From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65570C001DD for ; Thu, 13 Jul 2023 12:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=fKEaRr146TdzEXJ06Ftb5tzfUVfYSAtTgZukQhWj5kE=; b=CqC NRV32B9fjytpHNghqrZbn5oPid6/JWy6ppa1/qH+XgkqSt9qVp7RMFdVolG9p0d8B2xymrzyCukFx LKeIjKGM4Jm/N+hTFo9H+tnrKSM5ogigkuFXjCnooqYTEFaK9NkyvV/PeM5Psbo4NAxeV9qDZ0EHn YaSipaQzexAOG5iPAZPZillTR0QVfSj8N/slu5EfXwiNneoZqn6uCWW83Zz0gF93SxDj9Uwkk5fhN 5qrfixHd8gjWvvn8WyY1NHon2Tgs5OIG16mdM6jbzhxb0zca31yW8U/WvsvVZ735lzG9RauEsHcdE Rmk47tgklgiufTA6gK0rwocQe5/nWAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvsj-003JfB-0D; Thu, 13 Jul 2023 12:57:17 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvsg-003Jeo-27 for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:57:16 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-cac213f9264so610189276.3 for ; Thu, 13 Jul 2023 05:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689253033; x=1691845033; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=YZVmzvDv/wEkBzFvNB2jvCzxG6CGiDCDClwpWrFVZEg=; b=kHOs3OGWZRHY462sr8GlRAigBTUHckxrZT7XE5e/UoXWp7cDnu9efMT0TzUL/VotGY ZF0GWh8CHu2/IPXoacr1ELwvnzvC9MV1hj4U8a5z+FmJbN5mquh6n1mJQ/DBZaQgXbcn xohjUkIWb1JWqX5Ughb7iMDtvlAoCO258U4VZ5+2CV0aBk/XPEXpnvnBJAPsrImJbyjL mMFB7Vyb6UJH3OrkhtLXFgQbzWAzh4hz9VTmASffooNg5ujWFws10w6rjpOrrTU9x88P myl+PwL2m9+mStlnWqlX5cAMfakhfshQRZY1lEfZCp9r7GTUbUjlQq5TlTn83Nk9J5DE kGGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689253033; x=1691845033; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YZVmzvDv/wEkBzFvNB2jvCzxG6CGiDCDClwpWrFVZEg=; b=DFpwuB9KDJgqpkOSC5egzUPCmjqBoQk9k48dxg7TglT4kOtkrYKevvdf+BzeGfuSYU BBAuOVsR5Rwj6WzUG73qonoGv5ro/54iqC87v7ALFOgAuXI7U4ZFuxUxWH9Kq+Imy3X9 OlLePj/cZNyqy7tGREa/PaBtksZJW0Cp95Dwx5vajl1Pgq8FHrSw8y7qViRuZH1DgQx4 Vh4PZFr/z4smcY3GUmE9uKEnLG1kjBM2I4ITq9qlUkKOzvxxQGPnqmqmaA2MbvvXmi7Z 79dSMOAa0nKfOL4nnW5lZRZvcL+JoAZgnKHQOGfJR3QAFsJERW0QAtC23C/6PO/gglid lkjw== X-Gm-Message-State: ABy/qLYyREV57LLjKauAY4fNJjQeSsedQlTS4UHVHZ+NNaX5+XblyAnJ POfEmxcKl2nCM57GrAFFzs/9Oif6XNs= X-Google-Smtp-Source: APBJJlGE9Zj3+QlLEq9LQgNjQ5luQsqHW9scwXLl6f++pWPyI1Gv/NRvW0Mstq+Kix2p3qhM7BDofpUZpB4= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:7a88:66b7:31e5:7d85]) (user=glider job=sendgmr) by 2002:a25:cacf:0:b0:c72:2386:7d26 with SMTP id a198-20020a25cacf000000b00c7223867d26mr7702ybg.0.1689253032952; Thu, 13 Jul 2023 05:57:12 -0700 (PDT) Date: Thu, 13 Jul 2023 14:57:00 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230713125706.2884502-1-glider@google.com> Subject: [v2 0/5] Implement MTE tag compression for swapped pages From: Alexander Potapenko To: glider@google.com, catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_055714_719600_319C9769 X-CRM114-Status: GOOD ( 14.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 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. v2: - as suggested by Yuri Norov, replace the poorly implemented struct bitq with Alexander Potapenko (5): lib/bitmap: add bitmap_{set,get}_value_unaligned() lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned 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 | 412 +++++++++++++++++++++++++++++++ arch/arm64/mm/mteswap.c | 19 +- arch/arm64/mm/mteswap.h | 12 + arch/arm64/mm/mteswap_comp.c | 50 ++++ arch/arm64/mm/mteswap_nocomp.c | 37 +++ arch/arm64/mm/test_mtecomp.c | 175 +++++++++++++ include/linux/bitmap.h | 63 +++++ lib/test_bitmap.c | 34 +++ 11 files changed, 878 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel