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 B5BF6EB64DD for ; Thu, 20 Jul 2023 17:40:27 +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=MES2Hi3Lz8lPuNhpBZ5WZsQfYz7lQ3I8FLVZzacqOyM=; b=rOm YRVXERAx7nI4z5dBMDccchzzv1Ywk0zyzfc0VqzxLi5AJkFAZBC0/1DWqkderfNUbdaSVYNMToWo8 V7XqZv7EqwgOgULlcCHh6IgkLRurAg8IGYH9tMNv4BrA5n4/GUtwUVb2Wi09TNHzYc5bnT61BubRm xUovbWW3i1uZnHCg2h2t6HIelZcehfFXHdlXRtWIDQFWuV9LSTR3vhr2NVaCHRvw7wpNAxbfWGqFs tsYVdEnuQyd4WQ8oVJOa3ZHEBMpijLV6/I8Nz3xI/1NSf/BXXMfH9lhHR1QkKM5dlJTfMPnexmexY os2gPbkn6Dnu4oShbCrt4dgaEUxksgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMXdH-00BoMr-32; Thu, 20 Jul 2023 17:40:07 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMXdF-00BoLO-1V for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2023 17:40:06 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-cffb72c1d6dso459897276.0 for ; Thu, 20 Jul 2023 10:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689874800; x=1690479600; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=QXAvwU8PCBDNP3WmfE01iwMkKtvsYZg4exTztqekXrg=; b=44CqHRSEm6INB+DXI2owqq2rdfKaoCskgqstxzTUuCE3JQY7euGu3GtKuqfhJ4Azsa daoKakRV1zO3kP1yLp8rhhvktP8/6Hv9+cXkqRxEjOMDGns33sVtj+bn96QPQ4/e+Xa8 LLkDt01HZgrhuHnATUXoazGZv/vBu06YVwmivVz2KpzjLq+2Hy0X092bwj9aEziA328w B2vsDnuPmvSw8B9bNIDB/O3U67ihWHNXgLyMOHIc8h22K2VqOXHoF+84nMTNzQyxblaP McMT8Jb633yicJf4ovZGX5/YnY7DVMjOa5SEOSlp2M6R0+DDGk8kPtjghuqbM2OmGQsS FLJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689874800; x=1690479600; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QXAvwU8PCBDNP3WmfE01iwMkKtvsYZg4exTztqekXrg=; b=g4AWXElq/0TheqY4iPbMHLJUe15L1V8u/rKme3jcq6W+6VRqeDKV+pD/tmlLj4iHA/ M3PWlyOde3+VlqC8LmbibRUgbSbgAfO8W9F/xAH4Q4eJml+nNMtoXo6QNJ5THEsVPiJL +Swzwx+eABAdTFS4bSMaYhDdqAvSLyrl4pnBEKVjmrFDQg6RK8bpQPsegY78lNSP2P02 0tldNqzDlWezpScxdhGsjlZY9nC7Y9jQefGveaP2089XUhgYqwDJ6chSt1btNCaTi1D4 9+CtGnb8ajqnsDH9YyGqfWlA4ur8P3O3e+iX3YZ4oSoZIcrswo+F1XsUJJ6GYQt81ngk Nf/w== X-Gm-Message-State: ABy/qLaP4Q0h/uKRFfd6la9OhG2sIn83ZMCfhTMjUad1ahxEjJx7V0yt /S2KRZu7jICOYkB4EtP/f/MZTIeCMq8= X-Google-Smtp-Source: APBJJlHcrSfGWICYrKCTQHwEKkGwtJESJFM4ZLN4JtQZ6u5LVrtT+xoC2j69M0nDoBDlMsg511qhRE/wdPs= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:c495:c29a:e275:1dfb]) (user=glider job=sendgmr) by 2002:a05:6902:10c5:b0:ca1:abd7:47d3 with SMTP id w5-20020a05690210c500b00ca1abd747d3mr50018ybu.9.1689874800280; Thu, 20 Jul 2023 10:40:00 -0700 (PDT) Date: Thu, 20 Jul 2023 19:39:51 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230720173956.3674987-1-glider@google.com> Subject: [PATCH v4 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, syednwaris@gmail.com, william.gray@linaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230720_104005_550166_CC2A2BEE X-CRM114-Status: GOOD ( 15.01 ) 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. 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 Alexander Potapenko (4): 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 Syed Nayyar Waris (1): lib/bitmap: add bitmap_{set,get}_value() Documentation/arch/arm64/index.rst | 1 + .../arch/arm64/mte-tag-compression.rst | 212 ++++++++++ arch/arm64/Kconfig | 19 + arch/arm64/include/asm/mtecomp.h | 13 + arch/arm64/mm/Makefile | 7 + arch/arm64/mm/mtecomp.c | 382 ++++++++++++++++++ arch/arm64/mm/mteswap.c | 20 +- arch/arm64/mm/mteswap.h | 12 + arch/arm64/mm/mteswap_comp.c | 54 +++ arch/arm64/mm/mteswap_nocomp.c | 38 ++ arch/arm64/mm/test_mtecomp.c | 217 ++++++++++ include/linux/bitmap.h | 60 +++ lib/test_bitmap.c | 81 ++++ 13 files changed, 1105 insertions(+), 11 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/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.487.g6d72f3e995-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel