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 8AB1AC4332F for ; Thu, 14 Dec 2023 11:07:21 +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=HGuzviD8r/TWcsAsvSzqcOq+Vif0cdm50XLzNo4hzr8=; b=RVb 0UAKBiQ1tWsgSMrgrMMumUVkOXNuulgAmOvQGtAGKySJAFtGK6Z/pGZ1iLSE4kPTGYzAa2vkyyeBD vz0cJdYwIMlZkeiit4WwvydLtFN1dl2I4lHJAe/A9aTRusv4pUA4GBD949ZjyBuaO94ec9h8wXRc6 ajqe6MZYAc52r7CGVdQhK6z6FonPMvltFAkaszfToRjE59fXwtNf6A/zgzyg9zJlbPeBGDYxvNHUG CenlU4XDiO5QjlLUfm+B+Rz8hVlyqJg6nYCmEiJevMKOTMpoOV2unEAuDP/WLlKq1ndE0tPq0uH1K jVrypCS4g0N+Bst5pG/BYSRzBNH8sBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjYK-00HZt2-1A; Thu, 14 Dec 2023 11:06:52 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDjYH-00HZs6-1Q for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 11:06:51 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-33637412100so1407304f8f.3 for ; Thu, 14 Dec 2023 03:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702552006; x=1703156806; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=SxQzspHe7zUTJxgwsmv/wupQFTZZ1fYtpU5Xj8U0vX4=; b=SB+M2DzIKCj1QJWBFHPFzHOY2ZnarracOr6qavHmDlWBwMZoHOTzZnfzNBMlZuznUv odFvlPc0GMlcJRWYcNqvSlk7a4rWTIwTYprilS3KhMt2+2TLH6yNe+cyFgzojurSWSLy dR3gQ7I1EIJaShpvsEMW4pujp6IRmU0no4n2y3VdujzcWIKVODR+Q44xzzxFkvs2YemY 3rk235scamY5JLSKgPrlODGHSJsYt1G4XXAuOjsAtdQMuD4DAxewGrpyYzaXc36uFd2C 2RzwwaqzUjpgoxeq6/piiCGJf89ZzDOm2qGk/4yK27IbAK7hrM4gmufg202hkS7iDEX5 urmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702552006; x=1703156806; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SxQzspHe7zUTJxgwsmv/wupQFTZZ1fYtpU5Xj8U0vX4=; b=TznQMyHYv16/EOYoX2qBCbfcIkQSdz+pZOmJFxyh5vSKpXx26bksY38330tVaXYNzM YL8/FtqW1rG76Jvj0SPvmxCuoSwd1AquiMC4yunLgMgyBosn3ipT0CbPpG30K0bIHQ/R H6WKqUjbu/HaoeWKQgPZei0N1GTV+iYwhltmN+aZeDGKx6EWOBHxDS/sKCfUbKpAy8/S EENYdN3UVAIH1JOvmPWIQRPT8CpjvdXA49j/2VtVrZZODjsE5z6wkY9JLwOTZwUN0EkS JO9H5TBdKm8ZI+KJUJ6lUbW3/0zIRoK85SkYqqeq2DAnr2aYcMWJ/JtcTRlpgmV99SHM pykQ== X-Gm-Message-State: AOJu0YxCmR/iHpdtdYD//+0clOis7vKI2T/gsD+GXqwS+PeaOIR1Pves D2ZvDVkX28MSB3bCvMk7feNPqfFYe+o= X-Google-Smtp-Source: AGHT+IGMKnQPwwwiWWoX0llBK0P2iontezG4gLDcsQN7qdh3Rh6ZSgqvPXK9BoS6aWvD7C6GcGIHC4Tvkss= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:8447:3e89:1f77:ff8a]) (user=glider job=sendgmr) by 2002:a5d:64e3:0:b0:334:b38b:6deb with SMTP id g3-20020a5d64e3000000b00334b38b6debmr54429wri.14.1702552006212; Thu, 14 Dec 2023 03:06:46 -0800 (PST) Date: Thu, 14 Dec 2023 12:06:32 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214110639.2294687-1-glider@google.com> Subject: [PATCH v10-mte 0/7] 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, alexandru.elisei@arm.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-20231214_030649_495356_9C032B6A X-CRM114-Status: GOOD ( 16.14 ) 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 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 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/20231030153210.139512-1-glider@google.com/T/) that is mailed separately. v10-mte: - add the bitmap_read()/bitmap_write() patches (https://lore.kernel.org/lkml/20231109151106.2385155-1-glider@google.com/) 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 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 | 257 +++++++++++++ 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, 1237 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 -- 2.43.0.472.g3155946c3a-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel