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 D54BBC3DA6F for ; Thu, 24 Aug 2023 07:50:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 215D8280076; Thu, 24 Aug 2023 03:50:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EB44280071; Thu, 24 Aug 2023 03:50:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B3C6280076; Thu, 24 Aug 2023 03:50:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EEAB2280071 for ; Thu, 24 Aug 2023 03:50:41 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C2249160210 for ; Thu, 24 Aug 2023 07:50:41 +0000 (UTC) X-FDA: 81158226282.18.5890EEB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 99ACC120017 for ; Thu, 24 Aug 2023 07:50:39 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bXj0eTn1; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692863439; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9VEiwM/469XoxPkv00kiY2u9t4qVyJoCjGxKGq/80WA=; b=LP5F4ARobYydxRtURfbpgEuqAkOBPaq1yvtnE+djuCVdxwBK17QMezyaVlPBezv0eKDtQQ 96GFF+244lnS23JmJmlZNjdXzmpnSmLI0KQAJJaodXmc/CYlLBWCKk2DLdfS9oiZKNdzEA sj7gfrNjkIBeQPBaRWUgEeb+6/A8Zvk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692863439; a=rsa-sha256; cv=none; b=J8SZl8bT4EIuAiSKU1SYiDHG1ZZiwrpGOZT55ASAc05i0qDmizQntFV0QkR+tDf7NmsyP4 KH+xh1GpJV9/HgW7U6plHj801OUIOT5cRhqDWIFCL7gDmOZ56gdiYyuTWThoO1ln9in/Je yAtiE9u/1bTr+0SMINdHotAnhaQoGK0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bXj0eTn1; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692863438; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9VEiwM/469XoxPkv00kiY2u9t4qVyJoCjGxKGq/80WA=; b=bXj0eTn16vSh2KzmI7uPM8zkiBpDPJN+E9wQbnQ+fiXttwTW7duQXxoNJjBDRjsLCy2GUU 8yVs53Gn+h1O15hxuMeKtu+a7U1uTLFBJqoFBUQGXbFPUQfBNQvsvjymfBaMUV/LIl5yyl 4NlTjK3zCJ36KHVsOFnn8BrEwtujQ0k= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-QU2mGjC9M_ynZpdsFEvPmQ-1; Thu, 24 Aug 2023 03:50:37 -0400 X-MC-Unique: QU2mGjC9M_ynZpdsFEvPmQ-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-4ff92d9f376so6858785e87.3 for ; Thu, 24 Aug 2023 00:50:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692863436; x=1693468236; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9VEiwM/469XoxPkv00kiY2u9t4qVyJoCjGxKGq/80WA=; b=JdJTVlx7xyMbG7AuQN5TAiW7Jkb46lUbrD83vi4bBSHKK4+k8YuwiIMsNCUD5vPheO WP+47ZMjC/KBIFN3JGGOrT6f3GEV8ASyTA/1XYEf5qrQk/pq7RH1dCj+GZNI+TAFh1P2 IZXqXKrQSzV5x1YlXz2Y5w7Q2aGVpXl2e3g+18/IET0EiqOyaceqwpII8gSx7k5M5v5U n7Vh+VDY/HCL1n8tpDVtVxW26UAjVVPPqOPDBitQ9HjnqplDUmdAEG3Cu+p6xlKDLZ8m kkyFUNZUPF0HMuX4sZ4eohMiqUR0sz42oBbsTnuyxRUlp/cGL50etBEI/f28uEpFz1/b n4xg== X-Gm-Message-State: AOJu0Yz30SuI2BOit27bROsgxY4XOImsObCK2lJSdXh4uOD2nccH7nHV m1w7x2a1LP482YWYAwwAVfTD4uWbaeBIRJwKML3rYg6i5HDgJdJ06IMipzVoWSvp/LgIgcefjuE bheoOtBqyAWg= X-Received: by 2002:a05:6512:1296:b0:4fe:993:2218 with SMTP id u22-20020a056512129600b004fe09932218mr13520795lfs.31.1692863435835; Thu, 24 Aug 2023 00:50:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWxb3vEOPi9oDLO474PCk5smXiK4t0flJpP1QfkBeZvkQd0769Sd7lavC4bQKKWkbdbP5Q0A== X-Received: by 2002:a05:6512:1296:b0:4fe:993:2218 with SMTP id u22-20020a056512129600b004fe09932218mr13520754lfs.31.1692863435397; Thu, 24 Aug 2023 00:50:35 -0700 (PDT) Received: from ?IPV6:2003:cb:c709:6200:16ba:af70:999d:6a1a? (p200300cbc709620016baaf70999d6a1a.dip0.t-ipconnect.de. [2003:cb:c709:6200:16ba:af70:999d:6a1a]) by smtp.gmail.com with ESMTPSA id w7-20020adfcd07000000b00313de682eb3sm21614062wrm.65.2023.08.24.00.50.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Aug 2023 00:50:34 -0700 (PDT) Message-ID: <33def4fe-fdb8-6388-1151-fabd2adc8220@redhat.com> Date: Thu, 24 Aug 2023 09:50:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 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, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com Cc: pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org References: <20230823131350.114942-1-alexandru.elisei@arm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH RFC 00/37] Add support for arm64 MTE dynamic tag storage reuse In-Reply-To: <20230823131350.114942-1-alexandru.elisei@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 99ACC120017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: uf56tzwms88ahrfmynhxdnpu8s54u1ts X-HE-Tag: 1692863439-312558 X-HE-Meta: U2FsdGVkX1/iwXSiUPqqOv0wauWEHAK476n5ZPPYcdY5tyAODg9s+rbRXcqIxKIcFGeDD86DbGM2oNP5uhBM365X3HS9vnKY37QTedhrfyXEWFJMlfHauXBKNt3DmhV05+vckWpTLGfA0/ENuucHkr/x7JIdwiG5d74WAokKJeo9vHMLSZQhm0C3jYP/xEBtW/gwLM1JiC3i65jnFNf7gqCWtJfeYkikUS0yQnuKAIQJYk9XiqSH5lb3dIwBQ0CvVn5CH+E3p+RX6iTFSpBH+T2ROnNJM/5RJ9ZF003kq1LdMCuKJr59+xdcil19aLv35Y7Ar4aEYhWwQQSlr0pdvvK03qC0/VLLiWD4B/rQioYOAv9IJuQFla3taFmMz6EgQVYKTg/BpIbW6AexOHpo5xNEKCQo8saHrXfj6Z2fmO6v/UMtmvkjxJ5lMZDXSPtY4mOUzsXIZEzflJ8ggy5NaU+I24QjGy5zaRBVtesGJvWyNjKWjjHehk//IUT0n3VnlTtYDxlFPVEmh+FMj8NMYEQ3CgXlFSFkal7vf8/j1+WNE6XyWPFRw/MiueN29a4KpjeDYX7REYf5vXmoD5gZ+xvnwWe68o8OkMV1M4dksLnu4A4YVcmvaivbQYTXZdIJ6fiLeaTUobJNdNCwYw98mKPbPIU3C0xLN3bqDlLChxAxytdRxxbnAKSqfn3F6/0YTO/1ERYAhmIicaQPACq7EQO5v6iGPS1uRJNssaXrubOLYd2wVlD9976gp3/cCyiJsE4ULHE3qFDtpykZY62vNlwrhcZSirlhCyBxE8E/ccMKQRXxrmNoxMaMecEUjNtFvTOU1QsLvQrxK3hPxsBhk1nkGCj8seZcrfwEq37CTR8UnQCLtkvgMGbZI+ZHCblVJuqnRE3s6MmaSO9fK59Tc//QXO/9bGbV694sZKfVFtShQhf1u0WCz5Cxchyp6z14TgTpmlCVLbJSshUxSfF dcb9VtcG P86A7ZKaCkurWEnRJWJb7CdVMsaB0OG+huPNLn1/4wnS8HvnfJVT25MEUL2w6VFhozm7CxBUghOWTs7CQmptptQS+JYfSdtIOALP6C4qEHClGCEe4myr2LNE51NDdedn3vthhptKyJIUDmRiRV5xz6xow9gVCv1tizjvI5lcSwVnAsn0LH0A/3JnLWmpnnfBKc/q2usQ6qLOYWss518Ul4vdISagE2kP50ut7Dphlbge03yhmjOV0hvBISwoJAndSe+42Y0ZqOzyGRMU0cRecGcUzISpksmNzea6pzVZLt329oPKFXQ/HQMqYe8tMHEndHcNeXabdVD9X/2JoM+ElWL5uo0TvRZGgbdD8xskv6G0XAuPRJMUy3bcFI+3jPvrO3OTxdl+P/N/T5qmxt56qONLSfYzSkQK2sn6dhrVJaBuhC9fGO02hP+r9dtYaKZ5KiBmj3RPVftfeVkaaDbYTKGXj/Op3lj1YTjUOWtnbqtFfF4s4ovgCzV3sUwKRgcPJtRZFMJDNRwH4Q2GQxeVqWwBnFV+j41hm5bOsdhRiLzJrA4VzcOtaMLamouBHs3g4hC3N/8NRa1yYtdPDmo2ccA6RKw== 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: On 23.08.23 15:13, Alexandru Elisei wrote: > Introduction > ============ > > Arm has implemented memory coloring in hardware, and the feature is called > Memory Tagging Extensions (MTE). It works by embedding a 4 bit tag in bits > 59..56 of a pointer, and storing this tag to a reserved memory location. > When the pointer is dereferenced, the hardware compares the tag embedded in > the pointer (logical tag) with the tag stored in memory (allocation tag). > > The relation between memory and where the tag for that memory is stored is > static. > > The memory where the tags are stored have been so far unaccessible to Linux. > This series aims to change that, by adding support for using the tag storage > memory only as data memory; tag storage memory cannot be itself tagged. > > > Implementation > ============== > > The series is based on v6.5-rc3 with these two patches cherry picked: > > - mm: Call arch_swap_restore() from unuse_pte(): > > https://lore.kernel.org/all/20230523004312.1807357-3-pcc@google.com/ > > - arm64: mte: Simplify swap tag restoration logic: > > https://lore.kernel.org/all/20230523004312.1807357-4-pcc@google.com/ > > The above two patches are queued for the v6.6 merge window: > > https://lore.kernel.org/all/20230702123821.04e64ea2c04dd0fdc947bda3@linux-foundation.org/ > > The entire series, including the above patches, can be cloned with: > > $ git clone https://gitlab.arm.com/linux-arm/linux-ae.git \ > -b arm-mte-dynamic-carveout-rfc-v1 > > On the arm64 architecture side, an extension is being worked on that will > clarify how MTE tag storage reuse should behave. The extension will be > made public soon. > > On the Linux side, MTE tag storage reuse is accomplished with the > following changes: > > 1. The tag storage memory is exposed to the memory allocator as a new > migratetype, MIGRATE_METADATA. It behaves similarly to MIGRATE_CMA, with > the restriction that it cannot be used to allocate tagged memory (tag > storage memory cannot be tagged). On tagged page allocation, the > corresponding tag storage is reserved via alloc_contig_range(). > > 2. mprotect(PROT_MTE) is implemented by changing the pte prot to > PAGE_METADATA_NONE. When the page is next accessed, a fault is taken and > the corresponding tag storage is reserved. > > 3. When the code tries to copy tags to a page which doesn't have the tag > storage reserved, the tags are copied to an xarray and restored in > set_pte_at(), when the page is eventually mapped with the tag storage > reserved. Hi! after re-reading it 2 times, I still have no clue what your patch set is actually trying to achieve. Probably there is a way to describe how user space intents to interact with this feature, so to see which value this actually has for user space -- and if we are using the right APIs and allocators. So some dummy questions / statements 1) Is this about re-propusing the memory used to hold tags for different purpose? Or what exactly is user space going to do with the PROT_MTE memory? The whole mprotect(PROT_MTE) approach might not eb the right thing to do. 2) Why do we even have to involve the page allocator if this is some special-purpose memory? Re-porpusing the buddy when later using alloc_contig_range() either way feels wrong. [...] > arch/arm64/Kconfig | 13 + > arch/arm64/include/asm/assembler.h | 10 + > arch/arm64/include/asm/memory_metadata.h | 49 ++ > arch/arm64/include/asm/mte-def.h | 16 +- > arch/arm64/include/asm/mte.h | 40 +- > arch/arm64/include/asm/mte_tag_storage.h | 36 ++ > arch/arm64/include/asm/page.h | 5 +- > arch/arm64/include/asm/pgtable-prot.h | 2 + > arch/arm64/include/asm/pgtable.h | 33 +- > arch/arm64/kernel/Makefile | 1 + > arch/arm64/kernel/elfcore.c | 14 +- > arch/arm64/kernel/hibernate.c | 46 +- > arch/arm64/kernel/mte.c | 31 +- > arch/arm64/kernel/mte_tag_storage.c | 667 +++++++++++++++++++++++ > arch/arm64/kernel/setup.c | 7 + > arch/arm64/kvm/arm.c | 6 +- > arch/arm64/lib/mte.S | 30 +- > arch/arm64/mm/copypage.c | 26 + > arch/arm64/mm/fault.c | 35 +- > arch/arm64/mm/mteswap.c | 113 +++- > fs/proc/meminfo.c | 8 + > fs/proc/page.c | 1 + > include/asm-generic/Kbuild | 1 + > include/asm-generic/memory_metadata.h | 50 ++ > include/linux/gfp.h | 10 + > include/linux/gfp_types.h | 14 +- > include/linux/huge_mm.h | 6 + > include/linux/kernel-page-flags.h | 1 + > include/linux/migrate_mode.h | 1 + > include/linux/mm.h | 12 +- > include/linux/mmzone.h | 26 +- > include/linux/page-flags.h | 1 + > include/linux/pgtable.h | 19 + > include/linux/sched.h | 2 +- > include/linux/sched/mm.h | 13 + > include/linux/vm_event_item.h | 5 + > include/linux/vmstat.h | 2 + > include/trace/events/mmflags.h | 5 +- > mm/Kconfig | 5 + > mm/compaction.c | 52 +- > mm/huge_memory.c | 109 ++++ > mm/internal.h | 7 + > mm/khugepaged.c | 7 + > mm/memory.c | 180 +++++- > mm/mempolicy.c | 7 + > mm/migrate.c | 6 + > mm/mm_init.c | 23 +- > mm/mprotect.c | 46 ++ > mm/page_alloc.c | 136 ++++- > mm/page_isolation.c | 19 +- > mm/page_owner.c | 3 +- > mm/shmem.c | 14 +- > mm/show_mem.c | 4 + > mm/swapfile.c | 4 + > mm/vmscan.c | 3 + > mm/vmstat.c | 13 +- > 56 files changed, 1834 insertions(+), 161 deletions(-) > create mode 100644 arch/arm64/include/asm/memory_metadata.h > create mode 100644 arch/arm64/include/asm/mte_tag_storage.h > create mode 100644 arch/arm64/kernel/mte_tag_storage.c > create mode 100644 include/asm-generic/memory_metadata.h The core-mm changes don't look particularly appealing :) -- Cheers, David / dhildenb