From patchwork Mon Dec 4 10:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13478194 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 D5837C4167B for ; Mon, 4 Dec 2023 10:55:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77DE06B02AE; Mon, 4 Dec 2023 05:55:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72DA46B02B0; Mon, 4 Dec 2023 05:55:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61DB06B02B1; Mon, 4 Dec 2023 05:55:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4FB326B02AE for ; Mon, 4 Dec 2023 05:55:35 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2D40F1C01E1 for ; Mon, 4 Dec 2023 10:55:35 +0000 (UTC) X-FDA: 81528829830.21.BDDB2F7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 8DB0714000A for ; Mon, 4 Dec 2023 10:55:33 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@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=1701687333; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0BwGCXMY0Jm/jIsiVmBBtVJvXghyud81fHEkKj7GCo=; b=67uVcmK+gk7IwmzpNDRGRoHM7SlD/IAskY/xQj/szqB26mWhIZE7WxU2IsDv1JlxpdZbN4 0oTsMUrQnlVUySiT2JjL3bfDeKVCoZHEVHQ0QYmKNzGuHrJo5jIhPCfdPtiv8Pwadf4M5D x9k+ypo8+p9euwnUAt0C0ndNZAT/54A= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701687333; a=rsa-sha256; cv=none; b=C91Z7RDp9z2GTAxVvKhPSKdmXsVr50hcPyHHdCVkUihGwmRN4sOrt5cZk+aYuCEpSXpyCH eKngiGKm4VDTNaHzb8hYuVAdP/xG00ArGoZ25jZYQ7IUhLbZ/y6fyW0WO/AGGkmgA9XNDq kBeAos86hJWjWiaIZSNG7fivSleHCaA= 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 3482816A3; Mon, 4 Dec 2023 02:56:20 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FF083F6C4; Mon, 4 Dec 2023 02:55:29 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/15] arm64/mm: ptep_set_access_flags(): New layer to manage contig bit Date: Mon, 4 Dec 2023 10:54:35 +0000 Message-Id: <20231204105440.61448-11-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204105440.61448-1-ryan.roberts@arm.com> References: <20231204105440.61448-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8DB0714000A X-Rspam-User: X-Stat-Signature: 6jw19fmky68wzniydcyj8w9by5sr9ppd X-Rspamd-Server: rspam01 X-HE-Tag: 1701687333-248888 X-HE-Meta: U2FsdGVkX18w2zUmK4r62dmcwgR6XBXuMf7MmIYDj/hKr/pMLhIOLpTZ4f1clyjGIMf8EF5zdvpSY4ayQSuhXpX+6ytxAltMqYh5Mm1AAPkddcjIK7vTCAgrwEI+IVkluVjX8WAc6jhiFNI0/YgOLA3KASOrYf8ttLb9KM+ZXsKNxaNQHqA+mS+zcWDhjIM0XMoLIJ4QAJc3/fekX4/YBCT5Xd1+OAvA6kVWjjW7XCiauwGydx3Ijfkq4ooOQKWYUXl09oyq2BGTKs+pr4+IE8IxCN4eYq3cz2uLh6rdWe1K3tMX9GZvAIRiEO8PisRDhbuw1zMsrQup5lEBtCYr6224gvm2LUHcwoqFd0kOmU2Tvlw7Z2G5oGu9U6sXBzsAkcfXl05by8PVgR5g/nojA+/T1M1brGUUQXFbMW86eEP8w0iTC49kblsN9WwT0pGZQZQUyY3c8umLc4gB+s4f+uTR0W2C+ANhi0f7/8wsL6LU2wVoQIUfn2HJn5ddUVokVtOhzi6vuZgqp2N+FxYKOXWepTytse0T8wOp86fEFZzPkS8mSlMfctn9EVbmuwP4ySI0UHQytrUTglaubvkqL00E2sVb21LSYE2+ZTbsc6G9TPB6keoygV0USsVa4h9MDHDLu2zanOuU0eTy2JzdXn7hSfAhxUrqTOnI8gJ/N7caXuczczdSsGbm9UuNw7AJoGeHSu+HiF+TuCfEccWP7vYiykIopriTuBc7v0P0zKi8xFlrclgMWsHLTfp7lRiNlhPxFwangz4j9Pz8H0EGP1koLu4YgfjY4/6Ex/yVl9OqCKOojNqb6h9cROTUJsHkF39OCvj4JtX+60ygLal7L7dpQuEua5tgPNdy2JHp0eka63QYphUBMopz+ACF/7ovahUBjNqx7ZXNO/5saYpRsgZjNT4gnmw2Y9tqDo0LHuSaQ3c1Xr6knSWWdXjSvSvFrR8rLFk0OEmrk9tNX/H rYkIOo0I UAi+e3Pxo96nbZTD9FatritrcjcNsIXFfs+Giv1zO0a1FGAmI1C+hFFk5MjAmyhJCPLWGNwGBBQO7UdcZoTVul0A1lpYtMwG4JtHUnDaa+xZLfRGmagMQgIeHlvww78Am/v65sCTAfIvkGMrMEYczHM8yVXrSzSkATncxC6lJ3enr/8EpJ9oGf8U2Oc1RScV0BPc494x2opqn+IoImSQIkrq7pXDuJ0XRIuYt/NkQfMe3KSHKnt9RsOaAYoFnx173v28zWrXwgmgduJyii7na5xZpjw== 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: Create a new layer for the in-table PTE manipulation APIs. For now, The existing API is prefixed with double underscore to become the arch-private API and the public API is just a simple wrapper that calls the private API. The public API implementation will subsequently be used to transparently manipulate the contiguous bit where appropriate. But since there are already some contig-aware users (e.g. hugetlb, kernel mapper), we must first ensure those users use the private API directly so that the future contig-bit manipulations in the public API do not interfere with those existing uses. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 10 ++++++---- arch/arm64/mm/fault.c | 6 +++--- arch/arm64/mm/hugetlbpage.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 423cc32b2777..85010c2d4dfa 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -312,7 +312,7 @@ static inline void __check_safe_pte_update(struct mm_struct *mm, pte_t *ptep, /* * Check for potential race with hardware updates of the pte - * (ptep_set_access_flags safely changes valid ptes without going + * (__ptep_set_access_flags safely changes valid ptes without going * through an invalid entry). */ VM_WARN_ONCE(!pte_young(pte), @@ -842,8 +842,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) return pte_pmd(pte_modify(pmd_pte(pmd), newprot)); } -#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS -extern int ptep_set_access_flags(struct vm_area_struct *vma, +extern int __ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t entry, int dirty); @@ -853,7 +852,8 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t entry, int dirty) { - return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty); + return __ptep_set_access_flags(vma, address, (pte_t *)pmdp, + pmd_pte(entry), dirty); } static inline int pud_devmap(pud_t pud) @@ -1122,6 +1122,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define ptep_clear_flush_young __ptep_clear_flush_young #define __HAVE_ARCH_PTEP_SET_WRPROTECT #define ptep_set_wrprotect __ptep_set_wrprotect +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS +#define ptep_set_access_flags __ptep_set_access_flags #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index a287c1dea871..7cebd9847aae 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -209,9 +209,9 @@ static void show_pte(unsigned long addr) * * Returns whether or not the PTE actually changed. */ -int ptep_set_access_flags(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep, - pte_t entry, int dirty) +int __ptep_set_access_flags(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, + pte_t entry, int dirty) { pteval_t old_pteval, pteval; pte_t pte = READ_ONCE(*ptep); diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 952462820d9d..627a9717e98c 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -459,7 +459,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, pte_t orig_pte; if (!pte_cont(pte)) - return ptep_set_access_flags(vma, addr, ptep, pte, dirty); + return __ptep_set_access_flags(vma, addr, ptep, pte, dirty); ncontig = find_num_contig(mm, addr, ptep, &pgsize); dpfn = pgsize >> PAGE_SHIFT;