From patchwork Mon Dec 18 10:50:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13496570 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 4AC6DC35274 for ; Mon, 18 Dec 2023 10:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D49E56B009C; Mon, 18 Dec 2023 05:51:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CFCD16B009D; Mon, 18 Dec 2023 05:51:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9B2E6B009E; Mon, 18 Dec 2023 05:51:42 -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 A56526B009C for ; Mon, 18 Dec 2023 05:51:42 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 84E581A0D80 for ; Mon, 18 Dec 2023 10:51:42 +0000 (UTC) X-FDA: 81579623244.26.040A893 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 09E411C0016 for ; Mon, 18 Dec 2023 10:51:40 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf20.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=1702896701; 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=43xS6Y4SE6bF0+VyPS5TuDh+DNzmqC+J1CqyywgWfDk=; b=LTZggdVw26EA8tuNQ+/gQioWxVFPS+LpEHrUfg/b2AKpTz9e2G9isab/ZJwjqOAl7b7TQH R9FS25eJqAVcGYa4fDa0b9VFyJskUprOAfQR9FESX3VtbvSM/ehjB7ieg6Uxg0b8yo363t nxeTlT9Et6gJPDy8+8XloUvfZEkLEyo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf20.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=1702896701; a=rsa-sha256; cv=none; b=PlkvALqLhP5fxlj4jCfTPYj6xR6AIPK+lgMlKZ7xXznZsMQllX6g6y+VcK4AXvGjeBkaJd G4Tuqjx5tQNapvlAuoZrK6hGd68sUd7swPteDw6WGJetdbHbYAlcwL+Xo1y6RJW9tlCmsn z0lO4bRr9BNLfQvBUlU8RskjdcebKc8= 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 A9CE72F4; Mon, 18 Dec 2023 02:52:24 -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 D00713F738; Mon, 18 Dec 2023 02:51:36 -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 v4 06/16] arm64/mm: pte_clear(): New layer to manage contig bit Date: Mon, 18 Dec 2023 10:50:50 +0000 Message-Id: <20231218105100.172635-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218105100.172635-1-ryan.roberts@arm.com> References: <20231218105100.172635-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 09E411C0016 X-Stat-Signature: 8zmn4w6cgfr93si84n1oumcbfaeb8of1 X-HE-Tag: 1702896700-379949 X-HE-Meta: U2FsdGVkX1/Aqck/UwU4BhFV3u5NFg7FYsmwVSaCqQMilaIrBXY1dL1pym3E1C3UJ7P4lQYC/IvsjnLHncMfW6B2/PBjH1i5KdJ76GSke6TurTXvsuilkPd+y3YEY5zR2iORqgklCefSlDoIFIYX+gCS9HVHk6GGjhKNvLZ68E+SCWNJ6lC1aGsIXW+aWvLYyzfaKt01LfF24lvCPHrLUVAcCcpt9W3+xmeaKHRZjw4dkDeE5f4GL/IKT8F7tozB4OX3dh5j6zzIebPGitqFbza7Fh85m2JbJTmU3j28zXzCE8NIWRSVzv7wuSIkzb8ejewpRIMeBwCBWNENfjwIREm1/8S1RByggT+XQmbSfZQSKgQlkqjtXbOzATJs7NIDsepHTq5lb1CQXZsLj6++x1OyDCEt+wnZSGsC2wvjKDpg1B3JAvaFqqa7WDwRDfTnCWGDDtlLJxyZMQ8r2PieyQso+20JctClJejD6fKzzN5Z9PB8tioslbUTXwLxeK1B0n2Z6bkbeeys+GII7ImdtWeeDBmftydNwa3T5venaNMQwrckTYSYbIPhFKuFYZFvA6y41yKGfl9sUwn3+cmV9E3aW86fAzTX7uhD9LDNPnGUPn8SD5YLjVypmvNzueQIN7WD1tsnKz+u/rhgTJAX7cjpaTXDhskkgplRKh7HdAU6Q10dd0y5CifZYBDKW8GXijK3YJyCnp++ih+hnIXxRtiklMgzNILgNjjyf39pk9g18BQas+4BrZPxpLDtr6bNTMdgQs88nrGVXl/ZubGB8fnKmlp0YhZZUNGM6hDxKX+fMCIB0+V0CquIvgd58VU7UXC/OZMv5kgumKLysRf5Uhxo2E2gDGYNU4NQQ8KPL0FPRNh02GSayw6UnQEw9pt0QCquWmPzcFafp3txasV9mgADeVGEGSFzqBZzB2JDCAKR29OVN/UmEp5PPqDA9ocm6vzHLqCaOdI6uO0Bctc y4w== 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. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 3 ++- arch/arm64/mm/fixmap.c | 2 +- arch/arm64/mm/hugetlbpage.c | 2 +- arch/arm64/mm/mmu.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 323ec91add60..1464e990580a 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -93,7 +93,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) #define pte_none(pte) (!pte_val(pte)) -#define pte_clear(mm, addr, ptep) \ +#define __pte_clear(mm, addr, ptep) \ __set_pte(ptep, __pte(0)) #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) @@ -1121,6 +1121,7 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define set_pte __set_pte #define set_ptes __set_ptes +#define pte_clear __pte_clear #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c index 51cd4501816d..bfc02568805a 100644 --- a/arch/arm64/mm/fixmap.c +++ b/arch/arm64/mm/fixmap.c @@ -123,7 +123,7 @@ void __set_fixmap(enum fixed_addresses idx, if (pgprot_val(flags)) { __set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags)); } else { - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr+PAGE_SIZE); } } diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 741cb53672fd..510b2d4b89a9 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -400,7 +400,7 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr, ncontig = num_contig_ptes(sz, &pgsize); for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); + __pte_clear(mm, addr, ptep); } pte_t huge_ptep_get_and_clear(struct mm_struct *mm, diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index e884279b268e..080e9b50f595 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -859,7 +859,7 @@ static void unmap_hotplug_pte_range(pmd_t *pmdp, unsigned long addr, continue; WARN_ON(!pte_present(pte)); - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr + PAGE_SIZE); if (free_mapped) free_hotplug_page_range(pte_page(pte),