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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD61EC5475B for ; Tue, 20 Feb 2024 16:03:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20E9E6B0078; Tue, 20 Feb 2024 11:03:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BE926B007B; Tue, 20 Feb 2024 11:03:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 086AE6B007D; Tue, 20 Feb 2024 11:03:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EB9B76B0078 for ; Tue, 20 Feb 2024 11:03:22 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9192412050C for ; Tue, 20 Feb 2024 16:03:22 +0000 (UTC) X-FDA: 81812651844.19.FDC3756 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 371B04008E for ; Tue, 20 Feb 2024 16:03:13 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708444994; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0aGAmYxxRfRThGc7f2rGLmlxEY3DA7SVM1HuwdZ8mI=; b=uRXafQYbHBygVaNTc3SVRomN/q9w3nYTBy1BTM8RnzPhzk3GnP7E/BTf/CoeXJsDJpM9Xo Wc2sFMEXkYvctneoq0YrRnnvzm1cPboKzLnukU8cHUpMz3fxyLBXBJVH7NFkyOUNVgtUIj lgeeQhSMgwnMzZpRMMYjsi2LOO1IJiw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708444994; a=rsa-sha256; cv=none; b=dllyCeRmik19a5ObzddjPHS53n8wIspP2NmOGXtQbsoF4Edd1uIa4CL9fuPWuVcV7RUrfl sCoSllCzKHnKP5ZYHsxmIT9qt1m3sOAfkqTj1Vib6vYtaed2nnwR9ZMJPe+F3yV85JMCL6 60Tx0xxRnhllN7lcaYmScM1XJXn+55I= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E8333FEC; Tue, 20 Feb 2024 08:03:51 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C114D3F762; Tue, 20 Feb 2024 08:03:08 -0800 (PST) Date: Tue, 20 Feb 2024 16:03:06 +0000 From: Alexandru Elisei To: David Hildenbrand Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, rppt@kernel.org, akpm@linux-foundation.org, peterz@infradead.org, konrad.wilk@oracle.com, willy@infradead.org, jgross@suse.com, hch@lst.de, geert@linux-m68k.org, vitaly.wool@konsulko.com, ddstreet@ieee.org, sjenning@redhat.com, hughd@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, alexandru.elisei@arm.com Subject: Re: arm64 MTE tag storage reuse - alternatives to MIGRATE_CMA Message-ID: References: <70d77490-9036-48ac-afc9-4b976433070d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 371B04008E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: zfs1hj9r8hfirsjjju8x3zt7tkf5h5ti X-HE-Tag: 1708444993-183762 X-HE-Meta: U2FsdGVkX18EaymEXmsHe0qxfL+Nw+w7G6rqnRiGzgpiqzwcAX8e1GQ2feVEPST3TclX+Hllf3j92zHOi2utGOFEqrIbRkS2et8RAh1qGISZanjaHiRFs0SQghqdmifyZkH6P1BPP9DxLz7oM1HkZYRAOX+rh4krwz/v22DyJwTTcrl3ZjzsiAlNAlEeBfaPxui6DEkdwM9o53ZCibCOH2LRdTXh2ku1+/MF/++me0MK0W4IvmpN8KGQW/g18Nj43rLS1BWCjC55cxp0+RS/qN0Iwl9yaTF20YgxibrlBXB8+FXXzQ4zowE0bV/LNt8lWmAho0vB0NcS3mtFIclSiKZLNHJmzyCqGgpcO4tksSIFjga0/DXNcvlxfy/utD8JSTJtWk9aJVg5wUnN2Qm0q77m85CK6OV4RIUnCamsPro0lwTYwVKsgETbtI9gfIGWZymPjk/XJGjJKlUyDbwmY/tzrLQ9GneVdtzGPnUD4SBBuTI/UXP+s8Y6L/wxxAuvHWZjM3AUeOMgDw2qCeED6r34+8T8Fe56Uh3jn5d7/2BqQDY+a66T/9+VXZ5aPYwlcU4lZMye2N0qjvmlBtNh4I6uTr5zcMiKR38e/rnM6S1snhN8khW5g5R8TzrA8L1tlPoXMUnn03OOBkkFdenrPgsbXvuBCSHtL6gLO4Zg5iBThWI3Ghb97dM5qsMAvfgsZKHmZelP+6I8+1jjBJeTmxQcehzuJJ7mWDoc369qS39d1ZlB4BAdriYPwjlizFfZF1+GLtBE+qiVnbPsAXk4ZtDGMw2Fmc3f9oOJ4yFWWMZcLik9+DpmAijuo//D9e+iJYuiCkzICKfhNNZlJ8mS6yDQ1OnTm1SI1n30YC8UsDg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, On Tue, Feb 20, 2024 at 03:07:22PM +0100, David Hildenbrand wrote: > > > > > > With large folios in place, we'd likely want to investigate not working on > > > individual pages, but on (possibly large) folios instead. > > > > Yes, that would be interesting. Since the backend has no way of controlling > > what tag storage page will be needed for tags, and subsequently dropped > > from the cache, we would have to figure out what to do if one of the pages > > that is part of a large folio is dropped. The easiest solution that I can > > see is to remove the entire folio from the cleancache, but that would mean > > also dropping the rest of the pages from the folio unnecessarily. > > Right, but likely that won't be an issue. Things get interesting when > thinking about an efficient allocation approach. Indeed. > > > > > > > > > > > > > > I believe this is a very good fit for tag storage reuse, because it allows > > > > tag storage to be allocated even in atomic contexts, which enables MTE in > > > > the kernel. As a bonus, all of the changes to MM from the current approach > > > > wouldn't be needed, as tag storage allocation can be handled entirely in > > > > set_ptes_at(), copy_*highpage() or arch_swap_restore(). > > > > > > > > Is this a viable approach that would be upstreamable? Are there other > > > > solutions that I haven't considered? I'm very much open to any alternatives > > > > that would make tag storage reuse viable. > > > > > > As raised recently, I had similar ideas with something like virtio-mem in > > > the past (wanted to call it virtio-tmem back then), but didn't have time to > > > look into it yet. > > > > > > I considered both, using special device memory as "cleancache" backend, and > > > using it as backend storage for something similar to zswap. We would not > > > need a memmap/"struct page" for that special device memory, which reduces > > > memory overhead and makes "adding more memory" a more reliable operation. > > > > Hm... this might not work with tag storage memory, the kernel needs to > > perform cache maintenance on the memory when it transitions to and from > > storing tags and storing data, so the memory must be mapped by the kernel. > > The direct map will definitely be required I think (copy in/out data). But > memmap for tag memory will likely not be required. Of course, it depends how > to manage tag storage. Likely we have to store some metadata, hopefully we > can avoid the full memmap and just use something else. So I guess instead of ZONE_DEVICE I should try to use arch_add_memory() directly? That has the limitation that it cannot be used by a driver (symbol not exported to modules). Thanks, Alex