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 192EBC4345F for ; Fri, 19 Apr 2024 07:47:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A485D6B0093; Fri, 19 Apr 2024 03:47:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F78C6B0095; Fri, 19 Apr 2024 03:47:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90CBA6B0096; Fri, 19 Apr 2024 03:47:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7444E6B0093 for ; Fri, 19 Apr 2024 03:47:13 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EE8D4C0D57 for ; Fri, 19 Apr 2024 07:47:12 +0000 (UTC) X-FDA: 82025500704.01.6B137BF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 34EFB40007 for ; Fri, 19 Apr 2024 07:47:10 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713512831; 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; bh=KO8ZUiJDe1k5Ddr+juayaazV8bqnaz5Pn+OT686Mq6Q=; b=7uQinDLc+UIjBvgUw2JyZxtTZyEkqDpCVxiHZyX4EuPPOXSc+zpdvLrA6dUMhxBd8sBsXY oCdthjKZEj9YKfW8YtxUeH3KZKO9de2d114/jElWbbekcCydL+5TbLV7oivANFbs1bgoUf wfXye8t22C4pdTRMqIOfRbLoyEJvgjs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713512831; a=rsa-sha256; cv=none; b=Aj5N4ZexYbi4KUHQ1yOHQQdDaF7BvYcbMx/ZQhivoEWPdd6CS+MymOeNDYtVGvwsbcojsM kj/TR+tF9fZYKuMcunmjfW3URhm+oHBGhGXEpNyU8/CATlWfhZzWhOyB8vdchOIhWzN7km UrRI8PxhbWd0O2WV9MK0tskEVhzmr0A= 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 9FEEF2F; Fri, 19 Apr 2024 00:47:38 -0700 (PDT) Received: from [10.57.74.127] (unknown [10.57.74.127]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 632573F792; Fri, 19 Apr 2024 00:47:08 -0700 (PDT) Message-ID: <24999e38-e4f7-4616-8eae-dfdeba327558@arm.com> Date: Fri, 19 Apr 2024 08:47:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking Content-Language: en-GB To: Catalin Marinas , Will Deacon , Andrew Morton , Shuah Khan , Joey Gouly , Ard Biesheuvel , Mark Rutland , Anshuman Khandual , David Hildenbrand , Shivansh Vij Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org References: <20240419074344.2643212-1-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: <20240419074344.2643212-1-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: bpw497or5xcq5aeshbax5nfezrnqhdrh X-Rspamd-Queue-Id: 34EFB40007 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713512830-359927 X-HE-Meta: U2FsdGVkX1/IHMDtRQIm1cVA4CHuKrAFeAhdjxfJq7W/QM42IcVaUWX2t3ueuF+foMbwQEwxwmTnmV4FhmL59bLFzi5vKGpYh+2IOGEUJxVWEpGLGl+Ob6f59sLh9gXw5w65igExOu87hUsQEFA9f6iLt8UIcWL/TwFSVAjroYgqpPAxMgrU/4eps08D9tmc84QI/4YSj1OpM0QWu1rbcZQn16M5AUa1ttXFYAV0bpiHNFbh8NP2qvdig66G3EBruRd0VqLg07Fggrea1TSK0mzcgVBvpobsHteQO/M2aEoWr8KMDrqJeSrQcJHe1U2P5UGuEnqTuS0gdmhX7Rcjrsrwyv1wLdjXz869w/kYqB9NMhacZUN8dRjtwUOIe5p8E3tZ8jvwjoXca/Yswg98s1GyVqR5HKi6iRKz3qJo4kDc8ELxrCKd/QM3dlwFb/l2HR/elDNdDA3ofQpAv1qhOra2zutnQyhrZnhQJHCLRRmcz613IUL7EJ71878opK2oSQmgOAiIYINWk1w2loKfm10y1UQ8Jwlbafvmjh9xfcDm0dq4jSmDMdC4zLMqvRIEmLjEd9RSFPZIyOftQzObbInY7lQ5yUvhdyn6AMrosc8qX/rZxIXBkA38e0nzfG0eLMYmvV2XHAQ9I5dFFi5/lyDQ7gIJiacumesxL6DjYEdiNcnQRkipy3mF+dPQl+y6HkZ9SkGVaFbw7V5Xph8LGa6Es1UcGBG5widsqcsbv7C5bD6a69acQHDzbLC6MI5Z08l+cbGGkCtZMs32/PcaS9+UHS9JQxe9Roub1PtWuxFBdZI6uulTAv1r1yAKToV0hOdRflZQKjA4OUgjGW0kQmDt4bDdCWevQ/uCJDLpEFeuylIObw1Rq9CJmSdWom7E5vQSQIKppX7X5XwRH5YRBoHRM1ARB4ih/PMTc9PvQB10Tr8mxVdjb510jpIZ2heJFw6HTsAvGzeowWECFld up8DiICF jVBwjObrG46iK6lAiY/sc4iTof1jy99hHNsKIxG5GWCPhSwK3orArgsODlfpBBk6ZpE9fz7N2D8OqVd7MLyCMDcnrdOxvhepAu5ry1kQMZY6FAKRWqUbk3Ny/6sv/odz8SFiZuXXYjZFfG0i3XF9D8o11UIcojI+q7+ZHJUUbe56PVbb7ZLhBF4qlav+V0Ckt1v377pFN4eFJuMneJhvi2WApZ4bcCQF1R7Os 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: On 19/04/2024 08:43, Ryan Roberts wrote: > Hi All, > > This series adds uffd write-protect and soft-dirty tracking support for arm64. I > consider the soft-dirty support (patches 3 and 4) as RFC - see rationale below. > > Previous attempts to add these features have failed because of a perceived lack > of available PTE SW bits. However it actually turns out that there are 2 > available but they are hidden. PTE_PROT_NONE was previously occupying a SW bit, > but it only applies when PTE_VALID is clear, so this is moved to overlay PTE_UXN > in patch 1, freeing up the SW bit. Bit 63 is marked as "IGNORED" in the Arm ARM, > but it does not currently indicate "reserved for SW use" like it does for the > other SW bits. I've confirmed with the spec owner that this is an oversight; the > bit is intended to be reserved for SW use and the spec will clarify this in a > future update. > > So we have our two bits; patch 2 enables uffd-wp, patch 3 enables soft-dirty and > patches 4 and 5 sort out the selftests so that the soft-dirty tests are compiled > for, and run on arm64. > > That said, these are the last 2 SW bits and we may want to keep 1 bit in reserve > for future use. soft-dirty is only used for CRIU to my knowledge, and it is > thought that their use case could be solved with the more generic uffd-wp. So > unless somebody makes a clear case for the inclusion of soft-dirty support, we > are probably better off dropping patches 3 and 4 and keeping bit 63 for future > use. Although note that the most recent attempt to add soft-dirty for arm64 was > last month [1] so I'd like to give Shivansh Vij the opportunity to make the > case. Ugh, forgot to mention that this applies on top of v6.9-rc3, and all the uffd-wp and soft-dirty tests in the mm selftests suite run and pass. And no regressions are observed in any of the other selftests. > > ---8<--- > As an appendix, I've also experimented with adding an "extended SW bits" region > linked by the `struct ptdesc` (which you can always find from the `pte_t *`). If > demonstrated to work, this would act as an insurance policy in case we ever need > more SW bits in future, giving us confidence to merge soft-dirty now. > Unfortunately this approach suffers from 2 problems; 1) its slow; my fork() > microbenchmark takes 40% longer in the worst case. 2) it is not possible to read > the HW pte and the extended SW bits atomically so it is impossible to implement > ptep_get_lockess() in its current form. So I've abandoned this experiment. (I > can provide more details if there is interest). > ---8<--- > > [1] https://lore.kernel.org/linux-arm-kernel/MW4PR12MB687563EFB56373E8D55DDEABB92B2@MW4PR12MB6875.namprd12.prod.outlook.com/ > > Thanks, > Ryan > > > Ryan Roberts (5): > arm64/mm: Move PTE_PROT_NONE and PMD_PRESENT_INVALID > arm64/mm: Add uffd write-protect support > arm64/mm: Add soft-dirty page tracking support > selftests/mm: Enable soft-dirty tests on arm64 > selftests/mm: soft-dirty should fail if a testcase fails > > arch/arm64/Kconfig | 2 + > arch/arm64/include/asm/pgtable-prot.h | 20 +++- > arch/arm64/include/asm/pgtable.h | 118 +++++++++++++++++++-- > arch/arm64/mm/contpte.c | 6 +- > arch/arm64/mm/fault.c | 3 +- > arch/arm64/mm/hugetlbpage.c | 6 +- > tools/testing/selftests/mm/Makefile | 5 +- > tools/testing/selftests/mm/madv_populate.c | 26 +---- > tools/testing/selftests/mm/run_vmtests.sh | 5 +- > tools/testing/selftests/mm/soft-dirty.c | 2 +- > 10 files changed, 141 insertions(+), 52 deletions(-) > > -- > 2.25.1 >