From patchwork Thu Jun 22 14:42:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13289254 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 02626EB64D8 for ; Thu, 22 Jun 2023 14:42:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AD338D000A; Thu, 22 Jun 2023 10:42:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9351A8D0001; Thu, 22 Jun 2023 10:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D78D8D000A; Thu, 22 Jun 2023 10:42:53 -0400 (EDT) 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 6F2C98D0001 for ; Thu, 22 Jun 2023 10:42:53 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3B7E11C888D for ; Thu, 22 Jun 2023 14:42:53 +0000 (UTC) X-FDA: 80930650626.05.E333F88 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 403A72001E for ; Thu, 22 Jun 2023 14:42:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1687444971; 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=8+4aKe5InG/sT9ahgDIcgoSk7tRyyrQ1fi5c8NU1sPo=; b=CxiOKhq2SM4PuP9N1lXiB3kISKf9RmdaZnHs8LZIu6f10Z/1foT4FI+pid2Oh1F+t5z9cx c3j3DeuU0qO1uoUx7UtNZxgJFKoqBrQlanaGwH1sz0sJukquQ66f8NBtew7Jficp4ZMiA1 b9mF2tUFb/XlGZlGFPV/+cRFOaaeX4g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687444971; a=rsa-sha256; cv=none; b=tEZpgk/5wv86RYAx9TrrMn8CO0twEHrab0f4BbNydyMaPn/6GgW2dmRoNHUAlEbSfuvhEe +wS7uhNACh5Ux35HIR7J/rWzZYh/kh5m9eC5CHbz7Gcd3i/gr5cekf4/TEFXcZXhDuFA9y G+7/hE5MJSG5jnS+UoPRAZxOEKx1kUA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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 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 7A4C61042; Thu, 22 Jun 2023 07:43:34 -0700 (PDT) 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 EAAD23F663; Thu, 22 Jun 2023 07:42:47 -0700 (PDT) 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 Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 08/14] arm64/mm: ptep_set_access_flags(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:42:03 +0100 Message-Id: <20230622144210.2623299-9-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230622144210.2623299-1-ryan.roberts@arm.com> References: <20230622144210.2623299-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 403A72001E X-Rspam-User: X-Stat-Signature: rqb4rzth8zt8sndyzztp8cwzj6puc69r X-Rspamd-Server: rspam03 X-HE-Tag: 1687444971-797809 X-HE-Meta: U2FsdGVkX198C3mqLG9qCBOK4+7yPLzc7seQGlU5TlxCJBlV07AJtR+dLSXrd//YvfDGXVc2r/kYkK0Els2yRszFIG9NN0g0uV9Lc3HA5F1zrKp+UsHt1E3hO4NQ/36SnA97fo9fXrB8Y+wYjov17pBppGMF+Kz9E9mXYHLtuLyZY2om0Y213WyoL3nSf0v3a+sG3YR6C3g1dyeISTR49lZv/aL7h3aR1+TfDc/IfHKgyCENvXb5i8MnZ5SUTuty+nnwedLw5KaJNmpB3VHdTTRXs+SI7sYM5R+GoQRogayxfASycC+mcZziIwOkdD5ZNdNRIyqmoKqZj+EG/a52nG1kz+Ps301oOECqsofvlWXD1qAAgMimd9874SA8sjcL81K9wzOR1NMnddrvXSDXrMb8r2EsVepZFNNCZXPg2wW6vcfL2/naAy0DE9CHEMuQusgF1BHBQbg2Uo2CaEc7OhMQ0J7pVqJ1PJ07jpSooG2lLJTvqNh1i/W7XFYaiAXMoc9Cl2zJJmQGf2/vCof01HWaGJkReSqrYjG6EDbFeKfHnLbg1pFfqTrs9Ehpbn71mw9Ai73/pOS25oDhnqpqz2rBajOf+j1KNUNPbmvKiiv4wcFr6d00CT+wV274FmnW0Rdak+vhemZFmUHmVuNHpZfjSDdMFxrkiAdxGwJT4O7AO1kUbVtkSl8wfwS8dNWm+HIg+57nL0qY/5ccKBQur8O/ZNCTG2owibqz0II3Xb/4BJNsF7F9vrtit8p63A9F/B8LtaDsLNQupp/nScOUEgqKGuVQvzs8VByx9xvetTLbxZIN9pVpKzvow1sr2vEKCgoFotnkq+yiwiXmNDph+isT8MO516pdhEUY+AH/0398TtP4rK6Vr4+5ceUt6VzpWQbsrARoH4fMNotvmSBjuk9J4wg7x3aZbwejYSMibfpOJwkZihzKJVxCvbYj6tkLAmcLD0ONa3oO7diQje1 beJcuk0K kuFU/0TE6x51enDBZ2GlFsMVJX9nk7Bd10IxsLITfLla7EPZzic2YFfA5Re40NlOLIa6lCBleFxNn17jppFvDkAJcVGTZNDdrf4WaFwz+lgKIPYsHxHbe3VUIqVKCkmVAViYMQ3DDtJvoy7BGzRyP1HUQat/yjhlERlSIVfuauffJMSLP9YgB7DN+RmpIE80cPsVMKMP3Jho/+zxuAxYX+a+a3Y9iKsYis2gzDEsexmbcHOr7IgV1wByfDZRfPDK1aaVprckFXYqnyMOvh5LnQh8huw== 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: 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. No behavioural changes intended. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 16 ++++++++++++---- arch/arm64/mm/fault.c | 6 +++--- arch/arm64/mm/hugetlbpage.c | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 2fcc3b19c873..ff79578fd806 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -311,7 +311,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) @@ -1166,6 +1166,14 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, __ptep_set_wrprotect(mm, addr, ptep); } +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS +static inline int ptep_set_access_flags(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, + pte_t entry, int dirty) +{ + return __ptep_set_access_flags(vma, addr, ptep, entry, dirty); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index d3a64624ed88..f5a7a5ff6814 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -195,9 +195,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 7d5eb71db396..9a87b1c5661a 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -477,7 +477,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;