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 6AC41EE4981 for ; Fri, 18 Aug 2023 17:57:47 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yOZxGb8wlR2XYnLdwxguZaqhodQ9RT4ZgsWS/Agg9Z0=; b=qmZQ7NbVY/sLeB ZTe0Ins31GAVExSlUmU3bVlSAcysM97slI/VysApsmUIQRPflSJlMkjKlfsrp/BHSZgW3nrDaP56j x5Wew+Dr8Vde+Igr4hCbTDjbPdB56faSwGXiMaM72ppHUhCugOuW+ulyvKCggyZX5ZNTzxiPb6m5m t3+SjdUU2Cf7mhUsrii14cjCqvaldFAdCxRj8sG5J7ZtvsJob1v9Lw8Qe8oumfLlNI19qgxxzx2Gb +Dggp2n5ykZJ9R4SXp14JOLOnVuW+rqsKM1Mx9zXQm5HKVAwsLobUV4L9J3d8lGA+Nrk0CBVA4epP +lBeQfxvLDDFjCHfTvyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qX3it-009pzu-1E; Fri, 18 Aug 2023 17:57:23 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qX3iq-009pzU-1D for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2023 17:57:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB02E65EDD; Fri, 18 Aug 2023 17:57:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 484C7C433C8; Fri, 18 Aug 2023 17:57:17 +0000 (UTC) Date: Fri, 18 Aug 2023 18:57:13 +0100 From: Catalin Marinas To: Alexander Potapenko 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 Subject: Re: [PATCH v4 3/5] arm64: mte: implement CONFIG_ARM64_MTE_COMP Message-ID: References: <20230720173956.3674987-1-glider@google.com> <20230720173956.3674987-4-glider@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230720173956.3674987-4-glider@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230818_105720_498136_AF645313 X-CRM114-Status: GOOD ( 24.57 ) 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 Just some random comments, I haven't reviewed the series properly. On Thu, Jul 20, 2023 at 07:39:54PM +0200, Alexander Potapenko wrote: > diff --git a/Documentation/arch/arm64/mte-tag-compression.rst b/Documentation/arch/arm64/mte-tag-compression.rst > new file mode 100644 > index 0000000000000..af6716d53c1a8 > --- /dev/null > +++ b/Documentation/arch/arm64/mte-tag-compression.rst > @@ -0,0 +1,212 @@ > +.. SPDX-License-Identifier: GPL-2.0 > + > +================================================== > +Tag Compression for Memory Tagging Extension (MTE) > +================================================== > + > +This document describes the algorithm used to compress memory tags used by the > +ARM Memory Tagging Extension (MTE) > + > +Introduction > +============ > + > +MTE assigns tags to memory pages: for 4K pages those tags occupy 128 bytes > +(256 4-bit tags each corresponding to a 16-byte MTE granule). By default, MTE > +carves out 3.125% (1/16) of the available physical memory to store the tags. > + > +When MTE pages are saved to swap, their tags need to be stored in the kernel > +memory. If the system swap is used heavily, these tags may take a substantial > +portion of the physical memory, which in the case of a zram-backed swap may > +even exceed the memory used to store the swapped pages themselves. Hmm, I'm not sure about this claim ;). Is the zram so good that it manages a 32x compression (4096/128)? How much would we save if we only do the compression when it can fit in 63 bits? > +/** > + * mte_tags_to_ranges() - break @tags into arrays of tag ranges. > + * @tags: 128-byte array containing 256 MTE tags. > + * @out_tags: u8 array to store the tag of every range. > + * @out_sizes: unsigned short array to store the size of every range. > + * @out_len: length of @out_tags and @out_sizes (output parameter, initially > + * equal to lengths of out_tags[] and out_sizes[]). > + */ > +void mte_tags_to_ranges(u8 *tags, u8 *out_tags, unsigned short *out_sizes, > + size_t *out_len) > +{ > + u8 prev_tag = tags[0] / 16; /* First tag in the array. */ > + unsigned int cur_idx = 0, i, j; > + u8 cur_tag; > + > + memset(out_tags, 0, array_size(*out_len, sizeof(*out_tags))); > + memset(out_sizes, 0, array_size(*out_len, sizeof(*out_sizes))); > + > + out_tags[0] = prev_tag; > + for (i = 0; i < MTE_PAGE_TAG_STORAGE; i++) { > + for (j = 0; j < 2; j++) { > + cur_tag = j ? (tags[i] % 16) : (tags[i] / 16); > + if (cur_tag == prev_tag) { > + out_sizes[cur_idx]++; > + } else { > + cur_idx++; > + prev_tag = cur_tag; > + out_tags[cur_idx] = prev_tag; > + out_sizes[cur_idx] = 1; > + } > + } > + } > + *out_len = cur_idx + 1; > +} > +EXPORT_SYMBOL_NS(mte_tags_to_ranges, MTECOMP); What's with the exports here? Are we expecting these functions to be called from loadable modules? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel