Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1721328rdb; Wed, 20 Sep 2023 18:48:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtztYTdXRXq/lO6NTspL/4SB3+/GmP6oWCLZN8Nt2sv1nCVu2j2zXsp/rvabj3nJGtpsDI X-Received: by 2002:a05:6808:1524:b0:3ac:cf91:9160 with SMTP id u36-20020a056808152400b003accf919160mr4459862oiw.25.1695260925860; Wed, 20 Sep 2023 18:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695260925; cv=none; d=google.com; s=arc-20160816; b=TaZfBYTQ+ogb4SYmIuRYC9xMn9ikThLL71QUbSkXfqHcfDmLi6fjtXY69xfvSWuIKH 5/yeYZ/xLCrUTVtu7zF/sTfzYKjv4ekIwg8+bHTOGgowcHUIoVU7+kKG84/6CZFuP/vF dZ0wOzQYJdBO9NTYVE4CN1HJ1MydYDHTnV4gBGF1b0HDiwLIr7TfJGMhtTjjqhhSfNl8 pbi5p7xB1UjM/BMS5RGqjhCgpwfym0axd55np9ahHYhRn7RXSLNZ8aFIi8qmHU+l3bUO bWLIcIcOHyiLvZBJT/V+7D7o01Seemwooph+PFFMV0DoXRak9jCM7yl0ERJZ0ZoklnnJ oNKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/ukh8ZYDZxvX82LAHODROHiMYMv5lCVVYc8LANKub40=; fh=rZ2u9L9SX4HofeDcI5LwNFoDzrXZPEl69bFOlY0yugw=; b=ymmZwRP7Zv/8AbfNZhjDNbp2KhlTYpPoaHAjTQLO2uhNeVMpZzWtIr0xat4SW0b+ch KI1j37jBIQXE7DfH5mty5judcFr4vJhxNnGbeDDroKKlRXLESK6xx8yWadXY0iOR0MB0 dRvHBsshTJNPHM+DD9WFORZ2vFwNv9VAc53QbseD8KzgJ2bNXBhpazzPcHM7U6igbpNI H4cVxWqk2TCHfMD3J0OO2+24WJ0YiNovStCosRWeWe+yZvLA5sc1klMLx7JO0Rgfeae/ wKRjSVMDqJZXUcOZx5qU1aGDXI0YPTA0hM9+N/2vV3sE7RprkxuifL7vuydx2AeSZGUx I+qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kFEcw3wG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ay7-20020a056a00300700b0068fdc320483si393781pfb.225.2023.09.20.18.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 18:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kFEcw3wG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 649458263E9B; Wed, 20 Sep 2023 07:23:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234726AbjITOXj (ORCPT + 99 others); Wed, 20 Sep 2023 10:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbjITOXi (ORCPT ); Wed, 20 Sep 2023 10:23:38 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA42AC6 for ; Wed, 20 Sep 2023 07:23:31 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79d1a920137so153191239f.0 for ; Wed, 20 Sep 2023 07:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695219811; x=1695824611; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/ukh8ZYDZxvX82LAHODROHiMYMv5lCVVYc8LANKub40=; b=kFEcw3wGbpXHgOkomTnM6RvVR5NU6pwZgim0jcjudWdA7aR9b/j2AZXr9ekA4v4w5z IFP2YtAiOVL8ln626EUFhdXOvPhfNu5sOIVnu/pfRw84nfXecJEkYMnC0WcImqc5s27u ++PKT5nSf4hadOXr7SxCbbN+YptMwrb5JNi4TjTOeh+AxeMV1AzLqwM/KuYWRiAcCQBs OLZU9CY0LTnQn1DlTMt6XnKm/P5DeRXHmoniRcXwUdqPshrIQvwNiZrvNDaXhcpalkSh omJaYLuGN8+Q47Wr/w7rmdgX8+gplTmXtYBJWrKPClDgkm5bDtcgv3L3QZ3F715U2g52 S85g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695219811; x=1695824611; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ukh8ZYDZxvX82LAHODROHiMYMv5lCVVYc8LANKub40=; b=YLHAJbt8ABWlsHVlL3DdvOhWEz8f04Xu1ixc2M5C+X/2w1vp3IlZmNufC9taiLf8A6 Y7yQFa1EXjrd25J/WDCOVGalYvgb+6UuZRzUoSSQ55myZvhaaqG3b/hPXx4QaiR5lzUs IVJIXYSl+G8iTd/7Wj2wLDHZwRkQFnQVWAh2XL4Neoh4xxX+YB0uFHd7mc38YCJhrjXu fCoHV6hwPLfB4CY00Vs2Z3DiqHt6h/+OLK65XJKOdkGKyVTAxHZT8k2SXD4xeoi6xa6R qAUV2fE7wIVDCLncQcFepps92+03wYjsY9/S45UsO3h6papcu2GUPXN5KGigbQccnDJY /Ecg== X-Gm-Message-State: AOJu0YyfaXkUbv6SiERZmbWJoErHcRc9nbVG5F8cj26kaewstSMmnXEw 6c9CPz56VmGrmmgaUYRZf4zm1HxClJLIn6Wtfu6yaQ== X-Received: by 2002:a5d:9384:0:b0:791:1739:d525 with SMTP id c4-20020a5d9384000000b007911739d525mr2617835iol.20.1695219810990; Wed, 20 Sep 2023 07:23:30 -0700 (PDT) MIME-Version: 1.0 References: <20230720173956.3674987-1-glider@google.com> <20230720173956.3674987-6-glider@google.com> In-Reply-To: From: Alexander Potapenko Date: Wed, 20 Sep 2023 16:22:51 +0200 Message-ID: Subject: Re: [PATCH v4 5/5] arm64: mte: add compression support to mteswap.c To: Catalin Marinas Cc: will@kernel.org, pcc@google.com, andreyknvl@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com, 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 07:23:38 -0700 (PDT) > > Anyway, it would be nice to see the full picture of what the savings > relative to the total RAM is. Given that the swap in this instance is > zram, you have an upper bound of how many pages it can store. I'm just > trying to assess whether the complexity added here is worth it. Assuming the average compression rate of 2.5x, and the share of tagged pages being 20%, we'll be saving 0.375% of the swapped memory: 20% / 32 * (2.5-1)/2.5 With the compression rate of 4x and 40% of PROT_MTE pages, that would be 0.9375%, which is tens of megabytes (probably still a little though). > > Maybe not as good as the RLE algorithm here, I was wondering whether we > could use zswap to save the tags together with the page. I looked some > time ago at it seemed slightly easier for zswap than zram. Android uses zram, so unfortunately we'll need to handle both. > Another > option is to make the swap format more generic to support metadata > storage. Yet another option is for the zram to flag that it can compress > the metadata together with the data (no swap format change needed; when > decompressing the page, it populates the tags as well). I haven't looked into this, but this might sound promising. We'll have to copy the page contents to a temporary buffer holding both the page data and the metadata, but it might be ok. Another idea you've mentioned in one of the other patches is to only compress the data if it fits into 63 bits. Looks like this alone could yield 2x+ compression for 4K pages, and will spare us the kmem cache juggling in this patch series. > -- > Catalin -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg