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 2D44DE81DFD for ; Fri, 6 Oct 2023 13:46:11 +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=utKG0Q78X91YM5bCLSyA3Ok+Be61sWgwUZB6VRqnRR8=; b=sM1 xZyc43P/042E42w/l6u1wDwsQqVhJTlTJ17f5Jo5jpgRF8FYk3NqaPhALSCPwOR0DDUOX93attx+s L6quZ5+8oLSuL5Muhd8cZQ6MibwFWOe4cEW72aKN731fmB3mODNTNulNw9NxwJzKZhZk2cIf8vrVw nfGk7bX+dvfKtsUtR+JThHrESDYwvB2PEPpHbau5RI7j207rwR5ShMRUwuKythxq+a9RjZqoOHlVy k/PwZOtp7X/O/TtXliIzBzrrC2nOl6NJQqMRBvO4DgdH37pkM/4d/y/vpKQH27y5sYwtfqKbfUZtG FwqpseRbUCx22fRCpxHxBGEBQo5PTUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qol9A-005uS9-0o; Fri, 06 Oct 2023 13:45:40 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qol96-005uND-1i for linux-arm-kernel@lists.infradead.org; Fri, 06 Oct 2023 13:45:37 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-32323283257so1585669f8f.2 for ; Fri, 06 Oct 2023 06:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696599933; x=1697204733; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OtrAKvkMflYTL+omQBnC5NvMsnVi6sQ3TFEd0qd0ZG0=; b=pwcLUIiEMLlbNiXoEYO5EemFa/LupZ1XfKrt7s/oYSe8CQUjFVSqAN8p7aOgHfT8eU oh6/6fD9kyHMLekzsl8ClCKtVZGxTsYZjfKHA4vGiP+4m72dvLye5/xiq1CtvUy8dVJj jGXS0TM/SqAxHmvPE9Wyqbe3hcKXZLs078c8UK6kT9UPE2GmVCPU49a3680IdKQtY28y QXTbplcB6GhGZxrMLI1biOsDlTomI+8IcnhtKrIrepmlzQLS92iIcK08HhC3eTpysoxT cXNLoNVobV8LUx+K26Kyj4K5/FxYxSChVqfae3MrusQVvdXci+Sp5vp3t42cyzvt48XE iNVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696599933; x=1697204733; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OtrAKvkMflYTL+omQBnC5NvMsnVi6sQ3TFEd0qd0ZG0=; b=mviGnSVKCglw3vzjZJe9jb8HnrIDT2W+ruyHto59SkTkgdEQuyX34fS4k83BX/TjaL 0DnMv75MvGFIrDKVvmXbs61Pz1Z6HjB0EcoUKx6KgWL3yiJ4WUDmf/ALOMtnf0FPCUxH jNC1QmOSVuTQbvH5kQUeG+M69Hes0qcAVg+Dqfe0Zb2H8zc4eGac3LDpc4rj5YjGLklF aHvANoc3TUjj2SgS1R6N1HTOXKfuZuj4FDPVMY+PUPcqXGXLxDz0LcrueDNXH2XiCXCO 61xRNzM5Fleqyvn0Yu5o3ZO2ERFdivQCAIekq/DUyLtG5VqJM3AkwkZePCcCeX7UVky6 47HQ== X-Gm-Message-State: AOJu0YzP+t9Bb7aeXl7YdcA6pvdtBGAOJAoXUFPskNyIxtqZOW47/J+E xRSchTHAjo02yFqbgvGKr344fSX3wW4= X-Google-Smtp-Source: AGHT+IGb2cjEpqpBiIxzfPcD7K+9H+vfdX5CJqGEai4UM1Lm/lfEASgpnVc0FwnbuY0gHX3Q3GYs/ydoebc= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:2691:23e9:f01f:964]) (user=glider job=sendgmr) by 2002:a5d:6549:0:b0:319:8430:f801 with SMTP id z9-20020a5d6549000000b003198430f801mr52714wrv.2.1696599933422; Fri, 06 Oct 2023 06:45:33 -0700 (PDT) Date: Fri, 6 Oct 2023 15:45:24 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231006134529.2816540-1-glider@google.com> Subject: [PATCH v6 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, aleksander.lobakin@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-20231006_064536_570712_4C275E02 X-CRM114-Status: GOOD ( 16.04 ) 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 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 between 2.5x and 4x. 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 the proposed algorithm provides better compression than existing kernel compression algorithms (LZ4, LZO, LZ4HC, ZSTD) can offer. To implement compression/decompression, we also extend with methods to read/write 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. 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 Alexander Potapenko (4): lib/test_bitmap: add tests for bitmap_{read,write}() 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_{read,write}() Documentation/arch/arm64/index.rst | 1 + .../arch/arm64/mte-tag-compression.rst | 266 +++++++++ arch/arm64/Kconfig | 21 + arch/arm64/include/asm/mtecomp.h | 13 + arch/arm64/mm/Makefile | 7 + arch/arm64/mm/mtecomp.c | 524 ++++++++++++++++++ arch/arm64/mm/mtecomp.h | 12 + arch/arm64/mm/mteswap.c | 20 +- arch/arm64/mm/mteswap.h | 12 + arch/arm64/mm/mteswap_comp.c | 60 ++ arch/arm64/mm/mteswap_nocomp.c | 38 ++ arch/arm64/mm/test_mtecomp.c | 377 +++++++++++++ include/linux/bitmap.h | 68 +++ lib/test_bitmap.c | 118 ++++ 14 files changed, 1526 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/mtecomp.h 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.42.0.609.gbb76f46606-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel