Message ID | 20231006134529.2816540-1-glider@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp342494vqo; Fri, 6 Oct 2023 06:47:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCvcNYJ5YEMlvNhh1LBmuzpFJxjrS2mo8X+975yJ7vSN/vwlg/xUZzXf1sWEmEZwfL3AZI X-Received: by 2002:a05:6358:2496:b0:13a:cb52:4837 with SMTP id m22-20020a056358249600b0013acb524837mr8187486rwc.31.1696600020048; Fri, 06 Oct 2023 06:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696600020; cv=none; d=google.com; s=arc-20160816; b=j1oNX2eXmzz+TyoeM8B6s55ormt/j0x3oUY9AIGqALNgFKYmc/X64APxn3pfpTSHqX Vqw7CrBhI3EaPZygvYoqCGjwvyQFKyp3+YAe6dAVDJXgWdKxkhcIw5XM2/HEe3lLvmGq m3n/ckkOUWSV1/OoBnfQH6zU+lYtj3dmPxC791Hvy7Lp/2qYhuEfyiA12deiDUCpXSmM yhGWV8BwPW321ULqPIN5eXWQyy3Olyf8KE+QzWduS9Pw3bykJ3B4BXAm1+oRD2g3Dx0S BWI9asu1In/HekMFI68TLn3iju3Hh5TlNogKmqChUlKke4DpjM6LEGGkNVAcodRgWdJu zRNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=OtrAKvkMflYTL+omQBnC5NvMsnVi6sQ3TFEd0qd0ZG0=; fh=GHXKbtOfxidcL5p0HTnB6bho9FCoS3xq7NN3kpYT/tU=; b=GF0q+TLYt/ZRKH4tcWzzC8lpd1Aw9M0llG8Ec5FGP6gzXpAV4OjAWE8M5y9ZfqaT28 DQniL5xNAJvKB6uCHfWG0YRUV/FuU9pDNFtgaw+jhSPAh6NlW7wDA4CRgoZmTxGMXOCy TbkuZd+VQ/5y+F55YfpW82/srb5V0oSqSU2ArKN6MoLM7VEO11530+zDK8ZWgSVpxhrU TSJqJuNA6datnSbg3j+AP34z7Cr3uOQNsMprhPd9M7uVph4c2jfaOke97dEIOAcWZVTI lXffBxEn2xaEIfyVakN9WDy3xrLx5xlG9nH7cfq94aWd3M7r0uKIMOgiD2QM3LfsFXSE jlyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="O4T9lU/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id lb11-20020a17090b4a4b00b002777b6d0cabsi6206181pjb.89.2023.10.06.06.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="O4T9lU/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 92B7980B288A; Fri, 6 Oct 2023 06:46:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232622AbjJFNp5 (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Fri, 6 Oct 2023 09:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232545AbjJFNps (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Oct 2023 09:45:48 -0400 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F397181 for <linux-kernel@vger.kernel.org>; Fri, 6 Oct 2023 06:45:35 -0700 (PDT) Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3217fdf913dso1583510f8f.3 for <linux-kernel@vger.kernel.org>; Fri, 06 Oct 2023 06:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696599933; x=1697204733; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OtrAKvkMflYTL+omQBnC5NvMsnVi6sQ3TFEd0qd0ZG0=; b=O4T9lU/mURNyyyqIs88yj3Vtxog5kQ6+cPcru/PnqPMoyolZ6wtZtc8rQo4JLpRKc9 +mMS9cDF3VNgS3AAXQAtgZgwPDaGKRIKg3+xBZWlck3tHQzYGT7xeKY12NBzfIzyqV0e HkkJ0PKYvKlHsJLyBnyojVrtm6jIx+0gx8OkvZcuIh3e7dQ/ORcN3HeVh57MFyzzi7zO DlFakDhbZqzgZqJP/P0eMOT6ZCD8g/Ep7VcWgBRlGLsrm9mXFpqX4s7YDTF7K1OR3ZpL i+Vl4XdO6bT0VdZE5MwTTMZ6hVoYYAKqWs0aHXiAVhQCVAwA0KA7XpOhKQoJxPZofw8e B9Bw== 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=QK6OchyUsxw4k9jLEhnPHcA3/ChKJaxy45O22R7Gk8WiE4I3jKrWpNnD6PzjbJInH+ XI0tVLAQDSiIyyq5xNlsmhkX2QDJxoKNiKRRk9l+vCn05MLLMlozWhHwFv8NLV9aSBvl eaqQj5E9GpBU8Z7wpz600Tg2PkXZWbXh625n7ZHLT0p/RPvhXcYVFCixPJn9RUJFC4CF ps6s89bndMmHAGYi3SuG5UI+pdljhedbVBZ4YD2okpFhM+OSjFuDrOHxM75sVFn6mtzw RconZ6gTkkUIeLmUHAztzKyfrNhv1K2G77weT20vKhEvEvbstG/Rx4NkVNpNCB5BOAi+ FVDg== X-Gm-Message-State: AOJu0Yy7duGhlwpI3Pm6/7Gpq2hLTJyDmk8h1AOiwUFZ0xMx/YaOj5Y8 aq7pgOiKSeDRRYYrDSW+OzbDeyRwUCk= 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 <glider@google.com> 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 06 Oct 2023 06:46:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779014062596515035 X-GMAIL-MSGID: 1779014062596515035 |
Series |
Implement MTE tag compression for swapped pages
|
|
Message
Alexander Potapenko
Oct. 6, 2023, 1:45 p.m. UTC
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 <linux/bitmap.h> 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 <linux/bitmap.h> 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