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 4D53EEB64DD for ; Tue, 11 Jul 2023 14:43:08 +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=WK2BjvKtJTiwbjg1Qqaggowd6Ek7Gb3Lcz/TAZkQKmU=; b=LpO 92+C9YWprHITjOZnsbuG2n/eXDVh2yI/alyc1d9G+PBE9m324EebCgoEz3g6utJEHGQ4RWimiA0XQ wt22oRD9j0+JfD1zflJxnXAIRwNam+5SwbMOQHdMCcWSNxPecj0HvqU5/912tmQMg5JryRsw81zXp HSH/3ZCLHzB99OKFlejjCq6YYvzuoJHzS9rewLEQTJvbPFTCWvmKnpVALehNruWADKXIFer8jyTzH ehPZoXiwY6LwxLaf03WZRU87OS43QuxXjorarLio4V4T/jmdRl9VOlQ+rpu5W/QhQ8prFK5I8wgK1 uwqA5/i5PsXdaUqTVbCAqPWKbyRSRpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJEZe-00FABM-0V; Tue, 11 Jul 2023 14:42:42 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJEZb-00FAAe-1k for linux-arm-kernel@lists.infradead.org; Tue, 11 Jul 2023 14:42:40 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-57059e6f9c7so84683017b3.0 for ; Tue, 11 Jul 2023 07:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689086558; x=1691678558; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=JUYDVerV8URpwGJ6F0fNfWvwfXeGFLCwYeiofYpp/QI=; b=FqXpeZjc4sttpuWzmF3jWCSEBcVkYsunCs48g4nQPBHG01elPa9vB7+xnkIcnUlOc4 IZ86oal0oY7zOPlMq4NxW48QHHGG/Y1DL1ZLVxNQNzZhsSN1uzOwFLRwJ6wL9t3vSDYO FGIUxXokO757d1lZ6tmoruS6re+Kj+2bkUxvxu6MIxOSqdJNf3D4sQI+yF5ho4KAR0x9 Ayn7RicV+Kr+klHsefaDAk+AjhlCiz72Sf+zpbK9COQitEzzbi0IlzQ7yoUxRX58D4Tx CtwuG3Sh9AAVrlIEGQfWSrBUcho3i7hzbS5PUG9RjNQjnERlbzMOy4d2bK96VK5DHI6+ fIVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689086558; x=1691678558; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JUYDVerV8URpwGJ6F0fNfWvwfXeGFLCwYeiofYpp/QI=; b=P1kV5Po//tG8Hm3L6rToH6rCQ6B2l+qp7Ad4qrh7Khq12HzLNpka1ucdK3OM0uOKVm mxBtghm51IswJTJseT5NwGv30PSV/F43pufWQGOQ0sVhEyPQ2oBpwuNY4/oKZvx3x77K DBnZT6v2Z00cjuMks8S7JssefVwaM9Vf2R4or4sBQHJvWFxLbJYxEUfnJjicTsvbk/Zw drNK/1NuJaRYRiD5rwrjD9u/zn2avXfMAYf/qmqoS59x2XQcGs9YH8mAUxUBBdP8N9Lo vZPzwq2n5U0AinEKi/5HhCT+RvpMMgVoS7ggScGFTsLwOxmsQWbybpXfojNw00XB05+O rtXQ== X-Gm-Message-State: ABy/qLar/d44ABLh4EuPcTlKmb4GuWeYXnlC2hG9JpULV4OVGp4cfGdh 1oRYhOXsXaOh4B0fVZtpSbzBG1pnqdI= X-Google-Smtp-Source: APBJJlG8H5mxRAaZPSqfDthhmY3+Q9TwHSjryqeG2QVFvwHLl2FTUuvh4e8eI7hJ628wohDrg1Uo9DDM7Wg= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:564d:3aaa:6b5f:4419]) (user=glider job=sendgmr) by 2002:a81:aa53:0:b0:577:6462:24c3 with SMTP id z19-20020a81aa53000000b00577646224c3mr269427ywk.4.1689086557872; Tue, 11 Jul 2023 07:42:37 -0700 (PDT) Date: Tue, 11 Jul 2023 16:42:28 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230711144233.3129207-1-glider@google.com> Subject: [Resend v1 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 Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, yury.norov@gmail.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230711_074239_587102_16301ABE X-CRM114-Status: GOOD ( 14.03 ) 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 introduce , which provides a simple bit queue interface. 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. Alexander Potapenko (5): linux/bitqueue.h: add the bit queue implementation linux/bitqueue.h: add a KUnit test for bitqueue.h 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 | 398 +++++++++++++++++++++++++++++++ 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/bitqueue.h | 144 +++++++++++ lib/Kconfig.debug | 8 + lib/Makefile | 1 + lib/test_bitqueue.c | 244 +++++++++++++++++++ 13 files changed, 1164 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 create mode 100644 include/linux/bitqueue.h create mode 100644 lib/test_bitqueue.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