Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1683402rdb; Tue, 20 Feb 2024 04:06:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnmKTXnlH0Pi667YL5qAf44t7gOSjJD9++LUJWlHyCQMMzXKBrAGkzfTylA4XHgDsXjTnDiy6q3hMlzRYrzGVUv23lwuEXN8nf4/GAww== X-Google-Smtp-Source: AGHT+IHpQpj0ii2FI8G90WWiclXnyFhqo3j5ySTfowVOK4crCXCaKj2dyXxRNXXXuadnt+tmF5PK X-Received: by 2002:a17:906:411a:b0:a3e:5cba:e005 with SMTP id j26-20020a170906411a00b00a3e5cbae005mr4692986ejk.64.1708430764937; Tue, 20 Feb 2024 04:06:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708430764; cv=pass; d=google.com; s=arc-20160816; b=J7Fj7vCqPwSxJ9vv0q1cODBwyO/PSI7ADyilaY26cYKP+0x1V4BoGf2XnrfTyGQOft 3RvDH7kYMxs2Tsp5WJCTZbQDYAWmzAyHUa0xSBhVU+deBWaX0BbN0qB9incbzS4tDkNC J/Aw8J3HHIGTo1n1xRjB0yQBa0o7z8q4ligkKLWS5L8HkPAMxfRrcqL6ZfwG7uswMTZ4 yZBiuNQjHc6Q40zQoAUGTxLZmc1CEc0pIBmFKoHT4t0nAAHj6GFz89LRKoDhQw2USZIN 0vKIpSTw1rMx65s4hXh44Ul8I2iTUBKnhLeus/gBdg92mEMaJTirXiexroANY/Byb1p/ 0fwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=iu9GpedBJlsb/GLStbej3IybrXKMwD/RH9TYp6z4oqs=; fh=IzR6Lw2pav4xWGZtgoPcQluOZJZC1D5Az+34ODMFUW8=; b=rfMmpQWXfD4je1kDBa8jM3svt/eLfBhKJsvLxcaO4ImxT9QvSNlPqERxSM5dMns7NP mghgoZSuYTWuTaghIgv3cUgD99UomMbXSkA9cdO1PC6AV6stADNKA7IQom+hUCpzqVCR yk/wW2zYRIBeQf5NPYf371wk2iq7P9TqDTfQjqUDUoNi3oOtj92A5n8r9v3WY0939w0w DSpgM2LYR53hp6BfITtuwcYex6iuBIy7DhlyfWEptLfXsIqVQZ14gL6tAef0W2NFuFUs JKZ8wuOdA0KZeGPHizLv10ZJ1tUh/tC+CJLkJxEyCFtYFB73NIBpbhic7dOPJt8F1BYm xR0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZJYXrFPo; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-72979-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72979-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v15-20020a170906180f00b00a3e95937621si1727757eje.449.2024.02.20.04.06.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 04:06:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72979-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZJYXrFPo; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-72979-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72979-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8573B1F22402 for ; Tue, 20 Feb 2024 12:06:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2E6167E6C; Tue, 20 Feb 2024 12:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZJYXrFPo" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92F3767C50 for ; Tue, 20 Feb 2024 12:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708430751; cv=none; b=m0p34AZhOQVg5biOgiuIdoYsNZ2VhAJq9tOOVG6ZEspOuvCwKayfURzlsLIAgjhnuja3F9EE9hjq2mOpqq4V+vGR6p96R4QlAd+ry8qOF8h70i3nYNpUtiCReYsDk7p02J/4kh7uI0KqL4bJU2kH3s+84rOWE3SG+XgO+yeucSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708430751; c=relaxed/simple; bh=2AiCAlGFhbdgPcWkQSCiR7KZ0q8cVeEaMVaZUE8Jc0g=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=QiLHa58GK+Ihr1m8ReIF3AzUXBcZWWaTVMWlZqU5p5Try6LF2hNDbASTBcqOFnhVarIBtz5V9MBAHWa31XS6Pgo6k59MsdekufDqXyJGyNLkCz5jzYeqdsyPjdO0EzK0za+AphkMfS4e5ra3b4PpvIJIQ8swLbJN1l7yj36bffo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZJYXrFPo; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708430748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=iu9GpedBJlsb/GLStbej3IybrXKMwD/RH9TYp6z4oqs=; b=ZJYXrFPopRAm8NIFSkfPn0hytJHdlF5fx6aDBe392wgXKy/zW1o1p2eppCGUf1J/tXk527 fMJ9HvuwJm1Lmb8A9fD3354cR30GkBLerUbgREH7w1AeeGtFs8C3oXl4tAXO++1nTHsaYj DsT/ww7BKKhq3pTNNOU6jJNFya3p0iI= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-z2vBfuKKNz6BIf8Vjc7w7w-1; Tue, 20 Feb 2024 07:05:46 -0500 X-MC-Unique: z2vBfuKKNz6BIf8Vjc7w7w-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-512bad7d985so1810856e87.0 for ; Tue, 20 Feb 2024 04:05:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708430745; x=1709035545; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iu9GpedBJlsb/GLStbej3IybrXKMwD/RH9TYp6z4oqs=; b=E64MfPyK+E8oMnLhwRnXtFz35PdC9nzI76ATfUgi01E+mKSmehX33uADkk/kw0YfNB ubA4JVgvforbo3XfSXfbylrYSwimaHVKeO4WIeA7jl3g5ihaVBmoNiRqLh936o9JDJeP IESEmNHrLcF9pyvimcPuOY2xpe6YHGTiTOg9EaMg6SJHq/N7h+DjaSNMNgKLYs1un3+U 8wi3KPf/p00oid8JiC8kpRjeF9us1hS49iKKoZpAwvKsVs7lztxtT2T9gZDkZmAtdqV8 JJQtkGiZlMKpN/z3eNmeoa24D1AxWyD1IIx6dfxqeJ0cYUhOyze890SpVIVoEgDy5tpf XPBQ== X-Forwarded-Encrypted: i=1; AJvYcCV5oQ5AXdXKr75S+Cst4f77422nQnPsm+JdMaJ3P74+oSHL4ME4nUf/qTaF3lhmc8W7tV/abEmYTFp3D56fHsYg7lItnMXSjTnvoYtB X-Gm-Message-State: AOJu0YztKOa5dVCVT68H/rYIcOaZ7S1DiT5JI5d//x2Psvask6GUG/9t d7lvRzwSTOqMwW0AimKT+9Y3lwXmtPpoZZF1z7PSRvtbka5dSvKP0aIQpqVLfP0TchZgFtHg0iI J7nZ34LV6n7MOykpXKiWgBtfSy5y3PEhuSW/+6YkT7MzwYRjLtReYf//riqxbAQ== X-Received: by 2002:a05:6512:744:b0:512:9de5:baf1 with SMTP id c4-20020a056512074400b005129de5baf1mr3925588lfs.34.1708430745111; Tue, 20 Feb 2024 04:05:45 -0800 (PST) X-Received: by 2002:a05:6512:744:b0:512:9de5:baf1 with SMTP id c4-20020a056512074400b005129de5baf1mr3925546lfs.34.1708430744659; Tue, 20 Feb 2024 04:05:44 -0800 (PST) Received: from ?IPV6:2003:cb:c72a:bc00:9a2d:8a48:ef51:96fb? (p200300cbc72abc009a2d8a48ef5196fb.dip0.t-ipconnect.de. [2003:cb:c72a:bc00:9a2d:8a48:ef51:96fb]) by smtp.gmail.com with ESMTPSA id ij26-20020a056402159a00b005621bdbfdb0sm3616883edb.75.2024.02.20.04.05.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 04:05:44 -0800 (PST) Message-ID: <70d77490-9036-48ac-afc9-4b976433070d@redhat.com> Date: Tue, 20 Feb 2024 13:05:42 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: arm64 MTE tag storage reuse - alternatives to MIGRATE_CMA Content-Language: en-US To: Alexandru Elisei , 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 References: From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+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tc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 20.02.24 12:26, Alexandru Elisei wrote: > Hello, > Hi! > This is a request to discuss alternatives to the current approach for > reusing the MTE tag storage memory for data allocations [1]. Each iteration > of the series uncovered new issues, the latest being that memory allocation > is being performed in atomic contexts [2]; I would like to start a > discussion regarding possible alternative, which would integrate better > with the memory management code. > > This is a high level overview of the current approach: > > * Tag storage pages are put on the MIGRATE_CMA lists, meaning they can be > used for data allocations like (almost) any other page in the system. > > * When a page is allocated as tagged, the corresponding tag storage is > also allocated. > > * There's a static relationship between a page and the location in memory > where its tags are stored. Because of this, if the corresponding tag > storage is used for data, the tag storage page is migrated. > > Although this is the most generic approach because tag storage pages are > treated like normal pages, it has some disadvantages: > > * HW KASAN (MTE in the kernel) cannot be used. The kernel allocates memory > in atomic context, where migration is not possible. > > * Tag storage pages cannot be themselves tagged, and this means that all > CMA pages, even those which aren't tag storage, cannot be used for > tagged allocations. > > * Page migration is costly, and a process that uses MTE can experience > measurable slowdowns if the tag storage it requires is in use for data. > There might be ways to reduce this cost (by reducing the likelihood that > tag storage pages are allocated), but it cannot be completely > eliminated. > > * Worse yet, a userspace process can use a tag storage page in such a way > that migration is effectively impossible [3],[4]. A malicious process > can make use of this to prevent the allocation of tag storage for other > processes in the system, leading to a degraded experience for the > affected processes. Worst case scenario, progress becomes impossible for > those processes. > > One alternative approach I'm looking at right now is cleancache. Cleancache > was removed in v5.17 (commit 0a4ee518185e) because the only backend, the > tmem driver, had been removed earlier (in v5.3, commit 814bbf49dcd0). > > With this approach, MTE tag storage would be implemented as a driver > backend for cleancache. When a tag storage page is needed for storing tags, > the page would simply be dropped from the cache (cleancache_get_page() > returns -1). With large folios in place, we'd likely want to investigate not working on individual pages, but on (possibly large) folios instead. > > 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. Using it as "cleancache" backend does make some things a lot easier. The idea would be to provide a variable amount of additional memory to a VM, that can be reclaimed easily and reliably on demand. The details are a bit more involved, but in essence, imagine a special physical memory region that is provided by a the hypervisor via a device to the VM. A virtio device "owns" that region and the driver manages it, based on requests from the hypervisor. Similar to virtio-mem, there are ways for the hypervisor to request changes to the memory consumption of a device (setting the requested size). So when requested to consume less, clean pagecache pages can be dropped and the memory can be handed back to the hypervisor. Of course, likely we would want to consider using "slower" memory in the hypervisor to back such a device. I also thought about better integrating memory reclaim in the hypervisor, similar to "MADV_FREE" semantic way. One idea I had was that the memory provided by the device might have "special" semantics (as if the memory is always marked MADV_FREE), whereby the hypervisor could reclaim+discard any memory in that region any time, and the driver would have ways to get notified about that, or detect that reclaim happened. I learned that there are cases where data that is significantly larger than main memory might be read repeatedly. As long as there is free memory in the hypervisor, it could be used as a cache for clean pagecache pages. In contrast to memory ballonning + virtio-mem, that memory can be easily and reliably reclaimed. And reclaiming that memory cannot really hurt the VM, it would only affect performance. Long story short: what I had in mind would require similar hooks (again). In contrast to tmem, with arm64 MTE we could get an actual supported cleancache backend fairly easily. I recall that tmem was abandoned in XEN and never really reached production quality. -- Cheers, David / dhildenb