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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DF9EC369D5 for ; Mon, 28 Apr 2025 12:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XS3+A4YF9jFlQhCbMVUw4bYPRQL/1ezEMDDEfM85mB0=; b=2dtLT/IzajAgwrxosekov+Asa8 JNCoAjai4dilL+U+bus75Dmhp/s/TSfJ9Vprrnk/CxoE24qvlnStQC4Yx7YSpr+NNHBd8WF+/R9r6 TZEM357e+RzXeWMDkEMiP9dGn35FP+mKFAepC1v6xfyPLJ3cNm91H4uXy8obABkc1myRZ0t9WpJXU gGTI5tcduYlFFicPiFdrhgCrfh23Nz6//83x52ELNI4BEwKN30LJnwC4JW/SrZntz+Hzlwe3OyXdT 98Uut6F4tRtzxj7oODid/b527MiBWytGtkv1cNWJWp8iQz4hA5aG+MUUbZdyNCD3e3KM/shsihv+L VQbkjgOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9NiH-00000006DEX-18fS; Mon, 28 Apr 2025 12:35:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9NET-000000065qx-12b9 for linux-arm-kernel@lists.infradead.org; Mon, 28 Apr 2025 12:05:10 +0000 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 52ACF22BE; Mon, 28 Apr 2025 05:05:02 -0700 (PDT) Received: from K4MQJ0H1H2.arm.com (unknown [10.163.78.210]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D26543F66E; Mon, 28 Apr 2025 05:04:58 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org Cc: ryan.roberts@arm.com, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, anshuman.khandual@arm.com, peterx@redhat.com, joey.gouly@arm.com, ioworker0@gmail.com, baohua@kernel.org, kevin.brodsky@arm.com, quic_zhenhuah@quicinc.com, christophe.leroy@csgroup.eu, yangyicong@hisilicon.com, linux-arm-kernel@lists.infradead.org, namit@vmware.com, hughd@google.com, yang@os.amperecomputing.com, ziy@nvidia.com, Dev Jain Subject: [PATCH 3/7] mm: Add batched versions of ptep_modify_prot_start/commit Date: Mon, 28 Apr 2025 17:34:10 +0530 Message-Id: <20250428120414.12101-4-dev.jain@arm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20250428120414.12101-1-dev.jain@arm.com> References: <20250428120414.12101-1-dev.jain@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250428_050509_339918_0800CAC4 X-CRM114-Status: GOOD ( 10.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Batch ptep_modify_prot_start/commit in preparation for optimizing mprotect. Architecture can override these helpers. Signed-off-by: Dev Jain --- include/linux/pgtable.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index b50447ef1c92..ed287289335f 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -891,6 +891,44 @@ static inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr, } #endif +/* See the comment for ptep_modify_prot_start */ +#ifndef modify_prot_start_ptes +static inline pte_t modify_prot_start_ptes(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, unsigned int nr) +{ + pte_t pte, tmp_pte; + + pte = ptep_modify_prot_start(vma, addr, ptep); + while (--nr) { + ptep++; + addr += PAGE_SIZE; + tmp_pte = ptep_modify_prot_start(vma, addr, ptep); + if (pte_dirty(tmp_pte)) + pte = pte_mkdirty(pte); + if (pte_young(tmp_pte)) + pte = pte_mkyoung(pte); + } + return pte; +} +#endif + +/* See the comment for ptep_modify_prot_commit */ +#ifndef modify_prot_commit_ptes +static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned long addr, + pte_t *ptep, pte_t old_pte, pte_t pte, unsigned int nr) +{ + for (;;) { + ptep_modify_prot_commit(vma, addr, ptep, old_pte, pte); + if (--nr == 0) + break; + ptep++; + addr += PAGE_SIZE; + old_pte = pte_next_pfn(old_pte); + pte = pte_next_pfn(pte); + } +} +#endif + /* * On some architectures hardware does not set page access bit when accessing * memory page, it is responsibility of software setting this bit. It brings -- 2.30.2